Mercurial > hg > batmud > maputils
annotate mkloc.c @ 1775:db7fdbc8f81b
Modernification cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 28 Oct 2017 04:07:28 +0300 |
parents | 72adabd8e746 |
children | 77d6e13fb95e |
rev | line source |
---|---|
37 | 1 /* |
758 | 2 * mkloc - Manipulate and convert BatMUD location data files |
37 | 3 * |
4 * Programmed by Matti 'ccr' Hämäläinen (Ggr Pupunen) | |
1487 | 5 * (C) Copyright 2006-2015 Tecnic Software productions (TNSP) |
37 | 6 */ |
1308
d11f9751e299
Renamed maputils.[ch] -> libmaputils.[ch], adjusted other code accordingly;
Matti Hamalainen <ccr@tnsp.org>
parents:
1302
diff
changeset
|
7 #include "libmaputils.h" |
1302
9233b482b87a
Moved loc-file functionality to liblocfile.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
1249
diff
changeset
|
8 #include "liblocfile.h" |
37 | 9 #include "th_args.h" |
10 #include "th_string.h" | |
1754
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
11 #include "th_datastruct.h" |
51
6c51042147c1
Lots of code cleanups, moved stuff from main() to other functions
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
12 |
1484
2350cd3a6feb
Update to match the changes in th_args API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
13 enum |
2350cd3a6feb
Update to match the changes in th_args API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
14 { |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
15 OUTFMT_MAP = 0, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
16 OUTFMT_LOCFILE, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
17 OUTFMT_SCRIPT, |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
18 OUTFMT_MAPLOC, |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
19 OUTFMT_GMAPS |
100
55f7140efa2f
Support for generating shellscript for using imagemagick to add labels into
Matti Hamalainen <ccr@tnsp.org>
parents:
97
diff
changeset
|
20 }; |
55f7140efa2f
Support for generating shellscript for using imagemagick to add labels into
Matti Hamalainen <ccr@tnsp.org>
parents:
97
diff
changeset
|
21 |
1484
2350cd3a6feb
Update to match the changes in th_args API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
22 enum |
2350cd3a6feb
Update to match the changes in th_args API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
23 { |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
24 GMAPS_XML = 0, |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
25 GMAPS_JSON, |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
26 GMAPS_LAST |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
27 }; |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
28 |
1770 | 29 // These must be in lower case |
1484
2350cd3a6feb
Update to match the changes in th_args API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
30 const char *gmapsModes[GMAPS_LAST] = |
2350cd3a6feb
Update to match the changes in th_args API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
31 { |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
32 "xml", |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
33 "json", |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
34 }; |
100
55f7140efa2f
Support for generating shellscript for using imagemagick to add labels into
Matti Hamalainen <ccr@tnsp.org>
parents:
97
diff
changeset
|
35 |
37 | 36 /* Variables |
37 */ | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
38 char *srcFile = NULL, |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
39 *destFile = NULL; |
37 | 40 |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
41 int nlocFiles = -1; |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
42 LocFileInfo locFiles[LOC_MAX_FILES]; |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
43 |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
44 char *optLocMarkers = LOC_MARKERS; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
45 BOOL optGetUpdateLoc = FALSE, |
713 | 46 optOutput = OUTFMT_MAP, |
47 optNoLabels = FALSE, | |
48 optNoAdjust = FALSE, | |
49 optLabelType = FALSE; | |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
50 int optGMapsMode = -1; |
713 | 51 float optScale = -1, |
52 optUnitSize = 1.0f, | |
53 optFontScale = 1.0f; | |
104 | 54 |
45 | 55 |
37 | 56 /* Arguments |
57 */ | |
1615 | 58 static const th_optarg optList[] = |
1484
2350cd3a6feb
Update to match the changes in th_args API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
59 { |
713 | 60 { 0, '?', "help", "Show this help", OPT_NONE }, |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
61 { 2, 'v', "verbose", "Be more verbose", OPT_NONE }, |
713 | 62 { 3, 'q', "quiet", "Be quiet", OPT_NONE }, |
63 { 1, 'o', "output", "Output file (default stdout)", OPT_ARGREQ }, | |
64 { 5, 'm', "map", "Input map file", OPT_ARGREQ }, | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
65 { 6, 'l', "locinfo", "Input location info file", OPT_ARGREQ }, |
713 | 66 { 4, 'g', "getloc", "Generate/update location info", OPT_NONE }, |
67 { 7, 'x', "offset-x", "Location X offset", OPT_ARGREQ }, | |
68 { 8, 'y', "offset-y", "Location Y offset", OPT_ARGREQ }, | |
69 { 9, 's', "scale", "Scale coordinates by", OPT_ARGREQ }, | |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
70 { 12,'f', "font-scale", "(-S) Font scale factor", OPT_ARGREQ }, |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
71 { 13,'u', "unit-size", "(-S) Unit size", OPT_ARGREQ }, |
713 | 72 { 10,'S', "out-script", "Output script for ImageMagick", OPT_NONE }, |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
73 { 11,'L', "out-locinfo","Output location info file", OPT_NONE }, |
713 | 74 { 17,'M', "out-maploc", "Output MapLoc HTML", OPT_NONE }, |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
75 { 20,'G', "out-gmaps", "Output GMaps data (xml, overlay, labels)", OPT_ARGREQ }, |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
76 { 21,'c', "continent", "Continent for GMaps XML output", OPT_ARGREQ }, |
713 | 77 { 15,'n', "no-labels", "No labels, only markers", OPT_NONE }, |
78 { 16,'N', "no-adjust", "No label adjustment", OPT_NONE }, | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
79 { 18,'t', "type-prefix","Prepend labels with type prefix", OPT_NONE }, |
769
ee943e669003
The loc-file parser was completely refactored into a state-machine. This may, or may not make future changes easier. It's at least cleaner and more flexible.; Support for multiple location names was added.; Parsing of coder names into separate strings was implemented.
Matti Hamalainen <ccr@tnsp.org>
parents:
758
diff
changeset
|
80 { 19,'X', "loc-markers","Location markers ('" LOC_MARKERS "')", OPT_ARGREQ }, |
37 | 81 }; |
82 | |
1484
2350cd3a6feb
Update to match the changes in th_args API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
83 static const int optListN = sizeof(optList) / sizeof(optList[0]); |
37 | 84 |
85 | |
86 void argShowHelp() | |
87 { | |
1249 | 88 th_print_banner(stdout, th_prog_name, |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
89 "[options]"); |
1249 | 90 |
1484
2350cd3a6feb
Update to match the changes in th_args API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
91 th_args_help(stdout, optList, optListN, 0); |
37 | 92 } |
93 | |
94 | |
65
cceeafe5b400
Use standard types and th-lib types instead of D*
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
95 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) |
37 | 96 { |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
97 int i; |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
98 LocFileInfo *f; |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
99 |
1315 | 100 switch (optN) |
101 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
102 case 0: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
103 argShowHelp(); |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
104 exit(0); |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
105 break; |
37 | 106 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
107 case 2: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
108 th_verbosityLevel++; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
109 break; |
1543 | 110 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
111 case 3: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
112 th_verbosityLevel = -1; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
113 break; |
1543 | 114 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
115 case 1: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
116 destFile = optArg; |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
117 THMSG(2, "Output file '%s'\n", destFile); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
118 break; |
37 | 119 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
120 case 5: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
121 srcFile = optArg; |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
122 THMSG(2, "Map file '%s'\n", srcFile); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
123 break; |
37 | 124 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
125 case 6: |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
126 nlocFiles++; |
1315 | 127 if (nlocFiles < LOC_MAX_FILES) |
128 { | |
1526
aba0900dc31a
Refactor liblocfile API a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1509
diff
changeset
|
129 setLocFileInfo(&locFiles[nlocFiles], optArg, NULL); |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
130 THMSG(2, "Added location data file #%d '%s'\n", nlocFiles, optArg); |
1315 | 131 } |
132 else | |
133 { | |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
134 THERR("Too many location data files specified, maximum is %d.\n", LOC_MAX_FILES); |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
135 return FALSE; |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
136 } |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
137 break; |
1543 | 138 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
139 case 4: |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
140 THMSG(2, "Location updating/generation mode\n"); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
141 optGetUpdateLoc = TRUE; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
142 break; |
37 | 143 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
144 case 7: |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
145 f = &locFiles[nlocFiles]; |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
146 f->x = atoi(optArg); |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
147 THMSG(2, "Location file #%d X offset = %d\n", nlocFiles, f->x); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
148 break; |
61
4efae5dae2e3
th_args_process() transition.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
149 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
150 case 8: |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
151 f = &locFiles[nlocFiles]; |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
152 f->y = atoi(optArg); |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
153 THMSG(2, "Location file #%d Y offset = %d\n", nlocFiles, f->y); |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
154 break; |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
155 |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
156 case 21: |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
157 f = &locFiles[nlocFiles]; |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
158 th_free(f->continent); |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
159 f->continent = th_strdup(optArg); |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
160 THMSG(2, "Using continent name '%s' for location file #%d\n", optArg, nlocFiles); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
161 break; |
100
55f7140efa2f
Support for generating shellscript for using imagemagick to add labels into
Matti Hamalainen <ccr@tnsp.org>
parents:
97
diff
changeset
|
162 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
163 case 9: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
164 optScale = atof(optArg); |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
165 THMSG(2, "Location scale factor = %1.3f\n", optScale); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
166 break; |
100
55f7140efa2f
Support for generating shellscript for using imagemagick to add labels into
Matti Hamalainen <ccr@tnsp.org>
parents:
97
diff
changeset
|
167 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
168 case 10: |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
169 THMSG(2, "Script output mode\n"); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
170 optOutput = OUTFMT_SCRIPT; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
171 break; |
100
55f7140efa2f
Support for generating shellscript for using imagemagick to add labels into
Matti Hamalainen <ccr@tnsp.org>
parents:
97
diff
changeset
|
172 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
173 case 11: |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
174 THMSG(2, "Location file output mode\n"); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
175 optOutput = OUTFMT_LOCFILE; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
176 break; |
61
4efae5dae2e3
th_args_process() transition.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
177 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
178 case 17: |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
179 THMSG(2, "MapLoc HTML output mode\n"); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
180 optOutput = OUTFMT_MAPLOC; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
181 break; |
306
6ba2b8ddf2e6
Various improvements in generating maps.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
182 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
183 case 12: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
184 optFontScale = atof(optArg); |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
185 THMSG(2, "Font scale factor = %1.3f\n", optFontScale); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
186 break; |
339
7e4e8bb2a9fd
Separate settings/options for fontscale and unitsize.
Matti Hamalainen <ccr@tnsp.org>
parents:
333
diff
changeset
|
187 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
188 case 13: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
189 optUnitSize = atof(optArg); |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
190 THMSG(2, "Unit size = %1.3f\n", optUnitSize); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
191 break; |
104 | 192 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
193 case 15: |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
194 THMSG(2, "Not adding labels to locations\n"); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
195 optNoLabels = TRUE; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
196 break; |
104 | 197 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
198 case 16: |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
199 THMSG(2, "Not adjusting data under labels\n"); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
200 optNoAdjust = TRUE; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
201 break; |
306
6ba2b8ddf2e6
Various improvements in generating maps.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
202 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
203 case 18: |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
204 THMSG(2, "Adding label type prefixes\n"); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
205 optLabelType = TRUE; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
206 break; |
385
9433b416681e
Bunch of improvements, or something.
Matti Hamalainen <ccr@tnsp.org>
parents:
383
diff
changeset
|
207 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
208 case 19: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
209 optLocMarkers = optArg; |
797
b1846f1b4ff2
Adjust verbosity of some actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
794
diff
changeset
|
210 THMSG(2, "Using location markers = '%s'\n", optLocMarkers); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
211 break; |
440
9b1f463cab00
Add -X/--loc-markers option to mkloc.
Matti Hamalainen <ccr@tnsp.org>
parents:
421
diff
changeset
|
212 |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
213 case 20: |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
214 optOutput = OUTFMT_GMAPS; |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
215 optGMapsMode = -1; |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
216 for (i = 0; i < GMAPS_LAST; i++) |
1315 | 217 if (tolower(optArg[0]) == gmapsModes[i][0]) |
218 { | |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
219 optGMapsMode = i; |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
220 break; |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
221 } |
1543 | 222 |
1315 | 223 if (optGMapsMode < 0) |
224 { | |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
225 THERR("Invalid GMaps mode '%s'.\n", optArg); |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
226 return FALSE; |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
227 } |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
228 THMSG(2, "GMaps output mode '%s' selected\n", gmapsModes[optGMapsMode]); |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
229 break; |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
230 |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
231 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
232 default: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
233 THERR("Unknown option '%s'.\n", currArg); |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
234 return FALSE; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
235 } |
1543 | 236 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
237 return TRUE; |
37 | 238 } |
239 | |
38 | 240 |
1448 | 241 int locPrintType(FILE *outFile, LocMarker *loc, BOOL adjust, int (*func)(const char *, FILE *), BOOL label) |
242 { | |
243 const char *type = locGetType(loc->flags); | |
244 int len = 0; | |
245 | |
246 if (type != NULL && label) | |
247 { | |
248 len += strlen(type) + 1; | |
249 if (outFile != NULL && func != NULL) | |
250 fprintf(outFile, "%s ", type); | |
251 } | |
252 | |
253 if (func != NULL) | |
254 { | |
255 char *name = (loc->names[0].name != NULL) ? loc->names[0].name : "UNKNOWN"; | |
256 if (outFile != NULL) | |
257 func(name, outFile); | |
258 len += strlen(name); | |
259 | |
260 if (label && (loc->flags & LOCF_CLOSED)) | |
261 { | |
262 static const char *strClosed = " (CLOSED)"; | |
263 if (outFile != NULL) | |
264 func(strClosed, outFile); | |
265 len += strlen(strClosed); | |
266 } | |
267 } | |
268 | |
269 return adjust ? len : 0; | |
270 } | |
271 | |
272 | |
130 | 273 /* Adjust location label coordinates for the ASCII-CTRL map |
274 */ | |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
275 void adjustLocInfoCoords(MapBlock *map, MapLocations *l) |
104 | 276 { |
1775 | 277 for (int i = 0; i < l->n; i++) |
1315 | 278 { |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
279 int y, x0, x1, len; |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
280 LocMarker *tmp = l->locations[i]; |
1543 | 281 |
963
fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
961
diff
changeset
|
282 len = strlen(tmp->names[0].name); |
1083 | 283 if (optLabelType) |
1448 | 284 len += locPrintType(NULL, tmp, TRUE, NULL, FALSE); |
1543 | 285 |
1770 | 286 // Compute text location |
1526
aba0900dc31a
Refactor liblocfile API a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1509
diff
changeset
|
287 switch (tmp->align) |
1315 | 288 { |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
289 case LOCD_LEFTDOWN: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
290 y = tmp->y + 1; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
291 x0 = tmp->x - len; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
292 break; |
1543 | 293 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
294 case LOCD_LEFT: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
295 y = tmp->y - 1; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
296 x0 = tmp->x - len; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
297 break; |
104 | 298 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
299 case LOCD_DOWN: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
300 y = tmp->y + 1; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
301 x0 = tmp->x + 1; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
302 break; |
1543 | 303 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
304 case LOCD_NONE: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
305 default: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
306 y = tmp->y - 1; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
307 x0 = tmp->x + 1; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
308 break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
309 } |
1543 | 310 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
311 x1 = x0 + len + 1; |
1543 | 312 |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
313 if (x1 > map->width) |
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
314 x0 -= (x1 - map->width - 1); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
315 if (x0 < 0) x0 = 0; |
1543 | 316 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
317 if (y < 0) y += 2; |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
318 if (y > map->height) y -= (y - map->height - 1); |
1543 | 319 |
1770 | 320 // Update location info |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
321 tmp->x = x0; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
322 tmp->y = y; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
323 } |
104 | 324 } |
325 | |
326 | |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
327 /* Check for adjacent markers |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
328 */ |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
329 int checkForAdjacent(MapLocations *world, int cx, int cy, int mask) |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
330 { |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
331 int x, y, n; |
1543 | 332 |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
333 for (y = -1; y <= 1; y++) |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
334 for (x = -1; x <= 1; x++) |
1315 | 335 { |
1543 | 336 if (!(y == 0 && x == 0) && |
1315 | 337 (n = locFindByCoords(world, cx + x, cy + y, TRUE)) >= 0) |
338 { | |
339 LocMarker *loc = world->locations[n]; | |
340 if ((loc->flags & mask) == mask) | |
341 return n; | |
342 } | |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
343 } |
1543 | 344 |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
345 return -1; |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
346 } |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
347 |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
348 |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
349 /* Scan given map and update location list with new locations, |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
350 * if any are found. |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
351 */ |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
352 void updateLocations(MapBlock *worldMap, MapLocations *worldLoc) |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
353 { |
1775 | 354 int n, numNewLoc = 0, numInvLoc = 0, numNoMarker = 0; |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
355 LocMarker *tmpl; |
1543 | 356 |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
357 THMSG(2, "Updating location information ..\n"); |
1543 | 358 |
1770 | 359 // Find new, unknown locations |
1775 | 360 for (int y = 0; y < worldMap->height; y++) |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
361 { |
1775 | 362 unsigned char *dp = worldMap->data + (worldMap->scansize * y); |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
363 |
1775 | 364 for (int x = 0; x < worldMap->width; x++) |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
365 { |
1315 | 366 if (strchr(optLocMarkers, dp[x])) |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
367 { |
1503
13b8f4bb0b19
Change locAddName() and locAddNew() API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1496
diff
changeset
|
368 LocName tmpNames[LOC_MAX_NAMES]; |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
369 char tmpDesc[512]; |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
370 int tmpFlags; |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
371 |
1770 | 372 // Check for new locations |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
373 if (locFindByCoords(worldLoc, x, y, TRUE) >= 0) |
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
374 continue; |
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
375 |
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
376 |
1315 | 377 if (dp[x] == 'C') |
378 { | |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
379 n = checkForAdjacent(worldLoc, x, y, LOCF_M_PCITY); |
1315 | 380 if (n >= 0) |
381 { | |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
382 tmpl = worldLoc->locations[n]; |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
383 tmpFlags = LOCF_M_PCITY | LOCF_INVIS; |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
384 snprintf(tmpDesc, sizeof(tmpDesc), |
963
fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
961
diff
changeset
|
385 "%s", tmpl->names[0].name); |
1543 | 386 |
1315 | 387 } |
388 else | |
389 { | |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
390 numNewLoc++; |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
391 tmpFlags = LOCF_M_PCITY; |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
392 snprintf(tmpDesc, sizeof(tmpDesc), |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
393 "%.3s-PCITY #%d", |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
394 srcFile, numNewLoc); |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
395 } |
1315 | 396 } |
397 else | |
398 { | |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
399 numNewLoc++; |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
400 tmpFlags = LOCF_NONE; |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
401 snprintf(tmpDesc, sizeof(tmpDesc), |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
402 "%.3s-UNK #%d", |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
403 srcFile, numNewLoc); |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
404 } |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
405 memset(tmpNames, 0, sizeof(tmpNames)); |
1503
13b8f4bb0b19
Change locAddName() and locAddNew() API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1496
diff
changeset
|
406 tmpNames[0].name = tmpDesc; |
1166
54cf0d06d632
Rename various functions to somewhat saner names as they are in maputils library now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1165
diff
changeset
|
407 locAddNew(worldLoc, x, y, LOCD_NONE, tmpFlags, |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
408 tmpNames, NULL, NULL, FALSE, NULL, NULL, NULL); |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
409 |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
410 } |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
411 else |
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
412 { |
1770 | 413 // Check for misplaced locations |
1315 | 414 if ((n = locFindByCoords(worldLoc, x, y, TRUE)) >= 0) |
415 { | |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
416 tmpl = worldLoc->locations[n]; |
1543 | 417 |
1315 | 418 if (tmpl->flags == LOCF_NONE) |
419 { | |
1770 | 420 // Mark as possibly invalid |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
421 tmpl->flags |= LOCF_INVALID; |
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
422 numInvLoc++; |
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
423 } |
1543 | 424 |
1315 | 425 if ((tmpl->flags & LOCF_M_MASK) == 0) |
426 { | |
1770 | 427 // No apparent marker |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
428 tmpl->flags |= LOCF_NOMARKER; |
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
429 numNoMarker++; |
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
430 } |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
431 } |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
432 } |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
433 } |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
434 } |
1543 | 435 |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
436 THMSG(1, "%d new locations, %d invalid, %d missing marker.\n", |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
437 numNewLoc, numInvLoc, numNoMarker); |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
438 } |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
439 |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
440 |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
441 /* Quicksort comparision function for location names |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
442 */ |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
443 int maplocCompare(const void *p1, const void *p2) |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
444 { |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
445 LocMarker *vp1 = *(LocMarker **) p1, *vp2 = *(LocMarker **) p2; |
1543 | 446 |
1062
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
447 if (vp1->val == vp2->val) |
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
448 return strcmp(vp1->names[0].name, vp2->names[0].name); |
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
449 else |
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
450 return vp1->val - vp2->val; |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
451 } |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
452 |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
453 |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
454 /* Sort locations by name |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
455 */ |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
456 void maplocSort(MapLocations *l) |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
457 { |
1775 | 458 for (int i = 0; i < l->n; i++) |
1315 | 459 { |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
460 LocMarker *loc = l->locations[i]; |
1062
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
461 loc->val = 2; |
1543 | 462 |
1315 | 463 switch (loc->flags & LOCF_M_MASK) |
464 { | |
1775 | 465 case LOCF_M_CITY: loc->val = 1; break; |
466 case LOCF_M_PCITY: loc->val = 10; break; | |
467 default: | |
468 switch (loc->flags & LOCF_T_MASK) | |
469 { | |
470 case LOCF_T_GUILD: loc->val = 3; break; | |
471 case LOCF_T_TRAINER: loc->val = 4; break; | |
472 case LOCF_T_SHRINE: loc->val = 5; break; | |
473 case LOCF_T_SS: loc->val = 6; break; | |
474 case LOCF_T_MONSTER: loc->val = 7; break; | |
475 case LOCF_T_FORT: loc->val = 100; break; | |
476 } | |
1062
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
477 } |
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
478 } |
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
479 |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
480 qsort(l->locations, l->n, sizeof(LocMarker *), maplocCompare); |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
481 } |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
482 |
1062
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
483 |
130 | 484 /* Output the map with labels and location markers, etc. in |
485 * special ASCII-CTRL format understood by colormap utility. | |
486 */ | |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
487 void outputMapCTRL(FILE *outFile, MapBlock *map, MapLocations *l) |
51
6c51042147c1
Lots of code cleanups, moved stuff from main() to other functions
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
488 { |
1775 | 489 for (int y = 0; y < map->height; y++) |
1315 | 490 { |
1775 | 491 unsigned char *dp = map->data + (map->scansize * y); |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
492 |
1775 | 493 for (int x = 0; x < map->width; x++) |
1315 | 494 { |
1775 | 495 int n; |
1315 | 496 if ((n = locFindByCoords(l, x, y, TRUE)) >= 0) |
497 { | |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
498 LocMarker *tmp = l->locations[n]; |
1736
7a2d618f77d2
Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
1718
diff
changeset
|
499 char chm = dp[x]; |
1543 | 500 |
1315 | 501 switch (tmp->flags & LOCF_M_MASK) |
502 { | |
1736
7a2d618f77d2
Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
1718
diff
changeset
|
503 case LOCF_M_SCENIC1: chm = '?'; break; |
7a2d618f77d2
Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
1718
diff
changeset
|
504 case LOCF_M_SCENIC2: chm = '%'; break; |
7a2d618f77d2
Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
1718
diff
changeset
|
505 case LOCF_M_PCITY: chm = 'C'; break; |
7a2d618f77d2
Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
1718
diff
changeset
|
506 case LOCF_M_CITY: chm = 'c'; break; |
1543 | 507 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
508 default: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
509 if (tmp->flags & LOCF_INVALID) |
1736
7a2d618f77d2
Various minor code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
1718
diff
changeset
|
510 chm = '$'; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
511 break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
512 } |
1543 | 513 |
1745
65e37d990069
Implement marker tags, used only for HTML output.
Matti Hamalainen <ccr@tnsp.org>
parents:
1737
diff
changeset
|
514 fputc(0xfb, outFile); |
65e37d990069
Implement marker tags, used only for HTML output.
Matti Hamalainen <ccr@tnsp.org>
parents:
1737
diff
changeset
|
515 fprintf(outFile, "mloc%d_%d", tmp->ox + 1, tmp->oy + 1); |
65e37d990069
Implement marker tags, used only for HTML output.
Matti Hamalainen <ccr@tnsp.org>
parents:
1737
diff
changeset
|
516 fputc(0xfc, outFile); |
1737 | 517 fputc(chm, outFile); |
1745
65e37d990069
Implement marker tags, used only for HTML output.
Matti Hamalainen <ccr@tnsp.org>
parents:
1737
diff
changeset
|
518 fputc(0xfe, outFile); |
1315 | 519 } |
520 else | |
521 if (!optNoLabels && (n = locFindByCoords(l, x, y, FALSE)) >= 0) | |
522 { | |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
523 LocMarker *tmp = l->locations[n]; |
1543 | 524 |
1315 | 525 if ((tmp->flags & LOCF_INVIS) == 0) |
526 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
527 int col = col_light_white; |
1543 | 528 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
529 fputc(0xff, outFile); |
992
218a9ccd0c08
Generate maplocctrl data with correct coordinates (matching the LOC input coordinates origo 1,1).
Matti Hamalainen <ccr@tnsp.org>
parents:
987
diff
changeset
|
530 fprintf(outFile, "loc%d_%d", tmp->ox + 1, tmp->oy + 1); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
531 fputc(0xfc, outFile); |
1543 | 532 |
1315 | 533 switch (tmp->flags & LOCF_M_MASK) |
534 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
535 case LOCF_M_PCITY: col = col_light_green; break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
536 case LOCF_M_CITY: col = col_light_red; break; |
1543 | 537 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
538 default: |
1315 | 539 switch (tmp->flags & LOCF_T_MASK) |
540 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
541 case LOCF_T_SHRINE: col = col_light_yellow; break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
542 case LOCF_T_GUILD: col = col_light_magenta; break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
543 case LOCF_T_MONSTER: col = col_light_cyan; break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
544 case LOCF_T_TRAINER: col = col_light_magenta; break; |
758 | 545 case LOCF_T_FORT: col = col_light_cyan; break; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
546 default: col = col_light_white; break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
547 } |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
548 break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
549 } |
1543 | 550 |
1422
6541f0a63b3b
Colorize closed locations in red.
Matti Hamalainen <ccr@tnsp.org>
parents:
1416
diff
changeset
|
551 if (tmp->flags & LOCF_CLOSED) |
6541f0a63b3b
Colorize closed locations in red.
Matti Hamalainen <ccr@tnsp.org>
parents:
1416
diff
changeset
|
552 col = col_light_red; |
1543 | 553 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
554 fputc(col, outFile); |
1543 | 555 |
1315 | 556 if (optLabelType) |
557 { | |
1448 | 558 x += locPrintType(outFile, tmp, !optNoAdjust, NULL, FALSE); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
559 } |
1543 | 560 |
963
fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
961
diff
changeset
|
561 fputs(tmp->names[0].name, outFile); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
562 fputc(0xfe, outFile); |
1543 | 563 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
564 if (!optNoAdjust) |
963
fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
961
diff
changeset
|
565 x += strlen(tmp->names[0].name) - 1; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
566 else |
1315 | 567 fputc(dp[x], outFile); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
568 } |
1315 | 569 else |
570 fputc(dp[x], outFile); | |
1775 | 571 } |
572 else | |
1315 | 573 fputc(dp[x], outFile); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
574 } |
1315 | 575 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
576 fprintf(outFile, "\n"); |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
577 } |
51
6c51042147c1
Lots of code cleanups, moved stuff from main() to other functions
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
578 } |
6c51042147c1
Lots of code cleanups, moved stuff from main() to other functions
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
579 |
6c51042147c1
Lots of code cleanups, moved stuff from main() to other functions
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
580 |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
581 /* Print out location list as HTML option list. |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
582 */ |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
583 void outputMapLocHTML(FILE *outFile, MapLocations *l) |
306
6ba2b8ddf2e6
Various improvements in generating maps.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
584 { |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
585 assert(l != NULL); |
1543 | 586 |
1718
781e487ecd5e
Implement "no location selected" for the html+js dropdown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1692
diff
changeset
|
587 fprintf(outFile, "<option value=\"\">-</option>\n"); |
781e487ecd5e
Implement "no location selected" for the html+js dropdown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1692
diff
changeset
|
588 |
1775 | 589 for (int i = 0; i < l->n; i++) |
1315 | 590 { |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
591 LocMarker *tmp = l->locations[i]; |
306
6ba2b8ddf2e6
Various improvements in generating maps.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
592 |
1062
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
593 if (tmp->flags & LOCF_INVIS) |
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
594 continue; |
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
595 |
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
596 fprintf(outFile, "<option value=\"loc%d_%d\">", tmp->ox + 1, tmp->oy + 1); |
1448 | 597 locPrintType(outFile, tmp, FALSE, fputse, TRUE); |
1062
96508cc234b6
Improve location pulldown menu list generation and sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1056
diff
changeset
|
598 fprintf(outFile, "</option>\n"); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
599 } |
306
6ba2b8ddf2e6
Various improvements in generating maps.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
600 } |
6ba2b8ddf2e6
Various improvements in generating maps.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
601 |
6ba2b8ddf2e6
Various improvements in generating maps.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
602 |
130 | 603 /* Output generated locations into given file stream |
604 */ | |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
605 void printLocNameEsc(FILE *outFile, LocName *name) |
960
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
606 { |
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
607 char *prefix = ""; |
1315 | 608 switch (name->flags) |
609 { | |
960
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
610 case NAME_ORIG: prefix = "@"; break; |
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
611 case NAME_RECODER: prefix = "!"; break; |
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
612 case NAME_MAINTAINER: prefix = "%"; break; |
967
68c91395d9a0
Added '&' "expander" flag for creators.
Matti Hamalainen <ccr@tnsp.org>
parents:
963
diff
changeset
|
613 case NAME_EXPANDER: prefix = "&"; break; |
960
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
614 } |
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
615 fputs(prefix, outFile); |
1436
36b6e1dd4ab1
Use helper functions moved to libmaputils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1433
diff
changeset
|
616 fputsesc2(name->name, outFile); |
960
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
617 } |
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
618 |
1315 | 619 |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
620 void outputLocationFile(FILE *outFile, MapLocations *l) |
51
6c51042147c1
Lots of code cleanups, moved stuff from main() to other functions
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
621 { |
1770 | 622 // Output header |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
623 fprintf(outFile, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
624 "# " LOC_MAGIC " (version %d.%d)\n", |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
625 LOC_VERSION_MAJOR, LOC_VERSION_MINOR |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
626 ); |
1543 | 627 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
628 fprintf(outFile, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
629 "# Refer to README.loc for more information.\n" |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
630 "#\n" |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
631 ); |
1543 | 632 |
1770 | 633 // Output each location entry |
1775 | 634 for (int i = 0; i < l->n; i++) |
1315 | 635 { |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
636 LocMarker *tmp = l->locations[i]; |
1543 | 637 |
1770 | 638 // Add comment in few cases |
1315 | 639 if (tmp->flags & LOCF_Q_MASK) |
640 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
641 char *s = NULL; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
642 if (tmp->flags & LOCF_NOMARKER) |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
643 s = "Location missing marker"; |
1692 | 644 else |
645 if (tmp->flags & LOCF_INVALID) | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
646 s = "Possibly invalid location"; |
1543 | 647 |
1315 | 648 if (s) |
649 { | |
769
ee943e669003
The loc-file parser was completely refactored into a state-machine. This may, or may not make future changes easier. It's at least cleaner and more flexible.; Support for multiple location names was added.; Parsing of coder names into separate strings was implemented.
Matti Hamalainen <ccr@tnsp.org>
parents:
758
diff
changeset
|
650 fprintf(outFile, "\n# %s #%d: %s\n", |
963
fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
961
diff
changeset
|
651 s, i, tmp->names[0].name); |
769
ee943e669003
The loc-file parser was completely refactored into a state-machine. This may, or may not make future changes easier. It's at least cleaner and more flexible.; Support for multiple location names was added.; Parsing of coder names into separate strings was implemented.
Matti Hamalainen <ccr@tnsp.org>
parents:
758
diff
changeset
|
652 } |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
653 } |
1543 | 654 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
655 fprintf(outFile, "%d\t; %d\t; %d", |
1526
aba0900dc31a
Refactor liblocfile API a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1509
diff
changeset
|
656 tmp->ox + 1, tmp->oy + 1, tmp->align); |
1543 | 657 |
1315 | 658 switch (tmp->flags & LOCF_M_MASK) |
659 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
660 case LOCF_M_SCENIC1: fputc('?', outFile); break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
661 case LOCF_M_SCENIC2: fputc('%', outFile); break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
662 case LOCF_M_PCITY: fputc('C', outFile); break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
663 case LOCF_M_CITY: fputc('c', outFile); break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
664 } |
104 | 665 |
1315 | 666 switch (tmp->flags & LOCF_T_MASK) |
667 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
668 case LOCF_T_SHRINE: fputc('S', outFile); break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
669 case LOCF_T_GUILD: fputc('G', outFile); break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
670 case LOCF_T_SS: fputc('P', outFile); break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
671 case LOCF_T_MONSTER: fputc('M', outFile); break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
672 case LOCF_T_TRAINER: fputc('T', outFile); break; |
754
ca0a750abbb9
Add support for FORT flag 'F'.
Matti Hamalainen <ccr@tnsp.org>
parents:
713
diff
changeset
|
673 case LOCF_T_FORT: fputc('F', outFile); break; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
674 } |
960
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
675 |
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
676 if (tmp->flags & LOCF_CLOSED) |
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
677 fputc('!', outFile); |
1543 | 678 |
1657
c2a6e11ea44c
Add instance flag support to liblocfile and mkloc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1615
diff
changeset
|
679 if (tmp->flags & LOCF_INSTANCED) |
c2a6e11ea44c
Add instance flag support to liblocfile and mkloc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1615
diff
changeset
|
680 fputc('I', outFile); |
c2a6e11ea44c
Add instance flag support to liblocfile and mkloc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1615
diff
changeset
|
681 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
682 if (tmp->flags & LOCF_INVIS) |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
683 fputc('-', outFile); |
1543 | 684 |
773
2b8e29cef145
Properly escape sequences in loc-format output. Allow escaping of characters inside strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
772
diff
changeset
|
685 fprintf(outFile, "\t;"); |
963
fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
961
diff
changeset
|
686 printLocNameEsc(outFile, &tmp->names[0]); |
1775 | 687 for (int n = 1; n < tmp->nnames; n++) |
1315 | 688 { |
773
2b8e29cef145
Properly escape sequences in loc-format output. Allow escaping of characters inside strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
772
diff
changeset
|
689 fprintf(outFile, "|"); |
963
fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
961
diff
changeset
|
690 printLocNameEsc(outFile, &tmp->names[n]); |
773
2b8e29cef145
Properly escape sequences in loc-format output. Allow escaping of characters inside strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
772
diff
changeset
|
691 } |
769
ee943e669003
The loc-file parser was completely refactored into a state-machine. This may, or may not make future changes easier. It's at least cleaner and more flexible.; Support for multiple location names was added.; Parsing of coder names into separate strings was implemented.
Matti Hamalainen <ccr@tnsp.org>
parents:
758
diff
changeset
|
692 fprintf(outFile, ";"); |
1543 | 693 |
1315 | 694 if (tmp->ncoders > 0) |
695 { | |
963
fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
961
diff
changeset
|
696 printLocNameEsc(outFile, &tmp->coders[0]); |
1775 | 697 for (int n = 1; n < tmp->ncoders; n++) |
1315 | 698 { |
773
2b8e29cef145
Properly escape sequences in loc-format output. Allow escaping of characters inside strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
772
diff
changeset
|
699 fprintf(outFile, ","); |
963
fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
961
diff
changeset
|
700 printLocNameEsc(outFile, &tmp->coders[n]); |
773
2b8e29cef145
Properly escape sequences in loc-format output. Allow escaping of characters inside strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
772
diff
changeset
|
701 } |
769
ee943e669003
The loc-file parser was completely refactored into a state-machine. This may, or may not make future changes easier. It's at least cleaner and more flexible.; Support for multiple location names was added.; Parsing of coder names into separate strings was implemented.
Matti Hamalainen <ccr@tnsp.org>
parents:
758
diff
changeset
|
702 } |
1543 | 703 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
704 fprintf(outFile, ";"); |
1543 | 705 |
1315 | 706 if (tmp->valid) |
707 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
708 fprintf(outFile, LOC_TIMEFMT, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
709 tmp->added.day, tmp->added.month, tmp->added.year); |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
710 } |
1543 | 711 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
712 fprintf(outFile, ";"); |
1543 | 713 |
769
ee943e669003
The loc-file parser was completely refactored into a state-machine. This may, or may not make future changes easier. It's at least cleaner and more flexible.; Support for multiple location names was added.; Parsing of coder names into separate strings was implemented.
Matti Hamalainen <ccr@tnsp.org>
parents:
758
diff
changeset
|
714 if (tmp->uri) |
1436
36b6e1dd4ab1
Use helper functions moved to libmaputils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1433
diff
changeset
|
715 fputsesc2(tmp->uri, outFile); |
1543 | 716 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
717 fprintf(outFile, ";"); |
1543 | 718 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
719 if (tmp->freeform) |
1436
36b6e1dd4ab1
Use helper functions moved to libmaputils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1433
diff
changeset
|
720 fputsesc2(tmp->freeform, outFile); |
1543 | 721 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
722 fprintf(outFile, "\n"); |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
723 } |
51
6c51042147c1
Lots of code cleanups, moved stuff from main() to other functions
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
724 } |
6c51042147c1
Lots of code cleanups, moved stuff from main() to other functions
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
725 |
78 | 726 |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
727 /* Generate a shell-script for running ImageMagick to add |
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
728 * location and label information to an map image. |
130 | 729 */ |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
730 void outputMagickScript(FILE *outFile, MapLocations *l) |
104 | 731 { |
1775 | 732 int numCity, numLoc, numTotal; |
104 | 733 |
1770 | 734 // Output script start |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
735 fprintf(outFile, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
736 "#!/bin/sh\n" |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
737 "convert \"$1\" @OPTS_START@ \\\n"); |
1543 | 738 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
739 numCity = numLoc = numTotal = 0; |
1543 | 740 |
1770 | 741 // Output instructions for each visible location |
1775 | 742 for (int i = 0; i < l->n; i++) |
1315 | 743 { |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
744 LocMarker *tmp = l->locations[i]; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
745 int x, y, leftMove; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
746 char *cs; |
1543 | 747 |
1770 | 748 // Is location visible? |
1315 | 749 if (tmp->flags & LOCF_INVIS) |
750 continue; | |
751 | |
963
fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
961
diff
changeset
|
752 leftMove = ((float) strlen(tmp->names[0].name)) * optFontScale; |
1543 | 753 |
1526
aba0900dc31a
Refactor liblocfile API a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1509
diff
changeset
|
754 switch (tmp->align) |
1315 | 755 { |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
756 case LOCD_LEFTDOWN: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
757 y = tmp->y + optUnitSize*3.0f; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
758 x = tmp->x - leftMove; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
759 break; |
1543 | 760 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
761 case LOCD_LEFT: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
762 y = tmp->y - optUnitSize; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
763 x = tmp->x - leftMove; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
764 break; |
104 | 765 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
766 case LOCD_DOWN: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
767 y = tmp->y + optUnitSize*3.0f; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
768 x = tmp->x + optUnitSize; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
769 break; |
1543 | 770 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
771 case LOCD_NONE: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
772 default: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
773 y = tmp->y - optUnitSize; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
774 x = tmp->x + optUnitSize; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
775 break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
776 } |
1543 | 777 |
1770 | 778 // Determine colour |
1315 | 779 switch (tmp->flags & LOCF_M_MASK) |
780 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
781 case LOCF_M_CITY: |
1423
bdc92d60d9db
Improvements in "closed" location flag handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
1422
diff
changeset
|
782 cs = "'#880000'"; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
783 numLoc++; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
784 break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
785 case LOCF_M_PCITY: |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
786 cs = "'#00ff00'"; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
787 numCity++; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
788 break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
789 default: |
1315 | 790 switch (tmp->flags & LOCF_T_MASK) |
791 { | |
1423
bdc92d60d9db
Improvements in "closed" location flag handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
1422
diff
changeset
|
792 case LOCF_T_SHRINE: cs = "yellow"; break; |
bdc92d60d9db
Improvements in "closed" location flag handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
1422
diff
changeset
|
793 case LOCF_T_GUILD: cs = "magenta"; break; |
bdc92d60d9db
Improvements in "closed" location flag handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
1422
diff
changeset
|
794 case LOCF_T_MONSTER: cs = "cyan"; break; |
bdc92d60d9db
Improvements in "closed" location flag handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
1422
diff
changeset
|
795 case LOCF_T_TRAINER: cs = "magenta"; break; |
bdc92d60d9db
Improvements in "closed" location flag handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
1422
diff
changeset
|
796 case LOCF_T_FORT: cs = "'#00ffff'"; break; |
bdc92d60d9db
Improvements in "closed" location flag handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
1422
diff
changeset
|
797 default: cs = "white"; break; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
798 } |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
799 numLoc++; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
800 break; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
801 } |
1543 | 802 |
1423
bdc92d60d9db
Improvements in "closed" location flag handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
1422
diff
changeset
|
803 if (tmp->flags & LOCF_CLOSED) |
bdc92d60d9db
Improvements in "closed" location flag handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
1422
diff
changeset
|
804 cs = "'#ff0000'"; |
1543 | 805 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
806 numTotal++; |
1543 | 807 |
1770 | 808 // Location marker |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
809 fprintf(outFile, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
810 "\t-fill black -draw \"circle %d,%d %d,%d\" ", |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
811 tmp->x, tmp->y, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
812 (int) (tmp->x + optUnitSize), (int) (tmp->y + optUnitSize)); |
1543 | 813 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
814 fprintf(outFile, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
815 "-fill %s -draw \"circle %d,%d %d,%d\" ", |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
816 cs, tmp->x, tmp->y, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
817 (int) (tmp->x + optUnitSize * 0.90f), |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
818 (int) (tmp->y + optUnitSize * 0.90f)); |
1543 | 819 |
104 | 820 |
1770 | 821 // Location description text |
1315 | 822 if (!optNoLabels) |
823 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
824 fprintf(outFile, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
825 "-fill %s -box '#00000080' -draw \"text %d,%d '", |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
826 cs, x, y); |
1433
df03e317851e
Transform fprinte() to fputse().
Matti Hamalainen <ccr@tnsp.org>
parents:
1432
diff
changeset
|
827 |
1442
3cc75a125837
Add a new helper function and use it where appropriate.
Matti Hamalainen <ccr@tnsp.org>
parents:
1441
diff
changeset
|
828 fputsesc3(tmp->names[0].name, outFile); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
829 fprintf(outFile, "'\" "); |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
830 } |
104 | 831 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
832 fprintf(outFile, " \\\n"); |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
833 } |
104 | 834 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
835 fprintf(outFile, |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
836 "@OPTS_END@" |
930
ff806678ef3f
Number of locations etc. are pretty useless information in maps, so remove them.
Matti Hamalainen <ccr@tnsp.org>
parents:
868
diff
changeset
|
837 "'\" \\\n"); |
110 | 838 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
839 fprintf(outFile, "\t\"$2\"\n"); |
104 | 840 } |
841 | |
842 | |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
843 /* Output locations in GMaps XML format. Character set conversion |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
844 * is not performed, caller must take care of it via iconv or similar. |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
845 */ |
1754
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
846 static char *getQuestLink(const char *name, const char *desc) |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
847 { |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
848 char *str, *tmp = th_strdup(name); |
1775 | 849 |
850 for (size_t i = 0; i < strlen(tmp); i++) | |
1754
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
851 tmp[i] = th_isspace(tmp[i]) ? '+' : th_tolower(tmp[i]); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
852 |
1755
c97f28d7c4eb
Open those quest links in another tab as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
1754
diff
changeset
|
853 str = th_strdup_printf("<a target=\"_blank\" href=\"http://www.bat.org/help/quests?str=%s\">%s</a>", tmp, desc); |
1754
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
854 th_free(tmp); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
855 return str; |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
856 } |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
857 |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
858 |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
859 static char *addQuestLink(char **buf, size_t *bufSize, size_t *bufLen, char *ptr, char *start, char *end) |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
860 { |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
861 if (start != NULL && end != NULL) |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
862 { |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
863 char *name = th_strndup(start + 1, end - start - 1); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
864 char *desc = th_strndup(ptr, end - ptr + 1); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
865 char *tmp = getQuestLink(name, desc); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
866 th_strbuf_puts(buf, bufSize, bufLen, tmp); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
867 th_free(name); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
868 th_free(desc); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
869 th_free(tmp); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
870 return end + 1; |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
871 } |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
872 else |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
873 return ptr; |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
874 } |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
875 |
1448 | 876 void outputGMapsHTML(FILE *outFile, LocMarker *tmp, |
1436
36b6e1dd4ab1
Use helper functions moved to libmaputils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1433
diff
changeset
|
877 int (*fpr)(FILE *, const char *fmt, ...), int (*fps)(const char *, FILE *)) |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
878 { |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
879 if (tmp->uri != NULL) |
1448 | 880 { |
881 fpr(outFile, "<b><a target=\"_blank\" href=\"%s\">", tmp->uri); | |
882 locPrintType(outFile, tmp, FALSE, fps, TRUE); | |
883 fpr(outFile, "</a></b><br>"); | |
884 } | |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
885 else |
1448 | 886 { |
887 fpr(outFile, "<b>"); | |
888 locPrintType(outFile, tmp, FALSE, fps, TRUE); | |
889 fpr(outFile, "</b><br>"); | |
890 } | |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
891 |
1770 | 892 // Alternative names, if any |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
893 if (tmp->nnames > 1) |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
894 { |
1441
f6ae2862cf73
Use the function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1437
diff
changeset
|
895 fpr(outFile, "Also known as <i>"); |
1775 | 896 for (int n = 1; n < tmp->nnames; n++) |
1315 | 897 { |
1441
f6ae2862cf73
Use the function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1437
diff
changeset
|
898 fps(tmp->names[n].name, outFile); |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
899 if (tmp->names[n].flags & NAME_ORIG) |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
900 fprintf(outFile, " (*)"); |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
901 if (n < tmp->nnames - 1) |
1433
df03e317851e
Transform fprinte() to fputse().
Matti Hamalainen <ccr@tnsp.org>
parents:
1432
diff
changeset
|
902 fprintf(outFile, " ; "); |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
903 } |
1441
f6ae2862cf73
Use the function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1437
diff
changeset
|
904 fpr(outFile, "</i>.<br>"); |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
905 } |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
906 |
1770 | 907 // Added to game timestamp |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
908 if (tmp->valid) |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
909 { |
1441
f6ae2862cf73
Use the function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1437
diff
changeset
|
910 fpr(outFile, "Added " LOC_TIMEFMT ".<br>", |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
911 tmp->added.day, tmp->added.month, tmp->added.year); |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
912 } |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
913 |
1770 | 914 // Coder names or societies |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
915 if (tmp->ncoders > 0) |
1315 | 916 { |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
917 if (tmp->flags & LOCF_M_PCITY) |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
918 { |
1433
df03e317851e
Transform fprinte() to fputse().
Matti Hamalainen <ccr@tnsp.org>
parents:
1432
diff
changeset
|
919 fprintf(outFile, "Societies: "); |
1775 | 920 for (int n = 0; n < tmp->ncoders; n++) |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
921 { |
1441
f6ae2862cf73
Use the function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1437
diff
changeset
|
922 fps(tmp->coders[n].name, outFile); |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
923 if (n < tmp->ncoders - 1) |
1441
f6ae2862cf73
Use the function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1437
diff
changeset
|
924 fprintf(outFile, ", "); |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
925 } |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
926 } |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
927 else |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
928 { |
1433
df03e317851e
Transform fprinte() to fputse().
Matti Hamalainen <ccr@tnsp.org>
parents:
1432
diff
changeset
|
929 fprintf(outFile, "Coders: "); |
1775 | 930 for (int n = 0; n < tmp->ncoders; n++) |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
931 { |
1754
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
932 char *info = "", *sinfo = ""; |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
933 switch (tmp->coders[n].flags) |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
934 { |
1754
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
935 case NAME_ORIG: info = " (O)"; sinfo = "Original coder"; break; |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
936 case NAME_RECODER: info = " (R)"; sinfo = "Re-coder"; break; |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
937 case NAME_MAINTAINER: info = " (M)"; sinfo = "Maintainer"; break; |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
938 case NAME_EXPANDER: info = " (E)"; sinfo = "Expander"; break; |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
939 } |
1753
4d160a5c6425
Change coder links to point to tnsp.org wizard info instead of bat.org in GMaps XML/JSON output.
Matti Hamalainen <ccr@tnsp.org>
parents:
1745
diff
changeset
|
940 //fpr(outFile, "<a target=\"_blank\" href=\"http://www.bat.org/char/%s\">%s%s</a>", |
1754
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
941 fpr(outFile, "<a target=\"_blank\" href=\"https://tnsp.org/maps/loc.php?a=%s\" title=\"%s\">%s%s</a>", |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
942 tmp->coders[n].name, sinfo, |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
943 tmp->coders[n].name, info); |
1753
4d160a5c6425
Change coder links to point to tnsp.org wizard info instead of bat.org in GMaps XML/JSON output.
Matti Hamalainen <ccr@tnsp.org>
parents:
1745
diff
changeset
|
944 |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
945 if (n < tmp->ncoders - 1) |
1433
df03e317851e
Transform fprinte() to fputse().
Matti Hamalainen <ccr@tnsp.org>
parents:
1432
diff
changeset
|
946 fprintf(outFile, ", "); |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
947 } |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
948 } |
1441
f6ae2862cf73
Use the function parameters.
Matti Hamalainen <ccr@tnsp.org>
parents:
1437
diff
changeset
|
949 fps(".<br>", outFile); |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
950 } |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
951 |
1770 | 952 // Print out freeform information field |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
953 if (tmp->freeform) |
1754
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
954 { |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
955 char *ptr = tmp->freeform; |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
956 char *buf = NULL; |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
957 size_t bufLen = 0, bufSize = 0; |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
958 |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
959 while (*ptr != 0) |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
960 { |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
961 if (ptr[0] == 'A' && ptr[1] == 'Q' && th_isspace(ptr[2])) |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
962 { |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
963 char *start = strchr(ptr + 3, '"'); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
964 ptr = addQuestLink(&buf, &bufSize, &bufLen, ptr, start, strchr(start + 1, '"')); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
965 } |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
966 else |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
967 if (ptr[0] == 'L' && ptr[1] == 'Q' && th_isdigit(ptr[2])) |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
968 { |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
969 char *start = strchr(ptr + 3, '"'); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
970 ptr = addQuestLink(&buf, &bufSize, &bufLen, ptr, start, start ? strchr(start + 1, '"') : NULL); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
971 } |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
972 |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
973 if (*ptr != 0) |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
974 th_strbuf_putch(&buf, &bufSize, &bufLen, *ptr++); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
975 } |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
976 |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
977 th_strbuf_putch(&buf, &bufSize, &bufLen, 0); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
978 |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
979 fpr(outFile, "<br>%s<br>", buf); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
980 th_free(buf); |
3280d419f1c8
Improve GMaps XML/JSON output by adding links to quests etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
1753
diff
changeset
|
981 } |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
982 } |
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
983 |
1315 | 984 |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
985 void outputGMapsXML(FILE *outFile, MapLocations *l) |
227
16e9df5bdc80
Try to combine pcity marks into clusters.
Matti Hamalainen <ccr@tnsp.org>
parents:
218
diff
changeset
|
986 { |
840
9506734628e6
Oops, some output was accidentally going to stderr instead outFile. Fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
987 fprintf(outFile, |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
988 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
989 "<markers>\n"); |
1543 | 990 |
1770 | 991 // Output each location entry |
1775 | 992 for (int i = 0; i < l->n; i++) |
1315 | 993 { |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
994 LocMarker *tmp = l->locations[i]; |
227
16e9df5bdc80
Try to combine pcity marks into clusters.
Matti Hamalainen <ccr@tnsp.org>
parents:
218
diff
changeset
|
995 |
1770 | 996 // Skip disabled / invisible locations |
960
f2fcbf6ad2ef
Do initial changes for supporting area original names and flags for coder names (original, recoder, maintainer); these changes are in preparation for LOC file format 4.0.
Matti Hamalainen <ccr@tnsp.org>
parents:
943
diff
changeset
|
997 if (tmp->flags & (LOCF_INVIS | LOCF_INVALID)) continue; |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
998 |
1770 | 999 // Print out coordinates etc. |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
1000 fprintf(outFile, "<marker x=\"%d\" y=\"%d\" labeldir=\"%d\" name=\"", |
1526
aba0900dc31a
Refactor liblocfile API a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1509
diff
changeset
|
1001 tmp->ox, tmp->oy, tmp->align); |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1002 |
1770 | 1003 // Location name |
1448 | 1004 locPrintType(outFile, tmp, FALSE, fputse, FALSE); |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1005 |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1006 fprintf(outFile, "\" html=\""); |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1007 |
1448 | 1008 outputGMapsHTML(outFile, tmp, fprintfe, fputse); |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1009 |
1770 | 1010 // Flags |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1011 fprintf(outFile, "\" flags=\"%d\"", |
835
a5b6482b767a
Added support for outputting GMaps XML chunks.
Matti Hamalainen <ccr@tnsp.org>
parents:
811
diff
changeset
|
1012 tmp->flags); |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1013 |
1770 | 1014 // Continent name |
1315 | 1015 if (tmp->file != NULL && tmp->file->continent != NULL) |
1016 { | |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1017 fprintf(outFile, " continent=\""); |
1433
df03e317851e
Transform fprinte() to fputse().
Matti Hamalainen <ccr@tnsp.org>
parents:
1432
diff
changeset
|
1018 fputse(tmp->file->continent, outFile); |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1019 fprintf(outFile, "\""); |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1020 } |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1021 |
1770 | 1022 // Type of the marker |
1445 | 1023 fprintf(outFile, " type=\"%s\"/>\n", locGetLocationType(tmp->flags)); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1024 } |
1543 | 1025 |
840
9506734628e6
Oops, some output was accidentally going to stderr instead outFile. Fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
838
diff
changeset
|
1026 fprintf(outFile, "</markers>\n"); |
227
16e9df5bdc80
Try to combine pcity marks into clusters.
Matti Hamalainen <ccr@tnsp.org>
parents:
218
diff
changeset
|
1027 } |
16e9df5bdc80
Try to combine pcity marks into clusters.
Matti Hamalainen <ccr@tnsp.org>
parents:
218
diff
changeset
|
1028 |
16e9df5bdc80
Try to combine pcity marks into clusters.
Matti Hamalainen <ccr@tnsp.org>
parents:
218
diff
changeset
|
1029 |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1030 void outputGMapsJSON(FILE *outFile, MapLocations *l) |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1031 { |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1032 fprintf(outFile, "[\n"); |
1543 | 1033 |
1770 | 1034 // Output each location entry |
1775 | 1035 for (int i = 0; i < l->n; i++) |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1036 { |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1037 LocMarker *tmp = l->locations[i]; |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1038 |
1770 | 1039 // Skip disabled / invisible locations |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1040 if (tmp->flags & (LOCF_INVIS | LOCF_INVALID)) continue; |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1041 |
1770 | 1042 // Print out coordinates etc. |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1043 fprintf(outFile, "{\"x\":%d,\"y\":%d,\"labeldir\":%d,\"name\":\"", |
1526
aba0900dc31a
Refactor liblocfile API a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1509
diff
changeset
|
1044 tmp->ox, tmp->oy, tmp->align); |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1045 |
1770 | 1046 // Location name |
1448 | 1047 locPrintType(outFile, tmp, FALSE, fputsesc1, FALSE); |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1048 fprintf(outFile, "\",\"html\":\""); |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1049 |
1448 | 1050 outputGMapsHTML(outFile, tmp, fprintfesc1, fputsesc1); |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1051 |
1770 | 1052 // Flags |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1053 fprintf(outFile, "\",\"flags\":%d", |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1054 tmp->flags); |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1055 |
1770 | 1056 // Continent name |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1057 if (tmp->file != NULL && tmp->file->continent != NULL) |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1058 { |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1059 fprintf(outFile, ",\"continent\":\""); |
1436
36b6e1dd4ab1
Use helper functions moved to libmaputils.
Matti Hamalainen <ccr@tnsp.org>
parents:
1433
diff
changeset
|
1060 fputsesc1(tmp->file->continent, outFile); |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1061 fprintf(outFile, "\""); |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1062 } |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1063 |
1770 | 1064 // Type of the marker |
1448 | 1065 fprintf(outFile, "}"); |
1543 | 1066 |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1067 if (i < l->n - 1) |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1068 fprintf(outFile, ","); |
1543 | 1069 |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1070 fprintf(outFile, "\n"); |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1071 } |
1543 | 1072 |
1432
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1073 fprintf(outFile, "]\n"); |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1074 } |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1075 |
1aed25b2a6a6
Remove support from text overlay file output, add in JSON support instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
1423
diff
changeset
|
1076 |
37 | 1077 int main(int argc, char *argv[]) |
1078 { | |
1771 | 1079 FILE *outFile = NULL; |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
1080 MapBlock *worldMap = NULL; |
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
1081 MapLocations worldLoc; |
1543 | 1082 |
1473
ca272867a81b
Update to new th-libs (th_memset() removed)
Matti Hamalainen <ccr@tnsp.org>
parents:
1448
diff
changeset
|
1083 memset(&worldLoc, 0, sizeof(worldLoc)); |
37 | 1084 |
1770 | 1085 // Initialize |
1437 | 1086 th_init("mkloc", "Manipulate and convert location files and ASCII map data", "1.6", NULL, NULL); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1087 th_verbosityLevel = 0; |
1543 | 1088 |
1770 | 1089 // Parse arguments |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
1090 if (!th_args_process(argc, argv, optList, optListN, |
1484
2350cd3a6feb
Update to match the changes in th_args API.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
1091 argHandleOpt, NULL, OPTH_BAILOUT)) |
1771 | 1092 goto exit; |
1543 | 1093 |
1770 | 1094 // Check the mode and arguments |
1315 | 1095 if (srcFile == NULL && optGetUpdateLoc && optOutput == OUTFMT_LOCFILE) |
1096 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1097 THERR("Map file required for location update mode!\n"); |
1771 | 1098 goto exit; |
1543 | 1099 } |
1100 | |
1315 | 1101 if (optOutput == OUTFMT_LOCFILE && nlocFiles < 0 && !optGetUpdateLoc) |
1102 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1103 THERR("Location file or location update mode required for location file output!\n"); |
1771 | 1104 goto exit; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1105 } |
1543 | 1106 |
1315 | 1107 if ((optOutput == OUTFMT_SCRIPT || optOutput == OUTFMT_MAPLOC) && nlocFiles < 0) |
1108 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1109 THERR("Location file required for script or MapLoc HTML output!\n"); |
1771 | 1110 goto exit; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1111 } |
1543 | 1112 |
1315 | 1113 if (srcFile == NULL && optOutput == OUTFMT_MAP) |
1114 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1115 THERR("Mapfile required for map generation.\n"); |
1771 | 1116 goto exit; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1117 } |
1543 | 1118 |
1770 | 1119 // Read initial map |
1315 | 1120 if (srcFile) |
1121 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1122 THMSG(2, "Reading map '%s'\n", srcFile); |
1310
a6be5a68032f
Rename map block handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
1309
diff
changeset
|
1123 worldMap = mapBlockParseFile(srcFile, FALSE); |
1771 | 1124 if (worldMap == NULL) |
1315 | 1125 { |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1126 THERR("World map could not be loaded!\n"); |
1771 | 1127 goto exit; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1128 } |
1543 | 1129 |
1314
5d6ddd4d6781
Import more changes from Map Mask Designer, and do a cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
1313
diff
changeset
|
1130 THMSG(2, "Initial dimensions (%d x %d)\n", worldMap->width, worldMap->height); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1131 } |
38 | 1132 |
1770 | 1133 // Read location info |
1771 | 1134 for (int i = 0; i <= nlocFiles; i++) |
1315 | 1135 { |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
1136 LocFileInfo *f = &locFiles[i]; |
1526
aba0900dc31a
Refactor liblocfile API a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1509
diff
changeset
|
1137 FILE *inFile; |
794 | 1138 |
1315 | 1139 if (optOutput == OUTFMT_GMAPS && f->continent == NULL) |
1140 { | |
1771 | 1141 THERR("Required continent name not set for #%d '%s'.\n", |
1142 i, f->filename); | |
1143 goto exit; | |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1144 } |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1145 |
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1146 THMSG(2, "Reading location info '%s'\n", f->filename); |
1526
aba0900dc31a
Refactor liblocfile API a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1509
diff
changeset
|
1147 if ((inFile = fopen(f->filename, "rb")) == NULL) |
1315 | 1148 { |
794 | 1149 THERR("Could not open location file '%s' for reading.\n", |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1150 f->filename); |
1771 | 1151 goto exit; |
794 | 1152 } |
837
fe8978f826df
Added support for inputting multiple location files (this includes file-specific -x, -y and -c options).
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
1153 |
1526
aba0900dc31a
Refactor liblocfile API a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1509
diff
changeset
|
1154 if (!locParseLocStream(inFile, f, &worldLoc, f->x, f->y)) |
1771 | 1155 goto exit; |
1543 | 1156 |
1526
aba0900dc31a
Refactor liblocfile API a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1509
diff
changeset
|
1157 fclose(inFile); |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1158 } |
1543 | 1159 |
1770 | 1160 // Update locations |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1161 if (optGetUpdateLoc) |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1162 updateLocations(worldMap, &worldLoc); |
1543 | 1163 |
1770 | 1164 // Scale locations |
1315 | 1165 if (optScale > 0) |
1166 { | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1167 THMSG(1, "Scaling locations ..\n"); |
1543 | 1168 |
1771 | 1169 for (int i = 0; i < worldLoc.n; i++) |
1315 | 1170 { |
1309
5cd310e1dab9
Rename some structures/data types.
Matti Hamalainen <ccr@tnsp.org>
parents:
1308
diff
changeset
|
1171 LocMarker *tmp = worldLoc.locations[i]; |
1543 | 1172 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1173 tmp->x = ((float) tmp->x) * optScale; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1174 tmp->y = ((float) tmp->y) * optScale; |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1175 } |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1176 } |
1543 | 1177 |
1770 | 1178 // Open output file |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1179 if (destFile == NULL) |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1180 outFile = stdout; |
1692 | 1181 else |
1182 if ((outFile = fopen(destFile, "wb")) == NULL) | |
1315 | 1183 { |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1184 THERR("Error opening output file '%s'!\n", |
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1185 destFile); |
1771 | 1186 goto exit; |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1187 } |
38 | 1188 |
1770 | 1189 // Output results |
1771 | 1190 switch (optOutput) |
1191 { | |
1192 case OUTFMT_SCRIPT: | |
1193 THMSG(1, "Generating ImageMagick script ...\n"); | |
1194 outputMagickScript(outFile, &worldLoc); | |
1195 break; | |
269
0a2be000bf66
Arguments were not checked properly, this caused a segfault if certain parameters were not provided in a certain mode of operation. Fixed!
Matti Hamalainen <ccr@tnsp.org>
parents:
254
diff
changeset
|
1196 |
1771 | 1197 case OUTFMT_LOCFILE: |
1198 THMSG(1, "Outputting generated location list ...\n"); | |
1199 outputLocationFile(outFile, &worldLoc); | |
1200 THMSG(2, "%d locations\n", worldLoc.n); | |
1201 break; | |
1543 | 1202 |
1771 | 1203 case OUTFMT_MAPLOC: |
1204 maplocSort(&worldLoc); | |
1205 THMSG(1, "Outputting MapLoc HTML ...\n"); | |
1206 outputMapLocHTML(outFile, &worldLoc); | |
1207 THMSG(2, "%d locations\n", worldLoc.n); | |
1208 break; | |
1543 | 1209 |
1771 | 1210 case OUTFMT_GMAPS: |
1211 maplocSort(&worldLoc); | |
1212 THMSG(1, "Outputting GMaps data (%s) ...\n", gmapsModes[optGMapsMode]); | |
1213 switch (optGMapsMode) | |
1214 { | |
1215 case GMAPS_XML: outputGMapsXML(outFile, &worldLoc); break; | |
1216 case GMAPS_JSON: outputGMapsJSON(outFile, &worldLoc); break; | |
1217 } | |
1218 THMSG(2, "%d locations\n", worldLoc.n); | |
1219 break; | |
838
7c1894932117
Fixes and support for outputting Jeskko's GMaps overlay + overlay labels text formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
1220 |
1771 | 1221 case OUTFMT_MAP: |
1222 THMSG(1, "Outputting generated map of (%d x %d) ...\n", | |
1223 worldMap->width, worldMap->height); | |
37 | 1224 |
1771 | 1225 THMSG(2, "Adjusting location labels ..\n"); |
1226 adjustLocInfoCoords(worldMap, &worldLoc); | |
1543 | 1227 |
1771 | 1228 outputMapCTRL(outFile, worldMap, &worldLoc); |
1229 break; | |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1230 } |
1543 | 1231 |
1771 | 1232 exit: |
1233 if (outFile != NULL) | |
1234 fclose(outFile); | |
1235 | |
1310
a6be5a68032f
Rename map block handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
1309
diff
changeset
|
1236 mapBlockFree(worldMap); |
1509
7eeae6b4bce0
Use newly added functions to plug some memory leaks (not that they matter
Matti Hamalainen <ccr@tnsp.org>
parents:
1503
diff
changeset
|
1237 locFreeMapLocations(&worldLoc); |
1543 | 1238 |
712
2e75c11fed93
Indentation tabs to spaces.
Matti Hamalainen <ccr@tnsp.org>
parents:
677
diff
changeset
|
1239 return 0; |
37 | 1240 } |