| @@ -0,0 +1,693 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #include "main.h" | |
| 19 | + | ||
| 20 | + | #include "templates.h" | |
| 21 | + | ||
| 22 | + | ConversionMap getReplacementMapClassic() { | |
| 23 | + | ConversionMap replacement_map; | |
| 24 | + | std::vector<uint16_t> veckey, vecval; | |
| 25 | + | ||
| 26 | + | vecval.clear(); | |
| 27 | + | vecval.push_back(102); | |
| 28 | + | replacement_map.stm[102] = vecval; | |
| 29 | + | ||
| 30 | + | vecval.clear(); | |
| 31 | + | vecval.push_back(105); | |
| 32 | + | replacement_map.stm[105] = vecval; | |
| 33 | + | ||
| 34 | + | vecval.clear(); | |
| 35 | + | vecval.push_back(107); | |
| 36 | + | replacement_map.stm[107] = vecval; | |
| 37 | + | ||
| 38 | + | vecval.clear(); | |
| 39 | + | vecval.push_back(146); | |
| 40 | + | veckey.clear(); | |
| 41 | + | veckey.push_back(105); | |
| 42 | + | veckey.push_back(4667); | |
| 43 | + | std::sort(veckey.begin(), veckey.end()); | |
| 44 | + | replacement_map.mtm[veckey] = vecval; | |
| 45 | + | ||
| 46 | + | vecval.clear(); | |
| 47 | + | vecval.push_back(147); | |
| 48 | + | veckey.clear(); | |
| 49 | + | veckey.push_back(105); | |
| 50 | + | veckey.push_back(4669); | |
| 51 | + | std::sort(veckey.begin(), veckey.end()); | |
| 52 | + | replacement_map.mtm[veckey] = vecval; | |
| 53 | + | ||
| 54 | + | vecval.clear(); | |
| 55 | + | vecval.push_back(148); | |
| 56 | + | veckey.clear(); | |
| 57 | + | veckey.push_back(105); | |
| 58 | + | veckey.push_back(4670); | |
| 59 | + | std::sort(veckey.begin(), veckey.end()); | |
| 60 | + | replacement_map.mtm[veckey] = vecval; | |
| 61 | + | ||
| 62 | + | vecval.clear(); | |
| 63 | + | vecval.push_back(149); | |
| 64 | + | veckey.clear(); | |
| 65 | + | veckey.push_back(105); | |
| 66 | + | veckey.push_back(4668); | |
| 67 | + | std::sort(veckey.begin(), veckey.end()); | |
| 68 | + | replacement_map.mtm[veckey] = vecval; | |
| 69 | + | ||
| 70 | + | vecval.clear(); | |
| 71 | + | vecval.push_back(150); | |
| 72 | + | veckey.clear(); | |
| 73 | + | veckey.push_back(105); | |
| 74 | + | veckey.push_back(4675); | |
| 75 | + | std::sort(veckey.begin(), veckey.end()); | |
| 76 | + | replacement_map.mtm[veckey] = vecval; | |
| 77 | + | ||
| 78 | + | vecval.clear(); | |
| 79 | + | vecval.push_back(151); | |
| 80 | + | veckey.clear(); | |
| 81 | + | veckey.push_back(105); | |
| 82 | + | veckey.push_back(4676); | |
| 83 | + | std::sort(veckey.begin(), veckey.end()); | |
| 84 | + | replacement_map.mtm[veckey] = vecval; | |
| 85 | + | ||
| 86 | + | vecval.clear(); | |
| 87 | + | vecval.push_back(152); | |
| 88 | + | veckey.clear(); | |
| 89 | + | veckey.push_back(105); | |
| 90 | + | veckey.push_back(4678); | |
| 91 | + | std::sort(veckey.begin(), veckey.end()); | |
| 92 | + | replacement_map.mtm[veckey] = vecval; | |
| 93 | + | ||
| 94 | + | vecval.clear(); | |
| 95 | + | vecval.push_back(153); | |
| 96 | + | veckey.clear(); | |
| 97 | + | veckey.push_back(4566); | |
| 98 | + | veckey.push_back(4677); | |
| 99 | + | std::sort(veckey.begin(), veckey.end()); | |
| 100 | + | replacement_map.mtm[veckey] = vecval; | |
| 101 | + | ||
| 102 | + | vecval.clear(); | |
| 103 | + | vecval.push_back(154); | |
| 104 | + | veckey.clear(); | |
| 105 | + | veckey.push_back(105); | |
| 106 | + | veckey.push_back(4671); | |
| 107 | + | std::sort(veckey.begin(), veckey.end()); | |
| 108 | + | replacement_map.mtm[veckey] = vecval; | |
| 109 | + | ||
| 110 | + | vecval.clear(); | |
| 111 | + | vecval.push_back(155); | |
| 112 | + | veckey.clear(); | |
| 113 | + | veckey.push_back(105); | |
| 114 | + | veckey.push_back(4672); | |
| 115 | + | std::sort(veckey.begin(), veckey.end()); | |
| 116 | + | replacement_map.mtm[veckey] = vecval; | |
| 117 | + | ||
| 118 | + | vecval.clear(); | |
| 119 | + | vecval.push_back(156); | |
| 120 | + | veckey.clear(); | |
| 121 | + | veckey.push_back(105); | |
| 122 | + | veckey.push_back(4674); | |
| 123 | + | std::sort(veckey.begin(), veckey.end()); | |
| 124 | + | replacement_map.mtm[veckey] = vecval; | |
| 125 | + | ||
| 126 | + | vecval.clear(); | |
| 127 | + | vecval.push_back(157); | |
| 128 | + | veckey.clear(); | |
| 129 | + | veckey.push_back(105); | |
| 130 | + | veckey.push_back(4673); | |
| 131 | + | std::sort(veckey.begin(), veckey.end()); | |
| 132 | + | replacement_map.mtm[veckey] = vecval; | |
| 133 | + | ||
| 134 | + | vecval.clear(); | |
| 135 | + | vecval.push_back(158); | |
| 136 | + | veckey.clear(); | |
| 137 | + | veckey.push_back(105); | |
| 138 | + | veckey.push_back(4596); | |
| 139 | + | std::sort(veckey.begin(), veckey.end()); | |
| 140 | + | replacement_map.mtm[veckey] = vecval; | |
| 141 | + | ||
| 142 | + | vecval.clear(); | |
| 143 | + | vecval.push_back(159); | |
| 144 | + | veckey.clear(); | |
| 145 | + | veckey.push_back(105); | |
| 146 | + | veckey.push_back(4598); | |
| 147 | + | std::sort(veckey.begin(), veckey.end()); | |
| 148 | + | replacement_map.mtm[veckey] = vecval; | |
| 149 | + | ||
| 150 | + | vecval.clear(); | |
| 151 | + | vecval.push_back(160); | |
| 152 | + | veckey.clear(); | |
| 153 | + | veckey.push_back(105); | |
| 154 | + | veckey.push_back(4599); | |
| 155 | + | std::sort(veckey.begin(), veckey.end()); | |
| 156 | + | replacement_map.mtm[veckey] = vecval; | |
| 157 | + | ||
| 158 | + | vecval.clear(); | |
| 159 | + | vecval.push_back(161); | |
| 160 | + | veckey.clear(); | |
| 161 | + | veckey.push_back(105); | |
| 162 | + | veckey.push_back(4597); | |
| 163 | + | std::sort(veckey.begin(), veckey.end()); | |
| 164 | + | replacement_map.mtm[veckey] = vecval; | |
| 165 | + | ||
| 166 | + | vecval.clear(); | |
| 167 | + | vecval.push_back(162); | |
| 168 | + | veckey.clear(); | |
| 169 | + | veckey.push_back(105); | |
| 170 | + | veckey.push_back(4604); | |
| 171 | + | std::sort(veckey.begin(), veckey.end()); | |
| 172 | + | replacement_map.mtm[veckey] = vecval; | |
| 173 | + | ||
| 174 | + | vecval.clear(); | |
| 175 | + | vecval.push_back(163); | |
| 176 | + | veckey.clear(); | |
| 177 | + | veckey.push_back(105); | |
| 178 | + | veckey.push_back(4605); | |
| 179 | + | std::sort(veckey.begin(), veckey.end()); | |
| 180 | + | replacement_map.mtm[veckey] = vecval; | |
| 181 | + | ||
| 182 | + | vecval.clear(); | |
| 183 | + | vecval.push_back(164); | |
| 184 | + | veckey.clear(); | |
| 185 | + | veckey.push_back(105); | |
| 186 | + | veckey.push_back(4607); | |
| 187 | + | std::sort(veckey.begin(), veckey.end()); | |
| 188 | + | replacement_map.mtm[veckey] = vecval; | |
| 189 | + | ||
| 190 | + | vecval.clear(); | |
| 191 | + | vecval.push_back(165); | |
| 192 | + | veckey.clear(); | |
| 193 | + | veckey.push_back(105); | |
| 194 | + | veckey.push_back(4606); | |
| 195 | + | std::sort(veckey.begin(), veckey.end()); | |
| 196 | + | replacement_map.mtm[veckey] = vecval; | |
| 197 | + | ||
| 198 | + | vecval.clear(); | |
| 199 | + | vecval.push_back(166); | |
| 200 | + | veckey.clear(); | |
| 201 | + | veckey.push_back(105); | |
| 202 | + | veckey.push_back(4600); | |
| 203 | + | std::sort(veckey.begin(), veckey.end()); | |
| 204 | + | replacement_map.mtm[veckey] = vecval; | |
| 205 | + | ||
| 206 | + | vecval.clear(); | |
| 207 | + | vecval.push_back(167); | |
| 208 | + | veckey.clear(); | |
| 209 | + | veckey.push_back(105); | |
| 210 | + | veckey.push_back(4601); | |
| 211 | + | std::sort(veckey.begin(), veckey.end()); | |
| 212 | + | replacement_map.mtm[veckey] = vecval; | |
| 213 | + | ||
| 214 | + | vecval.clear(); | |
| 215 | + | vecval.push_back(168); | |
| 216 | + | veckey.clear(); | |
| 217 | + | veckey.push_back(105); | |
| 218 | + | veckey.push_back(4603); | |
| 219 | + | std::sort(veckey.begin(), veckey.end()); | |
| 220 | + | replacement_map.mtm[veckey] = vecval; | |
| 221 | + | ||
| 222 | + | vecval.clear(); | |
| 223 | + | vecval.push_back(169); | |
| 224 | + | veckey.clear(); | |
| 225 | + | veckey.push_back(105); | |
| 226 | + | veckey.push_back(4602); | |
| 227 | + | std::sort(veckey.begin(), veckey.end()); | |
| 228 | + | replacement_map.mtm[veckey] = vecval; | |
| 229 | + | ||
| 230 | + | vecval.clear(); | |
| 231 | + | vecval.push_back(219); | |
| 232 | + | veckey.clear(); | |
| 233 | + | veckey.push_back(106); | |
| 234 | + | veckey.push_back(4542); | |
| 235 | + | std::sort(veckey.begin(), veckey.end()); | |
| 236 | + | replacement_map.mtm[veckey] = vecval; | |
| 237 | + | ||
| 238 | + | vecval.clear(); | |
| 239 | + | vecval.push_back(220); | |
| 240 | + | veckey.clear(); | |
| 241 | + | veckey.push_back(106); | |
| 242 | + | veckey.push_back(4544); | |
| 243 | + | std::sort(veckey.begin(), veckey.end()); | |
| 244 | + | replacement_map.mtm[veckey] = vecval; | |
| 245 | + | ||
| 246 | + | vecval.clear(); | |
| 247 | + | vecval.push_back(221); | |
| 248 | + | veckey.clear(); | |
| 249 | + | veckey.push_back(106); | |
| 250 | + | veckey.push_back(4545); | |
| 251 | + | std::sort(veckey.begin(), veckey.end()); | |
| 252 | + | replacement_map.mtm[veckey] = vecval; | |
| 253 | + | ||
| 254 | + | vecval.clear(); | |
| 255 | + | vecval.push_back(222); | |
| 256 | + | veckey.clear(); | |
| 257 | + | veckey.push_back(106); | |
| 258 | + | veckey.push_back(4543); | |
| 259 | + | std::sort(veckey.begin(), veckey.end()); | |
| 260 | + | replacement_map.mtm[veckey] = vecval; | |
| 261 | + | ||
| 262 | + | vecval.clear(); | |
| 263 | + | vecval.push_back(223); | |
| 264 | + | veckey.clear(); | |
| 265 | + | veckey.push_back(106); | |
| 266 | + | veckey.push_back(4550); | |
| 267 | + | std::sort(veckey.begin(), veckey.end()); | |
| 268 | + | replacement_map.mtm[veckey] = vecval; | |
| 269 | + | ||
| 270 | + | vecval.clear(); | |
| 271 | + | vecval.push_back(224); | |
| 272 | + | veckey.clear(); | |
| 273 | + | veckey.push_back(106); | |
| 274 | + | veckey.push_back(4551); | |
| 275 | + | std::sort(veckey.begin(), veckey.end()); | |
| 276 | + | replacement_map.mtm[veckey] = vecval; | |
| 277 | + | ||
| 278 | + | vecval.clear(); | |
| 279 | + | vecval.push_back(225); | |
| 280 | + | veckey.clear(); | |
| 281 | + | veckey.push_back(106); | |
| 282 | + | veckey.push_back(4553); | |
| 283 | + | std::sort(veckey.begin(), veckey.end()); | |
| 284 | + | replacement_map.mtm[veckey] = vecval; | |
| 285 | + | ||
| 286 | + | vecval.clear(); | |
| 287 | + | vecval.push_back(226); | |
| 288 | + | veckey.clear(); | |
| 289 | + | veckey.push_back(106); | |
| 290 | + | veckey.push_back(4552); | |
| 291 | + | std::sort(veckey.begin(), veckey.end()); | |
| 292 | + | replacement_map.mtm[veckey] = vecval; | |
| 293 | + | ||
| 294 | + | vecval.clear(); | |
| 295 | + | vecval.push_back(227); | |
| 296 | + | veckey.clear(); | |
| 297 | + | veckey.push_back(106); | |
| 298 | + | veckey.push_back(4546); | |
| 299 | + | std::sort(veckey.begin(), veckey.end()); | |
| 300 | + | replacement_map.mtm[veckey] = vecval; | |
| 301 | + | ||
| 302 | + | vecval.clear(); | |
| 303 | + | vecval.push_back(228); | |
| 304 | + | veckey.clear(); | |
| 305 | + | veckey.push_back(106); | |
| 306 | + | veckey.push_back(4547); | |
| 307 | + | std::sort(veckey.begin(), veckey.end()); | |
| 308 | + | replacement_map.mtm[veckey] = vecval; | |
| 309 | + | ||
| 310 | + | vecval.clear(); | |
| 311 | + | vecval.push_back(229); | |
| 312 | + | veckey.clear(); | |
| 313 | + | veckey.push_back(106); | |
| 314 | + | veckey.push_back(4549); | |
| 315 | + | std::sort(veckey.begin(), veckey.end()); | |
| 316 | + | replacement_map.mtm[veckey] = vecval; | |
| 317 | + | ||
| 318 | + | vecval.clear(); | |
| 319 | + | vecval.push_back(230); | |
| 320 | + | veckey.clear(); | |
| 321 | + | veckey.push_back(106); | |
| 322 | + | veckey.push_back(4548); | |
| 323 | + | std::sort(veckey.begin(), veckey.end()); | |
| 324 | + | replacement_map.mtm[veckey] = vecval; | |
| 325 | + | ||
| 326 | + | vecval.clear(); | |
| 327 | + | vecval.push_back(232); | |
| 328 | + | veckey.clear(); | |
| 329 | + | veckey.push_back(231); | |
| 330 | + | veckey.push_back(4542); | |
| 331 | + | std::sort(veckey.begin(), veckey.end()); | |
| 332 | + | replacement_map.mtm[veckey] = vecval; | |
| 333 | + | ||
| 334 | + | vecval.clear(); | |
| 335 | + | vecval.push_back(233); | |
| 336 | + | veckey.clear(); | |
| 337 | + | veckey.push_back(231); | |
| 338 | + | veckey.push_back(4544); | |
| 339 | + | std::sort(veckey.begin(), veckey.end()); | |
| 340 | + | replacement_map.mtm[veckey] = vecval; | |
| 341 | + | ||
| 342 | + | vecval.clear(); | |
| 343 | + | vecval.push_back(234); | |
| 344 | + | veckey.clear(); | |
| 345 | + | veckey.push_back(231); | |
| 346 | + | veckey.push_back(4545); | |
| 347 | + | std::sort(veckey.begin(), veckey.end()); | |
| 348 | + | replacement_map.mtm[veckey] = vecval; | |
| 349 | + | ||
| 350 | + | vecval.clear(); | |
| 351 | + | vecval.push_back(235); | |
| 352 | + | veckey.clear(); | |
| 353 | + | veckey.push_back(231); | |
| 354 | + | veckey.push_back(4543); | |
| 355 | + | std::sort(veckey.begin(), veckey.end()); | |
| 356 | + | replacement_map.mtm[veckey] = vecval; | |
| 357 | + | ||
| 358 | + | vecval.clear(); | |
| 359 | + | vecval.push_back(236); | |
| 360 | + | veckey.clear(); | |
| 361 | + | veckey.push_back(231); | |
| 362 | + | veckey.push_back(4550); | |
| 363 | + | std::sort(veckey.begin(), veckey.end()); | |
| 364 | + | replacement_map.mtm[veckey] = vecval; | |
| 365 | + | ||
| 366 | + | vecval.clear(); | |
| 367 | + | vecval.push_back(237); | |
| 368 | + | veckey.clear(); | |
| 369 | + | veckey.push_back(231); | |
| 370 | + | veckey.push_back(4551); | |
| 371 | + | std::sort(veckey.begin(), veckey.end()); | |
| 372 | + | replacement_map.mtm[veckey] = vecval; | |
| 373 | + | ||
| 374 | + | vecval.clear(); | |
| 375 | + | vecval.push_back(238); | |
| 376 | + | veckey.clear(); | |
| 377 | + | veckey.push_back(231); | |
| 378 | + | veckey.push_back(4553); | |
| 379 | + | std::sort(veckey.begin(), veckey.end()); | |
| 380 | + | replacement_map.mtm[veckey] = vecval; | |
| 381 | + | ||
| 382 | + | vecval.clear(); | |
| 383 | + | vecval.push_back(239); | |
| 384 | + | veckey.clear(); | |
| 385 | + | veckey.push_back(231); | |
| 386 | + | veckey.push_back(4552); | |
| 387 | + | std::sort(veckey.begin(), veckey.end()); | |
| 388 | + | replacement_map.mtm[veckey] = vecval; | |
| 389 | + | ||
| 390 | + | vecval.clear(); | |
| 391 | + | vecval.push_back(240); | |
| 392 | + | veckey.clear(); | |
| 393 | + | veckey.push_back(231); | |
| 394 | + | veckey.push_back(4546); | |
| 395 | + | std::sort(veckey.begin(), veckey.end()); | |
| 396 | + | replacement_map.mtm[veckey] = vecval; | |
| 397 | + | ||
| 398 | + | vecval.clear(); | |
| 399 | + | vecval.push_back(241); | |
| 400 | + | veckey.clear(); | |
| 401 | + | veckey.push_back(231); | |
| 402 | + | veckey.push_back(4547); | |
| 403 | + | std::sort(veckey.begin(), veckey.end()); | |
| 404 | + | replacement_map.mtm[veckey] = vecval; | |
| 405 | + | ||
| 406 | + | vecval.clear(); | |
| 407 | + | vecval.push_back(242); | |
| 408 | + | veckey.clear(); | |
| 409 | + | veckey.push_back(231); | |
| 410 | + | veckey.push_back(4549); | |
| 411 | + | std::sort(veckey.begin(), veckey.end()); | |
| 412 | + | replacement_map.mtm[veckey] = vecval; | |
| 413 | + | ||
| 414 | + | vecval.clear(); | |
| 415 | + | vecval.push_back(243); | |
| 416 | + | veckey.clear(); | |
| 417 | + | veckey.push_back(231); | |
| 418 | + | veckey.push_back(4548); | |
| 419 | + | std::sort(veckey.begin(), veckey.end()); | |
| 420 | + | replacement_map.mtm[veckey] = vecval; | |
| 421 | + | ||
| 422 | + | vecval.clear(); | |
| 423 | + | vecval.push_back(296); | |
| 424 | + | veckey.clear(); | |
| 425 | + | veckey.push_back(103); | |
| 426 | + | veckey.push_back(4599); | |
| 427 | + | veckey.push_back(4542); | |
| 428 | + | std::sort(veckey.begin(), veckey.end()); | |
| 429 | + | replacement_map.mtm[veckey] = vecval; | |
| 430 | + | ||
| 431 | + | vecval.clear(); | |
| 432 | + | vecval.push_back(297); | |
| 433 | + | veckey.clear(); | |
| 434 | + | veckey.push_back(103); | |
| 435 | + | veckey.push_back(4597); | |
| 436 | + | veckey.push_back(4544); | |
| 437 | + | std::sort(veckey.begin(), veckey.end()); | |
| 438 | + | replacement_map.mtm[veckey] = vecval; | |
| 439 | + | ||
| 440 | + | vecval.clear(); | |
| 441 | + | vecval.push_back(298); | |
| 442 | + | veckey.clear(); | |
| 443 | + | veckey.push_back(103); | |
| 444 | + | veckey.push_back(4599); | |
| 445 | + | veckey.push_back(4544); | |
| 446 | + | std::sort(veckey.begin(), veckey.end()); | |
| 447 | + | replacement_map.mtm[veckey] = vecval; | |
| 448 | + | ||
| 449 | + | vecval.clear(); | |
| 450 | + | vecval.push_back(299); | |
| 451 | + | veckey.clear(); | |
| 452 | + | veckey.push_back(103); | |
| 453 | + | veckey.push_back(4596); | |
| 454 | + | veckey.push_back(4543); | |
| 455 | + | std::sort(veckey.begin(), veckey.end()); | |
| 456 | + | replacement_map.mtm[veckey] = vecval; | |
| 457 | + | ||
| 458 | + | vecval.clear(); | |
| 459 | + | vecval.push_back(300); | |
| 460 | + | veckey.clear(); | |
| 461 | + | veckey.push_back(103); | |
| 462 | + | veckey.push_back(4598); | |
| 463 | + | veckey.push_back(4543); | |
| 464 | + | std::sort(veckey.begin(), veckey.end()); | |
| 465 | + | replacement_map.mtm[veckey] = vecval; | |
| 466 | + | ||
| 467 | + | vecval.clear(); | |
| 468 | + | vecval.push_back(301); | |
| 469 | + | veckey.clear(); | |
| 470 | + | veckey.push_back(103); | |
| 471 | + | veckey.push_back(4596); | |
| 472 | + | veckey.push_back(4545); | |
| 473 | + | std::sort(veckey.begin(), veckey.end()); | |
| 474 | + | replacement_map.mtm[veckey] = vecval; | |
| 475 | + | ||
| 476 | + | vecval.clear(); | |
| 477 | + | vecval.push_back(302); | |
| 478 | + | veckey.clear(); | |
| 479 | + | veckey.push_back(103); | |
| 480 | + | veckey.push_back(4598); | |
| 481 | + | veckey.push_back(4545); | |
| 482 | + | std::sort(veckey.begin(), veckey.end()); | |
| 483 | + | replacement_map.mtm[veckey] = vecval; | |
| 484 | + | ||
| 485 | + | vecval.clear(); | |
| 486 | + | vecval.push_back(304); | |
| 487 | + | veckey.clear(); | |
| 488 | + | veckey.push_back(4566); | |
| 489 | + | veckey.push_back(4670); | |
| 490 | + | veckey.push_back(4542); | |
| 491 | + | std::sort(veckey.begin(), veckey.end()); | |
| 492 | + | replacement_map.mtm[veckey] = vecval; | |
| 493 | + | ||
| 494 | + | vecval.clear(); | |
| 495 | + | vecval.push_back(305); | |
| 496 | + | veckey.clear(); | |
| 497 | + | veckey.push_back(4566); | |
| 498 | + | veckey.push_back(4668); | |
| 499 | + | veckey.push_back(4544); | |
| 500 | + | std::sort(veckey.begin(), veckey.end()); | |
| 501 | + | replacement_map.mtm[veckey] = vecval; | |
| 502 | + | ||
| 503 | + | vecval.clear(); | |
| 504 | + | vecval.push_back(306); | |
| 505 | + | veckey.clear(); | |
| 506 | + | veckey.push_back(4566); | |
| 507 | + | veckey.push_back(4670); | |
| 508 | + | veckey.push_back(4544); | |
| 509 | + | std::sort(veckey.begin(), veckey.end()); | |
| 510 | + | replacement_map.mtm[veckey] = vecval; | |
| 511 | + | ||
| 512 | + | vecval.clear(); | |
| 513 | + | vecval.push_back(307); | |
| 514 | + | veckey.clear(); | |
| 515 | + | veckey.push_back(4566); | |
| 516 | + | veckey.push_back(4667); | |
| 517 | + | veckey.push_back(4543); | |
| 518 | + | std::sort(veckey.begin(), veckey.end()); | |
| 519 | + | replacement_map.mtm[veckey] = vecval; | |
| 520 | + | ||
| 521 | + | vecval.clear(); | |
| 522 | + | vecval.push_back(308); | |
| 523 | + | veckey.clear(); | |
| 524 | + | veckey.push_back(4566); | |
| 525 | + | veckey.push_back(4667); | |
| 526 | + | veckey.push_back(4545); | |
| 527 | + | std::sort(veckey.begin(), veckey.end()); | |
| 528 | + | replacement_map.mtm[veckey] = vecval; | |
| 529 | + | ||
| 530 | + | vecval.clear(); | |
| 531 | + | vecval.push_back(309); | |
| 532 | + | veckey.clear(); | |
| 533 | + | veckey.push_back(4566); | |
| 534 | + | veckey.push_back(4669); | |
| 535 | + | veckey.push_back(4543); | |
| 536 | + | std::sort(veckey.begin(), veckey.end()); | |
| 537 | + | replacement_map.mtm[veckey] = vecval; | |
| 538 | + | ||
| 539 | + | vecval.clear(); | |
| 540 | + | vecval.push_back(310); | |
| 541 | + | veckey.clear(); | |
| 542 | + | veckey.push_back(4566); | |
| 543 | + | veckey.push_back(4669); | |
| 544 | + | veckey.push_back(4545); | |
| 545 | + | std::sort(veckey.begin(), veckey.end()); | |
| 546 | + | replacement_map.mtm[veckey] = vecval; | |
| 547 | + | ||
| 548 | + | vecval.clear(); | |
| 549 | + | vecval.push_back(311); | |
| 550 | + | veckey.clear(); | |
| 551 | + | veckey.push_back(4566); | |
| 552 | + | veckey.push_back(4597); | |
| 553 | + | veckey.push_back(4542); | |
| 554 | + | std::sort(veckey.begin(), veckey.end()); | |
| 555 | + | replacement_map.mtm[veckey] = vecval; | |
| 556 | + | ||
| 557 | + | vecval.clear(); | |
| 558 | + | vecval.push_back(312); | |
| 559 | + | veckey.clear(); | |
| 560 | + | veckey.push_back(4566); | |
| 561 | + | veckey.push_back(4599); | |
| 562 | + | veckey.push_back(4542); | |
| 563 | + | std::sort(veckey.begin(), veckey.end()); | |
| 564 | + | replacement_map.mtm[veckey] = vecval; | |
| 565 | + | ||
| 566 | + | vecval.clear(); | |
| 567 | + | vecval.push_back(313); | |
| 568 | + | veckey.clear(); | |
| 569 | + | veckey.push_back(4566); | |
| 570 | + | veckey.push_back(4597); | |
| 571 | + | veckey.push_back(4544); | |
| 572 | + | std::sort(veckey.begin(), veckey.end()); | |
| 573 | + | replacement_map.mtm[veckey] = vecval; | |
| 574 | + | ||
| 575 | + | vecval.clear(); | |
| 576 | + | vecval.push_back(314); | |
| 577 | + | veckey.clear(); | |
| 578 | + | veckey.push_back(4566); | |
| 579 | + | veckey.push_back(4599); | |
| 580 | + | veckey.push_back(4544); | |
| 581 | + | std::sort(veckey.begin(), veckey.end()); | |
| 582 | + | replacement_map.mtm[veckey] = vecval; | |
| 583 | + | ||
| 584 | + | vecval.clear(); | |
| 585 | + | vecval.push_back(315); | |
| 586 | + | veckey.clear(); | |
| 587 | + | veckey.push_back(4566); | |
| 588 | + | veckey.push_back(4596); | |
| 589 | + | veckey.push_back(4543); | |
| 590 | + | std::sort(veckey.begin(), veckey.end()); | |
| 591 | + | replacement_map.mtm[veckey] = vecval; | |
| 592 | + | ||
| 593 | + | vecval.clear(); | |
| 594 | + | vecval.push_back(316); | |
| 595 | + | veckey.clear(); | |
| 596 | + | veckey.push_back(4566); | |
| 597 | + | veckey.push_back(4598); | |
| 598 | + | veckey.push_back(4543); | |
| 599 | + | std::sort(veckey.begin(), veckey.end()); | |
| 600 | + | replacement_map.mtm[veckey] = vecval; | |
| 601 | + | ||
| 602 | + | vecval.clear(); | |
| 603 | + | vecval.push_back(317); | |
| 604 | + | veckey.clear(); | |
| 605 | + | veckey.push_back(4566); | |
| 606 | + | veckey.push_back(4596); | |
| 607 | + | veckey.push_back(4545); | |
| 608 | + | std::sort(veckey.begin(), veckey.end()); | |
| 609 | + | replacement_map.mtm[veckey] = vecval; | |
| 610 | + | ||
| 611 | + | vecval.clear(); | |
| 612 | + | vecval.push_back(318); | |
| 613 | + | veckey.clear(); | |
| 614 | + | veckey.push_back(4566); | |
| 615 | + | veckey.push_back(4598); | |
| 616 | + | veckey.push_back(4545); | |
| 617 | + | std::sort(veckey.begin(), veckey.end()); | |
| 618 | + | replacement_map.mtm[veckey] = vecval; | |
| 619 | + | ||
| 620 | + | vecval.clear(); | |
| 621 | + | vecval.push_back(319); | |
| 622 | + | veckey.clear(); | |
| 623 | + | veckey.push_back(4566); | |
| 624 | + | veckey.push_back(4670); | |
| 625 | + | veckey.push_back(4596); | |
| 626 | + | std::sort(veckey.begin(), veckey.end()); | |
| 627 | + | replacement_map.mtm[veckey] = vecval; | |
| 628 | + | ||
| 629 | + | vecval.clear(); | |
| 630 | + | vecval.push_back(320); | |
| 631 | + | veckey.clear(); | |
| 632 | + | veckey.push_back(4566); | |
| 633 | + | veckey.push_back(4668); | |
| 634 | + | veckey.push_back(4596); | |
| 635 | + | std::sort(veckey.begin(), veckey.end()); | |
| 636 | + | replacement_map.mtm[veckey] = vecval; | |
| 637 | + | ||
| 638 | + | vecval.clear(); | |
| 639 | + | vecval.push_back(321); | |
| 640 | + | veckey.clear(); | |
| 641 | + | veckey.push_back(4566); | |
| 642 | + | veckey.push_back(4670); | |
| 643 | + | veckey.push_back(4598); | |
| 644 | + | std::sort(veckey.begin(), veckey.end()); | |
| 645 | + | replacement_map.mtm[veckey] = vecval; | |
| 646 | + | ||
| 647 | + | vecval.clear(); | |
| 648 | + | vecval.push_back(322); | |
| 649 | + | veckey.clear(); | |
| 650 | + | veckey.push_back(4566); | |
| 651 | + | veckey.push_back(4668); | |
| 652 | + | veckey.push_back(4598); | |
| 653 | + | std::sort(veckey.begin(), veckey.end()); | |
| 654 | + | replacement_map.mtm[veckey] = vecval; | |
| 655 | + | ||
| 656 | + | vecval.clear(); | |
| 657 | + | vecval.push_back(323); | |
| 658 | + | veckey.clear(); | |
| 659 | + | veckey.push_back(4566); | |
| 660 | + | veckey.push_back(4667); | |
| 661 | + | veckey.push_back(4597); | |
| 662 | + | std::sort(veckey.begin(), veckey.end()); | |
| 663 | + | replacement_map.mtm[veckey] = vecval; | |
| 664 | + | ||
| 665 | + | vecval.clear(); | |
| 666 | + | vecval.push_back(324); | |
| 667 | + | veckey.clear(); | |
| 668 | + | veckey.push_back(4566); | |
| 669 | + | veckey.push_back(4669); | |
| 670 | + | veckey.push_back(4597); | |
| 671 | + | std::sort(veckey.begin(), veckey.end()); | |
| 672 | + | replacement_map.mtm[veckey] = vecval; | |
| 673 | + | ||
| 674 | + | vecval.clear(); | |
| 675 | + | vecval.push_back(325); | |
| 676 | + | veckey.clear(); | |
| 677 | + | veckey.push_back(4566); | |
| 678 | + | veckey.push_back(4667); | |
| 679 | + | veckey.push_back(4599); | |
| 680 | + | std::sort(veckey.begin(), veckey.end()); | |
| 681 | + | replacement_map.mtm[veckey] = vecval; | |
| 682 | + | ||
| 683 | + | vecval.clear(); | |
| 684 | + | vecval.push_back(326); | |
| 685 | + | veckey.clear(); | |
| 686 | + | veckey.push_back(4566); | |
| 687 | + | veckey.push_back(4669); | |
| 688 | + | veckey.push_back(4599); | |
| 689 | + | std::sort(veckey.begin(), veckey.end()); | |
| 690 | + | replacement_map.mtm[veckey] = vecval; | |
| 691 | + | ||
| 692 | + | return replacement_map; | |
| 693 | + | } |
| @@ -0,0 +1,38 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #ifndef RME_MAP_TEMPLATES_H_ | |
| 19 | + | #define RME_MAP_TEMPLATES_H_ | |
| 20 | + | ||
| 21 | + | #include "common.h" | |
| 22 | + | ||
| 23 | + | struct ConversionMap { | |
| 24 | + | // Many to Many | |
| 25 | + | typedef std::map<std::vector<uint16_t>, std::vector<uint16_t>> MTM; | |
| 26 | + | // Single to Many | |
| 27 | + | typedef std::map<uint16_t, std::vector<uint16_t>> STM; | |
| 28 | + | ||
| 29 | + | MTM mtm; | |
| 30 | + | STM stm; | |
| 31 | + | }; | |
| 32 | + | ||
| 33 | + | ConversionMap getReplacementMapFrom800To810(); | |
| 34 | + | ConversionMap getReplacementMapFrom760To740(); | |
| 35 | + | ConversionMap getReplacementMapFrom854To854(); | |
| 36 | + | ConversionMap getReplacementMapClassic(); | |
| 37 | + | ||
| 38 | + | #endif |
| @@ -0,0 +1,50 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #ifndef RME_THREAD_H_ | |
| 19 | + | #define RME_THREAD_H_ | |
| 20 | + | ||
| 21 | + | #include "main.h" | |
| 22 | + | ||
| 23 | + | class Thread : public wxThread { | |
| 24 | + | public: | |
| 25 | + | Thread(wxThreadKind); | |
| 26 | + | ||
| 27 | + | void Execute(); // Calls "Create" and then "Run" | |
| 28 | + | }; | |
| 29 | + | ||
| 30 | + | class JoinableThread : public Thread { | |
| 31 | + | public: | |
| 32 | + | JoinableThread() : | |
| 33 | + | Thread(wxTHREAD_JOINABLE) { } | |
| 34 | + | }; | |
| 35 | + | ||
| 36 | + | class DetachedThread : public Thread { | |
| 37 | + | public: | |
| 38 | + | DetachedThread() : | |
| 39 | + | Thread(wxTHREAD_DETACHED) { } | |
| 40 | + | }; | |
| 41 | + | ||
| 42 | + | inline Thread::Thread(wxThreadKind kind) : | |
| 43 | + | wxThread(kind) { } | |
| 44 | + | ||
| 45 | + | inline void Thread::Execute() { | |
| 46 | + | Create(); | |
| 47 | + | Run(); | |
| 48 | + | } | |
| 49 | + | ||
| 50 | + | #endif |
| @@ -0,0 +1,834 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #include "main.h" | |
| 19 | + | ||
| 20 | + | #include "brush.h" | |
| 21 | + | ||
| 22 | + | #include "tile.h" | |
| 23 | + | #include "creature.h" | |
| 24 | + | #include "house.h" | |
| 25 | + | #include "basemap.h" | |
| 26 | + | #include "spawn.h" | |
| 27 | + | #include "ground_brush.h" | |
| 28 | + | #include "wall_brush.h" | |
| 29 | + | #include "carpet_brush.h" | |
| 30 | + | #include "table_brush.h" | |
| 31 | + | #include "town.h" | |
| 32 | + | #include "map.h" | |
| 33 | + | ||
| 34 | + | static thread_local std::set<Position> wallize_processing_tiles; | |
| 35 | + | ||
| 36 | + | Tile::Tile(int x, int y, int z) : | |
| 37 | + | location(nullptr), | |
| 38 | + | ground(nullptr), | |
| 39 | + | creature(nullptr), | |
| 40 | + | spawn(nullptr), | |
| 41 | + | house_id(0), | |
| 42 | + | mapflags(0), | |
| 43 | + | statflags(0), | |
| 44 | + | minimapColor(INVALID_MINIMAP_COLOR) { | |
| 45 | + | //// | |
| 46 | + | } | |
| 47 | + | ||
| 48 | + | Tile::Tile(TileLocation& loc) : | |
| 49 | + | location(&loc), | |
| 50 | + | ground(nullptr), | |
| 51 | + | creature(nullptr), | |
| 52 | + | spawn(nullptr), | |
| 53 | + | house_id(0), | |
| 54 | + | mapflags(0), | |
| 55 | + | statflags(0), | |
| 56 | + | minimapColor(INVALID_MINIMAP_COLOR) { | |
| 57 | + | //// | |
| 58 | + | } | |
| 59 | + | ||
| 60 | + | Tile::~Tile() { | |
| 61 | + | bool had_items = !items.empty(); | |
| 62 | + | bool had_ground = ground != nullptr; | |
| 63 | + | ||
| 64 | + | #ifdef __WXDEBUG__ | |
| 65 | + | if (had_ground) { | |
| 66 | + | // Store ground info before deleting it | |
| 67 | + | uint16_t ground_id = ground->getID(); | |
| 68 | + | void* ground_ptr = ground; | |
| 69 | + | printf("DEBUG: Tile destructor for %p with ground %p (ID:%d)\n", this, ground_ptr, ground_id); | |
| 70 | + | ||
| 71 | + | // Get call stack info by adding a breakpoint variable | |
| 72 | + | int debug_breakpoint_for_ground_deletion = 1; | |
| 73 | + | } | |
| 74 | + | #endif | |
| 75 | + | ||
| 76 | + | while (!items.empty()) { | |
| 77 | + | delete items.back(); | |
| 78 | + | items.pop_back(); | |
| 79 | + | } | |
| 80 | + | delete creature; | |
| 81 | + | delete ground; | |
| 82 | + | delete spawn; | |
| 83 | + | ||
| 84 | + | #ifdef __WXDEBUG__ | |
| 85 | + | if (had_ground) { | |
| 86 | + | printf("DEBUG: Ground %p deleted\n", ground); | |
| 87 | + | } | |
| 88 | + | #endif | |
| 89 | + | } | |
| 90 | + | ||
| 91 | + | Tile* Tile::deepCopy(BaseMap& map) { | |
| 92 | + | Tile* copy = map.allocator.allocateTile(location); | |
| 93 | + | copy->flags = flags; | |
| 94 | + | copy->house_id = house_id; | |
| 95 | + | ||
| 96 | + | #ifdef __WXDEBUG__ | |
| 97 | + | printf("DEBUG: deepCopy - Creating copy of tile %p (with ground %p)\n", | |
| 98 | + | this, ground); | |
| 99 | + | #endif | |
| 100 | + | ||
| 101 | + | if (spawn) { | |
| 102 | + | copy->spawn = spawn->deepCopy(); | |
| 103 | + | } | |
| 104 | + | if (creature) { | |
| 105 | + | copy->creature = creature->deepCopy(); | |
| 106 | + | } | |
| 107 | + | // Spawncount & exits are not transferred on copy! | |
| 108 | + | if (ground) { | |
| 109 | + | #ifdef __WXDEBUG__ | |
| 110 | + | printf("DEBUG: deepCopy - Copying ground %p with ID %d\n", | |
| 111 | + | ground, ground->getID()); | |
| 112 | + | #endif | |
| 113 | + | copy->ground = ground->deepCopy(); | |
| 114 | + | #ifdef __WXDEBUG__ | |
| 115 | + | printf("DEBUG: deepCopy - Ground copied to %p with ID %d\n", | |
| 116 | + | copy->ground, copy->ground->getID()); | |
| 117 | + | #endif | |
| 118 | + | } | |
| 119 | + | ||
| 120 | + | copy->setZoneIds(this); | |
| 121 | + | ||
| 122 | + | ItemVector::iterator it; | |
| 123 | + | ||
| 124 | + | it = items.begin(); | |
| 125 | + | while (it != items.end()) { | |
| 126 | + | copy->items.push_back((*it)->deepCopy()); | |
| 127 | + | ++it; | |
| 128 | + | } | |
| 129 | + | ||
| 130 | + | #ifdef __WXDEBUG__ | |
| 131 | + | printf("DEBUG: deepCopy - Created tile copy %p (with ground %p)\n", | |
| 132 | + | copy, copy->ground); | |
| 133 | + | #endif | |
| 134 | + | ||
| 135 | + | return copy; | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | uint32_t Tile::memsize() const { | |
| 139 | + | uint32_t mem = sizeof(*this); | |
| 140 | + | if (ground) { | |
| 141 | + | mem += ground->memsize(); | |
| 142 | + | } | |
| 143 | + | ||
| 144 | + | ItemVector::const_iterator it; | |
| 145 | + | ||
| 146 | + | it = items.begin(); | |
| 147 | + | while (it != items.end()) { | |
| 148 | + | mem += (*it)->memsize(); | |
| 149 | + | ++it; | |
| 150 | + | } | |
| 151 | + | ||
| 152 | + | mem += sizeof(Item*) * items.capacity(); | |
| 153 | + | ||
| 154 | + | return mem; | |
| 155 | + | } | |
| 156 | + | ||
| 157 | + | int Tile::size() const { | |
| 158 | + | int sz = 0; | |
| 159 | + | if (ground) { | |
| 160 | + | ++sz; | |
| 161 | + | } | |
| 162 | + | sz += items.size(); | |
| 163 | + | if (creature) { | |
| 164 | + | ++sz; | |
| 165 | + | } | |
| 166 | + | if (spawn) { | |
| 167 | + | ++sz; | |
| 168 | + | } | |
| 169 | + | if (location) { | |
| 170 | + | if (location->getHouseExits()) { | |
| 171 | + | ++sz; | |
| 172 | + | } | |
| 173 | + | if (location->getSpawnCount()) { | |
| 174 | + | ++sz; | |
| 175 | + | } | |
| 176 | + | if (location->getWaypointCount()) { | |
| 177 | + | ++sz; | |
| 178 | + | } | |
| 179 | + | } | |
| 180 | + | return sz; | |
| 181 | + | } | |
| 182 | + | ||
| 183 | + | void Tile::merge(Tile* other) { | |
| 184 | + | if (other->isPZ()) { | |
| 185 | + | setPZ(true); | |
| 186 | + | } | |
| 187 | + | if (other->house_id) { | |
| 188 | + | house_id = other->house_id; | |
| 189 | + | } | |
| 190 | + | ||
| 191 | + | if (other->ground) { | |
| 192 | + | delete ground; | |
| 193 | + | ground = other->ground; | |
| 194 | + | other->ground = nullptr; | |
| 195 | + | } | |
| 196 | + | ||
| 197 | + | if (other->creature) { | |
| 198 | + | delete creature; | |
| 199 | + | creature = other->creature; | |
| 200 | + | other->creature = nullptr; | |
| 201 | + | } | |
| 202 | + | ||
| 203 | + | if (other->spawn) { | |
| 204 | + | delete spawn; | |
| 205 | + | spawn = other->spawn; | |
| 206 | + | other->spawn = nullptr; | |
| 207 | + | } | |
| 208 | + | ||
| 209 | + | if (other->creature) { | |
| 210 | + | delete creature; | |
| 211 | + | creature = other->creature; | |
| 212 | + | other->creature = nullptr; | |
| 213 | + | } | |
| 214 | + | ||
| 215 | + | ItemVector::iterator it; | |
| 216 | + | ||
| 217 | + | it = other->items.begin(); | |
| 218 | + | while (it != other->items.end()) { | |
| 219 | + | addItem(*it); | |
| 220 | + | ++it; | |
| 221 | + | } | |
| 222 | + | other->items.clear(); | |
| 223 | + | } | |
| 224 | + | ||
| 225 | + | bool Tile::hasProperty(enum ITEMPROPERTY prop) const { | |
| 226 | + | if (prop == PROTECTIONZONE && isPZ()) { | |
| 227 | + | return true; | |
| 228 | + | } | |
| 229 | + | ||
| 230 | + | if (ground && ground->hasProperty(prop)) { | |
| 231 | + | return true; | |
| 232 | + | } | |
| 233 | + | ||
| 234 | + | ItemVector::const_iterator iit; | |
| 235 | + | for (iit = items.begin(); iit != items.end(); ++iit) { | |
| 236 | + | if ((*iit)->hasProperty(prop)) { | |
| 237 | + | return true; | |
| 238 | + | } | |
| 239 | + | } | |
| 240 | + | ||
| 241 | + | return false; | |
| 242 | + | } | |
| 243 | + | ||
| 244 | + | int Tile::getIndexOf(Item* item) const { | |
| 245 | + | if (!item) { | |
| 246 | + | return wxNOT_FOUND; | |
| 247 | + | } | |
| 248 | + | ||
| 249 | + | int index = 0; | |
| 250 | + | if (ground) { | |
| 251 | + | if (ground == item) { | |
| 252 | + | return index; | |
| 253 | + | } | |
| 254 | + | index++; | |
| 255 | + | } | |
| 256 | + | ||
| 257 | + | if (!items.empty()) { | |
| 258 | + | auto it = std::find(items.begin(), items.end(), item); | |
| 259 | + | if (it != items.end()) { | |
| 260 | + | index += (it - items.begin()); | |
| 261 | + | return index; | |
| 262 | + | } | |
| 263 | + | } | |
| 264 | + | return wxNOT_FOUND; | |
| 265 | + | } | |
| 266 | + | ||
| 267 | + | Item* Tile::getTopItem() const { | |
| 268 | + | if (!items.empty() && !items.back()->isMetaItem()) { | |
| 269 | + | return items.back(); | |
| 270 | + | } | |
| 271 | + | if (ground && !ground->isMetaItem()) { | |
| 272 | + | return ground; | |
| 273 | + | } | |
| 274 | + | return nullptr; | |
| 275 | + | } | |
| 276 | + | ||
| 277 | + | Item* Tile::getItemAt(int index) const { | |
| 278 | + | if (index < 0) { | |
| 279 | + | return nullptr; | |
| 280 | + | } | |
| 281 | + | if (ground) { | |
| 282 | + | if (index == 0) { | |
| 283 | + | return ground; | |
| 284 | + | } | |
| 285 | + | index--; | |
| 286 | + | } | |
| 287 | + | if (index >= 0 && index < items.size()) { | |
| 288 | + | return items.at(index); | |
| 289 | + | } | |
| 290 | + | return nullptr; | |
| 291 | + | } | |
| 292 | + | ||
| 293 | + | void Tile::addItem(Item* item) { | |
| 294 | + | if (!item) { | |
| 295 | + | return; | |
| 296 | + | } | |
| 297 | + | ||
| 298 | + | // Handle ground tiles | |
| 299 | + | if (item->isGroundTile()) { | |
| 300 | + | #ifdef __WXDEBUG__ | |
| 301 | + | printf("DEBUG: Adding ground tile ID %d to position %d,%d,%d\n", | |
| 302 | + | item->getID(), getPosition().x, getPosition().y, getPosition().z); | |
| 303 | + | #endif | |
| 304 | + | // Always delete the existing ground first | |
| 305 | + | delete ground; | |
| 306 | + | ground = item; | |
| 307 | + | ||
| 308 | + | // Also check for any ground items that might be in the items list | |
| 309 | + | // and remove them to prevent stacking issues | |
| 310 | + | ItemVector::iterator it = items.begin(); | |
| 311 | + | while (it != items.end()) { | |
| 312 | + | if ((*it)->isGroundTile() || (*it)->getGroundEquivalent() != 0) { | |
| 313 | + | #ifdef __WXDEBUG__ | |
| 314 | + | printf("DEBUG: Removing misplaced ground item with ID %d from tile items\n", (*it)->getID()); | |
| 315 | + | #endif | |
| 316 | + | delete *it; | |
| 317 | + | it = items.erase(it); | |
| 318 | + | } else { | |
| 319 | + | ++it; | |
| 320 | + | } | |
| 321 | + | } | |
| 322 | + | return; | |
| 323 | + | } | |
| 324 | + | ||
| 325 | + | // Handle items with ground equivalents | |
| 326 | + | uint16_t gid = item->getGroundEquivalent(); | |
| 327 | + | if (gid != 0) { | |
| 328 | + | // If item has a ground equivalent, replace the ground | |
| 329 | + | delete ground; | |
| 330 | + | ground = Item::Create(gid); | |
| 331 | + | ||
| 332 | + | // Insert at the very bottom of the stack | |
| 333 | + | items.insert(items.begin(), item); | |
| 334 | + | ||
| 335 | + | if (item->isSelected()) { | |
| 336 | + | statflags |= TILESTATE_SELECTED; | |
| 337 | + | } | |
| 338 | + | return; | |
| 339 | + | } | |
| 340 | + | ||
| 341 | + | // Handle normal items | |
| 342 | + | ItemVector::iterator it; | |
| 343 | + | if (item->isAlwaysOnBottom()) { | |
| 344 | + | it = items.begin(); | |
| 345 | + | while (true) { | |
| 346 | + | if (it == items.end()) { | |
| 347 | + | break; | |
| 348 | + | } else if ((*it)->isAlwaysOnBottom()) { | |
| 349 | + | if (item->getTopOrder() < (*it)->getTopOrder()) { | |
| 350 | + | break; | |
| 351 | + | } | |
| 352 | + | } else { // Always on top | |
| 353 | + | break; | |
| 354 | + | } | |
| 355 | + | ++it; | |
| 356 | + | } | |
| 357 | + | } else { | |
| 358 | + | it = items.end(); | |
| 359 | + | } | |
| 360 | + | ||
| 361 | + | items.insert(it, item); | |
| 362 | + | ||
| 363 | + | if (item->isSelected()) { | |
| 364 | + | statflags |= TILESTATE_SELECTED; | |
| 365 | + | } | |
| 366 | + | } | |
| 367 | + | ||
| 368 | + | void Tile::select() { | |
| 369 | + | if (size() == 0) { | |
| 370 | + | return; | |
| 371 | + | } | |
| 372 | + | if (ground) { | |
| 373 | + | ground->select(); | |
| 374 | + | } | |
| 375 | + | if (spawn) { | |
| 376 | + | spawn->select(); | |
| 377 | + | } | |
| 378 | + | if (creature) { | |
| 379 | + | creature->select(); | |
| 380 | + | } | |
| 381 | + | ||
| 382 | + | ItemVector::iterator it; | |
| 383 | + | ||
| 384 | + | it = items.begin(); | |
| 385 | + | while (it != items.end()) { | |
| 386 | + | (*it)->select(); | |
| 387 | + | ++it; | |
| 388 | + | } | |
| 389 | + | ||
| 390 | + | statflags |= TILESTATE_SELECTED; | |
| 391 | + | } | |
| 392 | + | ||
| 393 | + | void Tile::deselect() { | |
| 394 | + | if (ground) { | |
| 395 | + | ground->deselect(); | |
| 396 | + | } | |
| 397 | + | if (spawn) { | |
| 398 | + | spawn->deselect(); | |
| 399 | + | } | |
| 400 | + | if (creature) { | |
| 401 | + | creature->deselect(); | |
| 402 | + | } | |
| 403 | + | ||
| 404 | + | ItemVector::iterator it; | |
| 405 | + | ||
| 406 | + | it = items.begin(); | |
| 407 | + | while (it != items.end()) { | |
| 408 | + | (*it)->deselect(); | |
| 409 | + | ++it; | |
| 410 | + | } | |
| 411 | + | ||
| 412 | + | statflags &= ~TILESTATE_SELECTED; | |
| 413 | + | } | |
| 414 | + | ||
| 415 | + | Item* Tile::getTopSelectedItem() { | |
| 416 | + | for (ItemVector::reverse_iterator iter = items.rbegin(); iter != items.rend(); ++iter) { | |
| 417 | + | if ((*iter)->isSelected() && !(*iter)->isMetaItem()) { | |
| 418 | + | return *iter; | |
| 419 | + | } | |
| 420 | + | } | |
| 421 | + | if (ground && ground->isSelected() && !ground->isMetaItem()) { | |
| 422 | + | return ground; | |
| 423 | + | } | |
| 424 | + | return nullptr; | |
| 425 | + | } | |
| 426 | + | ||
| 427 | + | ItemVector Tile::popSelectedItems(bool ignoreTileSelected) { | |
| 428 | + | ItemVector pop_items; | |
| 429 | + | ||
| 430 | + | if (!ignoreTileSelected && !isSelected()) { | |
| 431 | + | return pop_items; | |
| 432 | + | } | |
| 433 | + | ||
| 434 | + | if (ground && ground->isSelected()) { | |
| 435 | + | pop_items.push_back(ground); | |
| 436 | + | ground = nullptr; | |
| 437 | + | } | |
| 438 | + | ||
| 439 | + | ItemVector::iterator it; | |
| 440 | + | ||
| 441 | + | it = items.begin(); | |
| 442 | + | while (it != items.end()) { | |
| 443 | + | if ((*it)->isSelected()) { | |
| 444 | + | pop_items.push_back(*it); | |
| 445 | + | it = items.erase(it); | |
| 446 | + | } else { | |
| 447 | + | ++it; | |
| 448 | + | } | |
| 449 | + | } | |
| 450 | + | ||
| 451 | + | statflags &= ~TILESTATE_SELECTED; | |
| 452 | + | return pop_items; | |
| 453 | + | } | |
| 454 | + | ||
| 455 | + | ItemVector Tile::getSelectedItems(bool unzoomed) { | |
| 456 | + | ItemVector selected_items; | |
| 457 | + | ||
| 458 | + | if (!isSelected()) { | |
| 459 | + | return selected_items; | |
| 460 | + | } | |
| 461 | + | ||
| 462 | + | if (ground && ground->isSelected()) { | |
| 463 | + | selected_items.push_back(ground); | |
| 464 | + | } | |
| 465 | + | ||
| 466 | + | // save performance when zoomed out | |
| 467 | + | if (!unzoomed) { | |
| 468 | + | ItemVector::iterator it; | |
| 469 | + | ||
| 470 | + | it = items.begin(); | |
| 471 | + | while (it != items.end()) { | |
| 472 | + | if ((*it)->isSelected()) { | |
| 473 | + | selected_items.push_back(*it); | |
| 474 | + | } | |
| 475 | + | it++; | |
| 476 | + | } | |
| 477 | + | } | |
| 478 | + | ||
| 479 | + | return selected_items; | |
| 480 | + | } | |
| 481 | + | ||
| 482 | + | uint8_t Tile::getMiniMapColor() const { | |
| 483 | + | if (minimapColor != INVALID_MINIMAP_COLOR) { | |
| 484 | + | return minimapColor; | |
| 485 | + | } | |
| 486 | + | ||
| 487 | + | for (ItemVector::const_reverse_iterator item_iter = items.rbegin(); item_iter != items.rend(); ++item_iter) { | |
| 488 | + | if ((*item_iter)->getMiniMapColor()) { | |
| 489 | + | return (*item_iter)->getMiniMapColor(); | |
| 490 | + | break; | |
| 491 | + | } | |
| 492 | + | } | |
| 493 | + | ||
| 494 | + | // check ground too | |
| 495 | + | if (hasGround()) { | |
| 496 | + | return ground->getMiniMapColor(); | |
| 497 | + | } | |
| 498 | + | ||
| 499 | + | return 0; | |
| 500 | + | } | |
| 501 | + | ||
| 502 | + | bool tilePositionLessThan(const Tile* a, const Tile* b) { | |
| 503 | + | return a->getPosition() < b->getPosition(); | |
| 504 | + | } | |
| 505 | + | ||
| 506 | + | bool tilePositionVisualLessThan(const Tile* a, const Tile* b) { | |
| 507 | + | Position pa = a->getPosition(); | |
| 508 | + | Position pb = b->getPosition(); | |
| 509 | + | ||
| 510 | + | if (pa.z > pb.z) { | |
| 511 | + | return true; | |
| 512 | + | } | |
| 513 | + | if (pa.z < pb.z) { | |
| 514 | + | return false; | |
| 515 | + | } | |
| 516 | + | ||
| 517 | + | if (pa.y < pb.y) { | |
| 518 | + | return true; | |
| 519 | + | } | |
| 520 | + | if (pa.y > pb.y) { | |
| 521 | + | return false; | |
| 522 | + | } | |
| 523 | + | ||
| 524 | + | if (pa.x < pb.x) { | |
| 525 | + | return true; | |
| 526 | + | } | |
| 527 | + | ||
| 528 | + | return false; | |
| 529 | + | } | |
| 530 | + | ||
| 531 | + | void Tile::update() { | |
| 532 | + | statflags &= TILESTATE_MODIFIED; | |
| 533 | + | ||
| 534 | + | if (spawn && spawn->isSelected()) { | |
| 535 | + | statflags |= TILESTATE_SELECTED; | |
| 536 | + | } | |
| 537 | + | if (creature && creature->isSelected()) { | |
| 538 | + | statflags |= TILESTATE_SELECTED; | |
| 539 | + | } | |
| 540 | + | ||
| 541 | + | if (ground) { | |
| 542 | + | if (ground->isSelected()) { | |
| 543 | + | statflags |= TILESTATE_SELECTED; | |
| 544 | + | } | |
| 545 | + | if (ground->isBlocking()) { | |
| 546 | + | statflags |= TILESTATE_BLOCKING; | |
| 547 | + | } | |
| 548 | + | if (ground->getUniqueID() != 0) { | |
| 549 | + | statflags |= TILESTATE_UNIQUE; | |
| 550 | + | } | |
| 551 | + | if (ground->getMiniMapColor() != 0) { | |
| 552 | + | minimapColor = ground->getMiniMapColor(); | |
| 553 | + | } | |
| 554 | + | } | |
| 555 | + | ||
| 556 | + | ItemVector::const_iterator iter = items.begin(); | |
| 557 | + | while (iter != items.end()) { | |
| 558 | + | Item* i = *iter; | |
| 559 | + | if (i->isSelected()) { | |
| 560 | + | statflags |= TILESTATE_SELECTED; | |
| 561 | + | } | |
| 562 | + | if (i->getUniqueID() != 0) { | |
| 563 | + | statflags |= TILESTATE_UNIQUE; | |
| 564 | + | } | |
| 565 | + | if (i->getMiniMapColor() != 0) { | |
| 566 | + | minimapColor = i->getMiniMapColor(); | |
| 567 | + | } | |
| 568 | + | ||
| 569 | + | ItemType& it = g_items[i->getID()]; | |
| 570 | + | if (it.unpassable) { | |
| 571 | + | statflags |= TILESTATE_BLOCKING; | |
| 572 | + | } | |
| 573 | + | if (it.isOptionalBorder) { | |
| 574 | + | statflags |= TILESTATE_OP_BORDER; | |
| 575 | + | } | |
| 576 | + | if (it.isTable) { | |
| 577 | + | statflags |= TILESTATE_HAS_TABLE; | |
| 578 | + | } | |
| 579 | + | if (it.isCarpet) { | |
| 580 | + | statflags |= TILESTATE_HAS_CARPET; | |
| 581 | + | } | |
| 582 | + | ++iter; | |
| 583 | + | } | |
| 584 | + | ||
| 585 | + | if ((statflags & TILESTATE_BLOCKING) == 0) { | |
| 586 | + | if (ground == nullptr && items.size() == 0) { | |
| 587 | + | statflags |= TILESTATE_BLOCKING; | |
| 588 | + | } | |
| 589 | + | } | |
| 590 | + | } | |
| 591 | + | ||
| 592 | + | void Tile::borderize(BaseMap* parent) { | |
| 593 | + | if (g_settings.getBoolean(Config::SAME_GROUND_TYPE_BORDER)) { | |
| 594 | + | // Use the custom reborderize method for better border placement | |
| 595 | + | GroundBrush::reborderizeTile(parent, this); | |
| 596 | + | } else { | |
| 597 | + | // Standard border handling | |
| 598 | + | GroundBrush::doBorders(parent, this); | |
| 599 | + | } | |
| 600 | + | } | |
| 601 | + | ||
| 602 | + | void Tile::addBorderItem(Item* item) { | |
| 603 | + | if (!item) { | |
| 604 | + | return; | |
| 605 | + | } | |
| 606 | + | ASSERT(item->isBorder()); | |
| 607 | + | ||
| 608 | + | if (g_settings.getBoolean(Config::SAME_GROUND_TYPE_BORDER)) { | |
| 609 | + | // When Same Ground Type Border is enabled, add borders at the end (top) of the stack | |
| 610 | + | // This ensures borders appear on top of existing items | |
| 611 | + | items.push_back(item); | |
| 612 | + | } else { | |
| 613 | + | // Standard behavior (borders at the bottom of the stack) | |
| 614 | + | items.insert(items.begin(), item); | |
| 615 | + | } | |
| 616 | + | } | |
| 617 | + | ||
| 618 | + | GroundBrush* Tile::getGroundBrush() const { | |
| 619 | + | if (ground) { | |
| 620 | + | if (ground->getGroundBrush()) { | |
| 621 | + | return ground->getGroundBrush(); | |
| 622 | + | } | |
| 623 | + | } | |
| 624 | + | return nullptr; | |
| 625 | + | } | |
| 626 | + | ||
| 627 | + | void Tile::cleanBorders() { | |
| 628 | + | // If Same Ground Type Border is enabled, we don't clean all borders | |
| 629 | + | // This will be handled in the GroundBrush::doBorders method | |
| 630 | + | if (g_settings.getBoolean(Config::SAME_GROUND_TYPE_BORDER)) { | |
| 631 | + | return; | |
| 632 | + | } | |
| 633 | + | ||
| 634 | + | // When Same Ground Type Border is disabled, remove all border items | |
| 635 | + | for (ItemVector::iterator it = items.begin(); it != items.end();) { | |
| 636 | + | if ((*it)->isBorder()) { | |
| 637 | + | delete *it; | |
| 638 | + | it = items.erase(it); | |
| 639 | + | } else { | |
| 640 | + | ++it; | |
| 641 | + | } | |
| 642 | + | } | |
| 643 | + | } | |
| 644 | + | ||
| 645 | + | void Tile::wallize(BaseMap* parent) { | |
| 646 | + | // Add recursion guard | |
| 647 | + | if (wallize_processing_tiles.find(getPosition()) != wallize_processing_tiles.end()) { | |
| 648 | + | return; | |
| 649 | + | } | |
| 650 | + | wallize_processing_tiles.insert(getPosition()); | |
| 651 | + | ||
| 652 | + | WallBrush::doWalls(parent, this); | |
| 653 | + | ||
| 654 | + | // Remove from processing set when done | |
| 655 | + | wallize_processing_tiles.erase(getPosition()); | |
| 656 | + | } | |
| 657 | + | ||
| 658 | + | Item* Tile::getWall() const { | |
| 659 | + | ItemVector::const_iterator it; | |
| 660 | + | ||
| 661 | + | it = items.begin(); | |
| 662 | + | while (it != items.end()) { | |
| 663 | + | if ((*it)->isWall()) { | |
| 664 | + | return *it; | |
| 665 | + | } | |
| 666 | + | ++it; | |
| 667 | + | } | |
| 668 | + | return nullptr; | |
| 669 | + | } | |
| 670 | + | ||
| 671 | + | Item* Tile::getCarpet() const { | |
| 672 | + | ItemVector::const_iterator it; | |
| 673 | + | ||
| 674 | + | it = items.begin(); | |
| 675 | + | while (it != items.end()) { | |
| 676 | + | if ((*it)->isCarpet()) { | |
| 677 | + | return *it; | |
| 678 | + | } | |
| 679 | + | ++it; | |
| 680 | + | } | |
| 681 | + | return nullptr; | |
| 682 | + | } | |
| 683 | + | ||
| 684 | + | Item* Tile::getTable() const { | |
| 685 | + | ItemVector::const_iterator it; | |
| 686 | + | ||
| 687 | + | it = items.begin(); | |
| 688 | + | while (it != items.end()) { | |
| 689 | + | if ((*it)->isTable()) { | |
| 690 | + | return *it; | |
| 691 | + | } | |
| 692 | + | ++it; | |
| 693 | + | } | |
| 694 | + | return nullptr; | |
| 695 | + | } | |
| 696 | + | ||
| 697 | + | void Tile::addWallItem(Item* item) { | |
| 698 | + | if (!item) { | |
| 699 | + | return; | |
| 700 | + | } | |
| 701 | + | ASSERT(item->isWall()); | |
| 702 | + | ||
| 703 | + | addItem(item); | |
| 704 | + | } | |
| 705 | + | ||
| 706 | + | void Tile::cleanWalls(bool dontdelete) { | |
| 707 | + | ItemVector::iterator it; | |
| 708 | + | ||
| 709 | + | it = items.begin(); | |
| 710 | + | while (it != items.end()) { | |
| 711 | + | if ((*it)->isWall()) { | |
| 712 | + | if (!dontdelete) { | |
| 713 | + | delete *it; | |
| 714 | + | } | |
| 715 | + | it = items.erase(it); | |
| 716 | + | } else { | |
| 717 | + | ++it; | |
| 718 | + | } | |
| 719 | + | } | |
| 720 | + | } | |
| 721 | + | ||
| 722 | + | void Tile::cleanWalls(WallBrush* wb) { | |
| 723 | + | ItemVector::iterator it; | |
| 724 | + | ||
| 725 | + | it = items.begin(); | |
| 726 | + | while (it != items.end()) { | |
| 727 | + | if ((*it)->isWall() && wb->hasWall(*it)) { | |
| 728 | + | delete *it; | |
| 729 | + | it = items.erase(it); | |
| 730 | + | } else { | |
| 731 | + | ++it; | |
| 732 | + | } | |
| 733 | + | } | |
| 734 | + | } | |
| 735 | + | ||
| 736 | + | void Tile::cleanTables(bool dontdelete) { | |
| 737 | + | ItemVector::iterator it; | |
| 738 | + | ||
| 739 | + | it = items.begin(); | |
| 740 | + | while (it != items.end()) { | |
| 741 | + | if ((*it)->isTable()) { | |
| 742 | + | if (!dontdelete) { | |
| 743 | + | delete *it; | |
| 744 | + | } | |
| 745 | + | it = items.erase(it); | |
| 746 | + | } else { | |
| 747 | + | ++it; | |
| 748 | + | } | |
| 749 | + | } | |
| 750 | + | } | |
| 751 | + | ||
| 752 | + | void Tile::tableize(BaseMap* parent) { | |
| 753 | + | TableBrush::doTables(parent, this); | |
| 754 | + | } | |
| 755 | + | ||
| 756 | + | void Tile::carpetize(BaseMap* parent) { | |
| 757 | + | CarpetBrush::doCarpets(parent, this); | |
| 758 | + | } | |
| 759 | + | ||
| 760 | + | void Tile::selectGround() { | |
| 761 | + | bool selected_ = false; | |
| 762 | + | if (ground) { | |
| 763 | + | ground->select(); | |
| 764 | + | selected_ = true; | |
| 765 | + | } | |
| 766 | + | ItemVector::iterator it; | |
| 767 | + | ||
| 768 | + | it = items.begin(); | |
| 769 | + | while (it != items.end()) { | |
| 770 | + | if ((*it)->isBorder()) { | |
| 771 | + | (*it)->select(); | |
| 772 | + | selected_ = true; | |
| 773 | + | } else { | |
| 774 | + | break; | |
| 775 | + | } | |
| 776 | + | ++it; | |
| 777 | + | } | |
| 778 | + | if (selected_) { | |
| 779 | + | statflags |= TILESTATE_SELECTED; | |
| 780 | + | } | |
| 781 | + | } | |
| 782 | + | ||
| 783 | + | void Tile::deselectGround() { | |
| 784 | + | if (ground) { | |
| 785 | + | ground->deselect(); | |
| 786 | + | } | |
| 787 | + | ItemVector::iterator it = items.begin(); | |
| 788 | + | while (it != items.end()) { | |
| 789 | + | if ((*it)->isBorder()) { | |
| 790 | + | (*it)->deselect(); | |
| 791 | + | } else { | |
| 792 | + | break; | |
| 793 | + | } | |
| 794 | + | ++it; | |
| 795 | + | } | |
| 796 | + | } | |
| 797 | + | ||
| 798 | + | void Tile::setHouse(House* _house) { | |
| 799 | + | house_id = (_house ? _house->getID() : 0); | |
| 800 | + | } | |
| 801 | + | ||
| 802 | + | void Tile::setHouseID(uint32_t newHouseId) { | |
| 803 | + | house_id = newHouseId; | |
| 804 | + | } | |
| 805 | + | ||
| 806 | + | bool Tile::isTownExit(Map& map) const { | |
| 807 | + | return location->getTownCount() > 0; | |
| 808 | + | } | |
| 809 | + | ||
| 810 | + | void Tile::addHouseExit(House* h) { | |
| 811 | + | if (!h) { | |
| 812 | + | return; | |
| 813 | + | } | |
| 814 | + | HouseExitList* house_exits = location->createHouseExits(); | |
| 815 | + | house_exits->push_back(h->getID()); | |
| 816 | + | } | |
| 817 | + | ||
| 818 | + | void Tile::removeHouseExit(House* h) { | |
| 819 | + | if (!h) { | |
| 820 | + | return; | |
| 821 | + | } | |
| 822 | + | ||
| 823 | + | HouseExitList* house_exits = location->getHouseExits(); | |
| 824 | + | if (!house_exits) { | |
| 825 | + | return; | |
| 826 | + | } | |
| 827 | + | ||
| 828 | + | for (std::vector<uint32_t>::iterator it = house_exits->begin(); it != house_exits->end(); ++it) { | |
| 829 | + | if (*it == h->getID()) { | |
| 830 | + | house_exits->erase(it); | |
| 831 | + | return; | |
| 832 | + | } | |
| 833 | + | } | |
| 834 | + | } |
| @@ -0,0 +1,383 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #ifndef RME_TILE_H | |
| 19 | + | #define RME_TILE_H | |
| 20 | + | ||
| 21 | + | #include "position.h" | |
| 22 | + | #include "item.h" | |
| 23 | + | #include "map_region.h" | |
| 24 | + | #include <unordered_set> | |
| 25 | + | ||
| 26 | + | enum { | |
| 27 | + | TILESTATE_NONE = 0x0000, | |
| 28 | + | TILESTATE_PROTECTIONZONE = 0x0001, | |
| 29 | + | TILESTATE_DEPRECATED = 0x0002, // Reserved | |
| 30 | + | TILESTATE_NOPVP = 0x0004, | |
| 31 | + | TILESTATE_NOLOGOUT = 0x0008, | |
| 32 | + | TILESTATE_PVPZONE = 0x0010, | |
| 33 | + | TILESTATE_REFRESH = 0x0020, | |
| 34 | + | TILESTATE_ZONE_BRUSH = 0x0040, | |
| 35 | + | // Internal | |
| 36 | + | TILESTATE_SELECTED = 0x0001, | |
| 37 | + | TILESTATE_UNIQUE = 0x0002, | |
| 38 | + | TILESTATE_BLOCKING = 0x0004, | |
| 39 | + | TILESTATE_OP_BORDER = 0x0008, // If this is true, gravel will be placed on the tile! | |
| 40 | + | TILESTATE_HAS_TABLE = 0x0010, | |
| 41 | + | TILESTATE_HAS_CARPET = 0x0020, | |
| 42 | + | TILESTATE_MODIFIED = 0x0040, | |
| 43 | + | }; | |
| 44 | + | ||
| 45 | + | enum : uint8_t { | |
| 46 | + | INVALID_MINIMAP_COLOR = 0xFF | |
| 47 | + | }; | |
| 48 | + | ||
| 49 | + | class Tile { | |
| 50 | + | public: // Members | |
| 51 | + | TileLocation* location; | |
| 52 | + | Item* ground; | |
| 53 | + | ItemVector items; | |
| 54 | + | Creature* creature; | |
| 55 | + | Spawn* spawn; | |
| 56 | + | uint32_t house_id; // House id for this tile (pointer not safe) | |
| 57 | + | ||
| 58 | + | public: | |
| 59 | + | // ALWAYS use this constructor if the Tile is EVER going to be placed on a map | |
| 60 | + | Tile(TileLocation& location); | |
| 61 | + | // Use this when the tile is only used internally by the editor (like in certain brushes) | |
| 62 | + | Tile(int x, int y, int z); | |
| 63 | + | ||
| 64 | + | ~Tile(); | |
| 65 | + | ||
| 66 | + | // Argument is a the map to allocate the tile from | |
| 67 | + | Tile* deepCopy(BaseMap& map); | |
| 68 | + | ||
| 69 | + | // The location of the tile | |
| 70 | + | // Stores state that remains between the tile being moved (like house exits) | |
| 71 | + | void setLocation(TileLocation* where) { | |
| 72 | + | location = where; | |
| 73 | + | } | |
| 74 | + | TileLocation* getLocation() { | |
| 75 | + | return location; | |
| 76 | + | } | |
| 77 | + | const TileLocation* getLocation() const { | |
| 78 | + | return location; | |
| 79 | + | } | |
| 80 | + | ||
| 81 | + | // Position of the tile | |
| 82 | + | Position getPosition() { | |
| 83 | + | return location->getPosition(); | |
| 84 | + | } | |
| 85 | + | const Position getPosition() const { | |
| 86 | + | return location->getPosition(); | |
| 87 | + | } | |
| 88 | + | int getX() const { | |
| 89 | + | return location->getPosition().x; | |
| 90 | + | } | |
| 91 | + | int getY() const { | |
| 92 | + | return location->getPosition().y; | |
| 93 | + | } | |
| 94 | + | int getZ() const { | |
| 95 | + | return location->getPosition().z; | |
| 96 | + | } | |
| 97 | + | ||
| 98 | + | public: // Functions | |
| 99 | + | // Absorb the other tile into this tile | |
| 100 | + | void merge(Tile* other); | |
| 101 | + | ||
| 102 | + | // Has tile been modified since the map was loaded/created? | |
| 103 | + | bool isModified() const { | |
| 104 | + | return testFlags(statflags, TILESTATE_MODIFIED); | |
| 105 | + | } | |
| 106 | + | void modify() { | |
| 107 | + | statflags |= TILESTATE_MODIFIED; | |
| 108 | + | } | |
| 109 | + | void unmodify() { | |
| 110 | + | statflags &= ~TILESTATE_MODIFIED; | |
| 111 | + | } | |
| 112 | + | ||
| 113 | + | // Get memory footprint size | |
| 114 | + | uint32_t memsize() const; | |
| 115 | + | // Get number of items on the tile | |
| 116 | + | bool empty() const { | |
| 117 | + | return size() == 0; | |
| 118 | + | } | |
| 119 | + | int size() const; | |
| 120 | + | ||
| 121 | + | // Blocking? | |
| 122 | + | bool isBlocking() const { | |
| 123 | + | return testFlags(statflags, TILESTATE_BLOCKING); | |
| 124 | + | } | |
| 125 | + | ||
| 126 | + | // PZ | |
| 127 | + | bool isPZ() const { | |
| 128 | + | return testFlags(mapflags, TILESTATE_PROTECTIONZONE); | |
| 129 | + | } | |
| 130 | + | void setPZ(bool pz) { | |
| 131 | + | if (pz) { | |
| 132 | + | mapflags |= TILESTATE_PROTECTIONZONE; | |
| 133 | + | } else { | |
| 134 | + | mapflags &= ~TILESTATE_PROTECTIONZONE; | |
| 135 | + | } | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | bool hasProperty(enum ITEMPROPERTY prop) const; | |
| 139 | + | ||
| 140 | + | int getIndexOf(Item* item) const; | |
| 141 | + | Item* getTopItem() const; // Returns the topmost item, or nullptr if the tile is empty | |
| 142 | + | Item* getItemAt(int index) const; | |
| 143 | + | void addItem(Item* item); | |
| 144 | + | ||
| 145 | + | void select(); | |
| 146 | + | void deselect(); | |
| 147 | + | // This selects borders too | |
| 148 | + | void selectGround(); | |
| 149 | + | void deselectGround(); | |
| 150 | + | ||
| 151 | + | bool isSelected() const { | |
| 152 | + | return testFlags(statflags, TILESTATE_SELECTED); | |
| 153 | + | } | |
| 154 | + | bool hasUniqueItem() const { | |
| 155 | + | return testFlags(statflags, TILESTATE_UNIQUE); | |
| 156 | + | } | |
| 157 | + | ||
| 158 | + | ItemVector popSelectedItems(bool ignoreTileSelected = false); | |
| 159 | + | ItemVector getSelectedItems(bool unzoomed = false); | |
| 160 | + | Item* getTopSelectedItem(); | |
| 161 | + | ||
| 162 | + | // Refresh internal flags (such as selected etc.) | |
| 163 | + | void update(); | |
| 164 | + | ||
| 165 | + | uint8_t getMiniMapColor() const; | |
| 166 | + | ||
| 167 | + | // Does this tile have ground? | |
| 168 | + | bool hasGround() const { | |
| 169 | + | return ground != nullptr; | |
| 170 | + | } | |
| 171 | + | bool hasBorders() const { | |
| 172 | + | return items.size() && items[0]->isBorder(); | |
| 173 | + | } | |
| 174 | + | ||
| 175 | + | // Get the border brush of this tile | |
| 176 | + | GroundBrush* getGroundBrush() const; | |
| 177 | + | ||
| 178 | + | // Remove all borders (for autoborder) | |
| 179 | + | void cleanBorders(); | |
| 180 | + | ||
| 181 | + | // Add a border item (added at the bottom of all items) | |
| 182 | + | void addBorderItem(Item* item); | |
| 183 | + | ||
| 184 | + | // Borderize this tile | |
| 185 | + | void borderize(BaseMap* parent); | |
| 186 | + | ||
| 187 | + | bool hasTable() const { | |
| 188 | + | return testFlags(statflags, TILESTATE_HAS_TABLE); | |
| 189 | + | } | |
| 190 | + | Item* getTable() const; | |
| 191 | + | ||
| 192 | + | bool hasCarpet() const { | |
| 193 | + | return testFlags(statflags, TILESTATE_HAS_CARPET); | |
| 194 | + | } | |
| 195 | + | Item* getCarpet() const; | |
| 196 | + | ||
| 197 | + | bool hasOptionalBorder() const { | |
| 198 | + | return testFlags(statflags, TILESTATE_OP_BORDER); | |
| 199 | + | } | |
| 200 | + | void setOptionalBorder(bool b) { | |
| 201 | + | if (b) { | |
| 202 | + | statflags |= TILESTATE_OP_BORDER; | |
| 203 | + | } else { | |
| 204 | + | statflags &= ~TILESTATE_OP_BORDER; | |
| 205 | + | } | |
| 206 | + | } | |
| 207 | + | ||
| 208 | + | // Get the (first) wall of this tile | |
| 209 | + | Item* getWall() const; | |
| 210 | + | bool hasWall() const; | |
| 211 | + | // Remove all walls from the tile (for autowall) (only of those belonging to the specified brush | |
| 212 | + | void cleanWalls(WallBrush* wb); | |
| 213 | + | // Remove all walls from the tile | |
| 214 | + | void cleanWalls(bool dontdelete = false); | |
| 215 | + | // Add a wall item (same as just addItem, but an additional check to verify that it is a wall) | |
| 216 | + | void addWallItem(Item* item); | |
| 217 | + | // Wallize (name sucks, I know) this tile | |
| 218 | + | void wallize(BaseMap* parent); | |
| 219 | + | // Remove all tables from this tile | |
| 220 | + | void cleanTables(bool dontdelete = false); | |
| 221 | + | // Tableize (name sucks even worse, I know) this tile | |
| 222 | + | void tableize(BaseMap* parent); | |
| 223 | + | // Carpetize (name sucks even worse than last one, I know) this tile | |
| 224 | + | void carpetize(BaseMap* parent); | |
| 225 | + | ||
| 226 | + | // Has to do with houses | |
| 227 | + | bool isHouseTile() const; | |
| 228 | + | uint32_t getHouseID() const; | |
| 229 | + | void setHouseID(uint32_t newHouseId); | |
| 230 | + | void addHouseExit(House* h); | |
| 231 | + | void removeHouseExit(House* h); | |
| 232 | + | bool isHouseExit() const; | |
| 233 | + | bool isTownExit(Map& map) const; | |
| 234 | + | const HouseExitList* getHouseExits() const; | |
| 235 | + | HouseExitList* getHouseExits(); | |
| 236 | + | bool hasHouseExit(uint32_t exit) const; | |
| 237 | + | void setHouse(House* house); | |
| 238 | + | House* getHouse() const; | |
| 239 | + | ||
| 240 | + | // Mapflags (PZ, PVPZONE etc.) | |
| 241 | + | void addZoneId(uint16_t _zoneId); | |
| 242 | + | void removeZoneId(uint16_t _zoneId); | |
| 243 | + | void clearZoneId(); | |
| 244 | + | void setZoneIds(Tile* tile); | |
| 245 | + | const std::vector<uint16_t>& getZoneIds() const; | |
| 246 | + | uint16_t getZoneId() const; | |
| 247 | + | ||
| 248 | + | void setMapFlags(uint16_t _flags); | |
| 249 | + | void unsetMapFlags(uint16_t _flags); | |
| 250 | + | uint16_t getMapFlags() const; | |
| 251 | + | ||
| 252 | + | // Statflags (You really ought not to touch this) | |
| 253 | + | void setStatFlags(uint16_t _flags); | |
| 254 | + | void unsetStatFlags(uint16_t _flags); | |
| 255 | + | uint16_t getStatFlags() const; | |
| 256 | + | ||
| 257 | + | protected: | |
| 258 | + | union { | |
| 259 | + | struct { | |
| 260 | + | uint16_t mapflags; | |
| 261 | + | uint16_t statflags; | |
| 262 | + | }; | |
| 263 | + | uint32_t flags; | |
| 264 | + | }; | |
| 265 | + | ||
| 266 | + | std::vector<uint16_t> zoneIds; | |
| 267 | + | ||
| 268 | + | private: | |
| 269 | + | uint8_t minimapColor; | |
| 270 | + | ||
| 271 | + | Tile(const Tile& tile); // No copy | |
| 272 | + | Tile& operator=(const Tile& i); // Can't copy | |
| 273 | + | Tile& operator==(const Tile& i); // Can't compare | |
| 274 | + | }; | |
| 275 | + | ||
| 276 | + | bool tilePositionLessThan(const Tile* a, const Tile* b); | |
| 277 | + | // This sorts them by draw order | |
| 278 | + | bool tilePositionVisualLessThan(const Tile* a, const Tile* b); | |
| 279 | + | ||
| 280 | + | typedef std::vector<Tile*> TileVector; | |
| 281 | + | typedef std::unordered_set<Tile*> TileSet; | |
| 282 | + | typedef std::list<Tile*> TileList; | |
| 283 | + | ||
| 284 | + | inline bool Tile::hasWall() const { | |
| 285 | + | return getWall() != nullptr; | |
| 286 | + | } | |
| 287 | + | ||
| 288 | + | inline bool Tile::isHouseTile() const { | |
| 289 | + | return house_id != 0; | |
| 290 | + | } | |
| 291 | + | ||
| 292 | + | inline uint32_t Tile::getHouseID() const { | |
| 293 | + | return house_id; | |
| 294 | + | } | |
| 295 | + | ||
| 296 | + | inline HouseExitList* Tile::getHouseExits() { | |
| 297 | + | return location->getHouseExits(); | |
| 298 | + | } | |
| 299 | + | ||
| 300 | + | inline const HouseExitList* Tile::getHouseExits() const { | |
| 301 | + | return location->getHouseExits(); | |
| 302 | + | } | |
| 303 | + | ||
| 304 | + | inline bool Tile::isHouseExit() const { | |
| 305 | + | const HouseExitList* house_exits = getHouseExits(); | |
| 306 | + | if (house_exits) { | |
| 307 | + | return !house_exits->empty(); | |
| 308 | + | } | |
| 309 | + | return false; | |
| 310 | + | } | |
| 311 | + | ||
| 312 | + | inline bool Tile::hasHouseExit(uint32_t exit) const { | |
| 313 | + | const HouseExitList* house_exits = getHouseExits(); | |
| 314 | + | if (house_exits) { | |
| 315 | + | for (HouseExitList::const_iterator iter = house_exits->begin(); iter != house_exits->end(); ++iter) { | |
| 316 | + | if (*iter == exit) { | |
| 317 | + | return true; | |
| 318 | + | } | |
| 319 | + | } | |
| 320 | + | } | |
| 321 | + | return false; | |
| 322 | + | } | |
| 323 | + | ||
| 324 | + | inline void Tile::setMapFlags(uint16_t _flags) { | |
| 325 | + | mapflags = _flags | mapflags; | |
| 326 | + | } | |
| 327 | + | ||
| 328 | + | inline void Tile::unsetMapFlags(uint16_t _flags) { | |
| 329 | + | mapflags &= ~_flags; | |
| 330 | + | } | |
| 331 | + | ||
| 332 | + | inline uint16_t Tile::getMapFlags() const { | |
| 333 | + | return mapflags; | |
| 334 | + | } | |
| 335 | + | ||
| 336 | + | inline void Tile::setStatFlags(uint16_t _flags) { | |
| 337 | + | statflags = _flags | statflags; | |
| 338 | + | } | |
| 339 | + | ||
| 340 | + | inline void Tile::unsetStatFlags(uint16_t _flags) { | |
| 341 | + | statflags &= ~_flags; | |
| 342 | + | } | |
| 343 | + | ||
| 344 | + | inline uint16_t Tile::getStatFlags() const { | |
| 345 | + | return statflags; | |
| 346 | + | } | |
| 347 | + | ||
| 348 | + | inline void Tile::addZoneId(uint16_t _zoneId) { | |
| 349 | + | if (std::find(zoneIds.begin(), zoneIds.end(), _zoneId) == zoneIds.end()) { | |
| 350 | + | zoneIds.push_back(_zoneId); | |
| 351 | + | } | |
| 352 | + | } | |
| 353 | + | ||
| 354 | + | inline void Tile::clearZoneId() { | |
| 355 | + | zoneIds.clear(); | |
| 356 | + | } | |
| 357 | + | ||
| 358 | + | inline void Tile::setZoneIds(Tile* tile) { | |
| 359 | + | zoneIds.clear(); | |
| 360 | + | zoneIds.assign(tile->getZoneIds().begin(), tile->getZoneIds().end()); | |
| 361 | + | } | |
| 362 | + | ||
| 363 | + | inline void Tile::removeZoneId(uint16_t _zoneId) { | |
| 364 | + | const auto& itZone = std::find(zoneIds.begin(), zoneIds.end(), _zoneId); | |
| 365 | + | if (itZone != zoneIds.end()) { | |
| 366 | + | zoneIds.erase(itZone); | |
| 367 | + | } | |
| 368 | + | } | |
| 369 | + | ||
| 370 | + | inline const std::vector<uint16_t>& Tile::getZoneIds() const { | |
| 371 | + | return zoneIds; | |
| 372 | + | } | |
| 373 | + | ||
| 374 | + | inline uint16_t Tile::getZoneId() const { | |
| 375 | + | if (zoneIds.empty()) { | |
| 376 | + | return 0; | |
| 377 | + | } | |
| 378 | + | ||
| 379 | + | return zoneIds.front(); | |
| 380 | + | } | |
| 381 | + | ||
| 382 | + | ||
| 383 | + | #endif |
| @@ -0,0 +1,273 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #include "main.h" | |
| 19 | + | ||
| 20 | + | #include "tileset.h" | |
| 21 | + | #include "creatures.h" | |
| 22 | + | #include "creature_brush.h" | |
| 23 | + | #include "items.h" | |
| 24 | + | #include "raw_brush.h" | |
| 25 | + | ||
| 26 | + | Tileset::Tileset(Brushes& brushes, const std::string& name) : | |
| 27 | + | name(name), | |
| 28 | + | brushes(brushes) { | |
| 29 | + | //// | |
| 30 | + | } | |
| 31 | + | ||
| 32 | + | Tileset::~Tileset() { | |
| 33 | + | for (TilesetCategoryArray::iterator iter = categories.begin(); iter != categories.end(); ++iter) { | |
| 34 | + | delete *iter; | |
| 35 | + | } | |
| 36 | + | } | |
| 37 | + | ||
| 38 | + | void Tileset::clear() { | |
| 39 | + | for (TilesetCategoryArray::iterator iter = categories.begin(); iter != categories.end(); ++iter) { | |
| 40 | + | (*iter)->brushlist.clear(); | |
| 41 | + | } | |
| 42 | + | } | |
| 43 | + | ||
| 44 | + | bool Tileset::containsBrush(Brush* brush) const { | |
| 45 | + | for (TilesetCategoryArray::const_iterator iter = categories.begin(); iter != categories.end(); ++iter) { | |
| 46 | + | if ((*iter)->containsBrush(brush)) { | |
| 47 | + | return true; | |
| 48 | + | } | |
| 49 | + | } | |
| 50 | + | ||
| 51 | + | return false; | |
| 52 | + | } | |
| 53 | + | ||
| 54 | + | TilesetCategory* Tileset::getCategory(TilesetCategoryType type) { | |
| 55 | + | ASSERT(type >= TILESET_UNKNOWN && type <= TILESET_HOUSE); | |
| 56 | + | for (TilesetCategoryArray::iterator iter = categories.begin(); iter != categories.end(); ++iter) { | |
| 57 | + | if ((*iter)->getType() == type) { | |
| 58 | + | return *iter; | |
| 59 | + | } | |
| 60 | + | } | |
| 61 | + | TilesetCategory* tsc = newd TilesetCategory(*this, type); | |
| 62 | + | categories.push_back(tsc); | |
| 63 | + | return tsc; | |
| 64 | + | } | |
| 65 | + | ||
| 66 | + | bool TilesetCategory::containsBrush(Brush* brush) const { | |
| 67 | + | for (std::vector<Brush*>::const_iterator iter = brushlist.begin(); iter != brushlist.end(); ++iter) { | |
| 68 | + | if (*iter == brush) { | |
| 69 | + | return true; | |
| 70 | + | } | |
| 71 | + | } | |
| 72 | + | ||
| 73 | + | return false; | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | const TilesetCategory* Tileset::getCategory(TilesetCategoryType type) const { | |
| 77 | + | ASSERT(type >= TILESET_UNKNOWN && type <= TILESET_HOUSE); | |
| 78 | + | for (TilesetCategoryArray::const_iterator iter = categories.begin(); iter != categories.end(); ++iter) { | |
| 79 | + | if ((*iter)->getType() == type) { | |
| 80 | + | return *iter; | |
| 81 | + | } | |
| 82 | + | } | |
| 83 | + | return nullptr; | |
| 84 | + | } | |
| 85 | + | ||
| 86 | + | void Tileset::loadCategory(pugi::xml_node node, wxArrayString& warnings) { | |
| 87 | + | TilesetCategory* category = nullptr; | |
| 88 | + | TilesetCategory* subCategory = nullptr; | |
| 89 | + | ||
| 90 | + | const std::string& nodeName = as_lower_str(node.name()); | |
| 91 | + | if (nodeName == "terrain") { | |
| 92 | + | category = getCategory(TILESET_TERRAIN); | |
| 93 | + | } else if (nodeName == "collections") { | |
| 94 | + | category = getCategory(TILESET_COLLECTION); | |
| 95 | + | } else if (nodeName == "doodad") { | |
| 96 | + | category = getCategory(TILESET_DOODAD); | |
| 97 | + | } else if (nodeName == "items") { | |
| 98 | + | category = getCategory(TILESET_ITEM); | |
| 99 | + | } else if (nodeName == "raw") { | |
| 100 | + | category = getCategory(TILESET_RAW); | |
| 101 | + | } else if (nodeName == "terrain_and_raw") { | |
| 102 | + | category = getCategory(TILESET_TERRAIN); | |
| 103 | + | subCategory = getCategory(TILESET_RAW); | |
| 104 | + | } else if (nodeName == "collections_and_raw") { | |
| 105 | + | category = getCategory(TILESET_COLLECTION); | |
| 106 | + | subCategory = getCategory(TILESET_RAW); | |
| 107 | + | } else if (nodeName == "collections_and_terrain") { | |
| 108 | + | category = getCategory(TILESET_COLLECTION); | |
| 109 | + | subCategory = getCategory(TILESET_TERRAIN); | |
| 110 | + | } else if (nodeName == "doodad_and_raw") { | |
| 111 | + | category = getCategory(TILESET_DOODAD); | |
| 112 | + | subCategory = getCategory(TILESET_RAW); | |
| 113 | + | } else if (nodeName == "items_and_raw") { | |
| 114 | + | category = getCategory(TILESET_ITEM); | |
| 115 | + | subCategory = getCategory(TILESET_RAW); | |
| 116 | + | } else if (nodeName == "creatures") { | |
| 117 | + | category = getCategory(TILESET_CREATURE); | |
| 118 | + | for (pugi::xml_node brushNode = node.first_child(); brushNode; brushNode = brushNode.next_sibling()) { | |
| 119 | + | const std::string& brushName = as_lower_str(brushNode.name()); | |
| 120 | + | if (brushName != "creature") { | |
| 121 | + | continue; | |
| 122 | + | } | |
| 123 | + | ||
| 124 | + | pugi::xml_attribute attribute; | |
| 125 | + | if (!(attribute = brushNode.attribute("name"))) { | |
| 126 | + | warnings.push_back("Couldn't read creature name tag of creature tileset"); | |
| 127 | + | continue; | |
| 128 | + | } | |
| 129 | + | ||
| 130 | + | const std::string& creatureName = attribute.as_string(); | |
| 131 | + | CreatureType* ctype = g_creatures[creatureName]; | |
| 132 | + | if (ctype) { | |
| 133 | + | CreatureBrush* brush; | |
| 134 | + | if (ctype->brush) { | |
| 135 | + | brush = ctype->brush; | |
| 136 | + | } else { | |
| 137 | + | brush = ctype->brush = newd CreatureBrush(ctype); | |
| 138 | + | brushes.addBrush(brush); | |
| 139 | + | } | |
| 140 | + | brush->flagAsVisible(); | |
| 141 | + | category->brushlist.push_back(brush); | |
| 142 | + | } else { | |
| 143 | + | warnings.push_back(wxString("Unknown creature type \"") << wxstr(creatureName) << "\""); | |
| 144 | + | } | |
| 145 | + | } | |
| 146 | + | } | |
| 147 | + | ||
| 148 | + | if (!category) { | |
| 149 | + | return; | |
| 150 | + | } | |
| 151 | + | ||
| 152 | + | for (pugi::xml_node brushNode = node.first_child(); brushNode; brushNode = brushNode.next_sibling()) { | |
| 153 | + | category->loadBrush(brushNode, warnings); | |
| 154 | + | if (subCategory) { | |
| 155 | + | subCategory->loadBrush(brushNode, warnings); | |
| 156 | + | } | |
| 157 | + | } | |
| 158 | + | } | |
| 159 | + | ||
| 160 | + | // | |
| 161 | + | ||
| 162 | + | TilesetCategory::TilesetCategory(Tileset& parent, TilesetCategoryType type) : | |
| 163 | + | type(type), tileset(parent) { | |
| 164 | + | ASSERT(type >= TILESET_UNKNOWN && type <= TILESET_HOUSE); | |
| 165 | + | } | |
| 166 | + | ||
| 167 | + | TilesetCategory::~TilesetCategory() { | |
| 168 | + | ASSERT(type >= TILESET_UNKNOWN && type <= TILESET_HOUSE); | |
| 169 | + | } | |
| 170 | + | ||
| 171 | + | bool TilesetCategory::isTrivial() const { | |
| 172 | + | return (type == TILESET_ITEM) || (type == TILESET_RAW); | |
| 173 | + | } | |
| 174 | + | ||
| 175 | + | void TilesetCategory::loadBrush(pugi::xml_node node, wxArrayString& warnings) { | |
| 176 | + | pugi::xml_attribute attribute; | |
| 177 | + | ||
| 178 | + | std::string brushName = node.attribute("after").as_string(); | |
| 179 | + | if ((attribute = node.attribute("afteritem"))) { | |
| 180 | + | ItemType& it = g_items[attribute.as_ushort()]; | |
| 181 | + | if (it.id != 0) { | |
| 182 | + | brushName = it.raw_brush ? it.raw_brush->getName() : std::string(); | |
| 183 | + | } | |
| 184 | + | } | |
| 185 | + | ||
| 186 | + | const std::string& nodeName = as_lower_str(node.name()); | |
| 187 | + | if (nodeName == "brush") { | |
| 188 | + | if (!(attribute = node.attribute("name"))) { | |
| 189 | + | return; | |
| 190 | + | } | |
| 191 | + | ||
| 192 | + | Brush* brush = tileset.brushes.getBrush(attribute.as_string()); | |
| 193 | + | if (brush) { | |
| 194 | + | auto insertPosition = brushlist.end(); | |
| 195 | + | if (!brushName.empty()) { | |
| 196 | + | for (auto itt = brushlist.begin(); itt != brushlist.end(); ++itt) { | |
| 197 | + | if ((*itt)->getName() == brushName) { | |
| 198 | + | insertPosition = ++itt; | |
| 199 | + | break; | |
| 200 | + | } | |
| 201 | + | } | |
| 202 | + | } | |
| 203 | + | brush->flagAsVisible(); | |
| 204 | + | brushlist.insert(insertPosition, brush); | |
| 205 | + | ||
| 206 | + | if (type == TILESET_COLLECTION) { | |
| 207 | + | brush->setCollection(); | |
| 208 | + | } | |
| 209 | + | } else { | |
| 210 | + | warnings.push_back("Brush \"" + wxString(attribute.as_string(), wxConvUTF8) + "\" doesn't exist."); | |
| 211 | + | } | |
| 212 | + | } else if (nodeName == "item") { | |
| 213 | + | uint16_t fromId = 0, toId = 0; | |
| 214 | + | if (!(attribute = node.attribute("id"))) { | |
| 215 | + | if (!(attribute = node.attribute("fromid"))) { | |
| 216 | + | warnings.push_back("Couldn't read raw ids."); | |
| 217 | + | } | |
| 218 | + | toId = node.attribute("toid").as_ushort(); | |
| 219 | + | } | |
| 220 | + | ||
| 221 | + | fromId = attribute.as_ushort(); | |
| 222 | + | toId = std::max<uint16_t>(fromId, toId); | |
| 223 | + | ||
| 224 | + | std::vector<Brush*> tempBrushVector; | |
| 225 | + | for (uint16_t id = fromId; id <= toId; ++id) { | |
| 226 | + | ItemType& it = g_items[id]; | |
| 227 | + | if (it.id == 0) { | |
| 228 | + | warnings.push_back(wxString::Format("Tileset: %s, Brush: %s, Previous %d, From: %d, To: %d", wxstr(tileset.name), wxstr(brushName), tileset.previousId, fromId, toId)); | |
| 229 | + | warnings.push_back("Unknown item id #" + std::to_string(id) + "."); | |
| 230 | + | continue; | |
| 231 | + | } | |
| 232 | + | ||
| 233 | + | RAWBrush* brush; | |
| 234 | + | if (it.raw_brush) { | |
| 235 | + | brush = it.raw_brush; | |
| 236 | + | if (type == TILESET_COLLECTION) { | |
| 237 | + | it.raw_brush->setCollection(); | |
| 238 | + | } | |
| 239 | + | } else { | |
| 240 | + | brush = it.raw_brush = newd RAWBrush(it.id); | |
| 241 | + | it.has_raw = true; | |
| 242 | + | if (type == TILESET_COLLECTION) { | |
| 243 | + | it.raw_brush->setCollection(); | |
| 244 | + | } | |
| 245 | + | tileset.brushes.addBrush(brush); // This will take care of cleaning up afterwards | |
| 246 | + | } | |
| 247 | + | ||
| 248 | + | if (type == TILESET_COLLECTION) { | |
| 249 | + | it.collection_brush = brush; | |
| 250 | + | } | |
| 251 | + | ||
| 252 | + | if (it.doodad_brush == nullptr && !isTrivial()) { | |
| 253 | + | it.doodad_brush = brush; | |
| 254 | + | } | |
| 255 | + | ||
| 256 | + | brush->flagAsVisible(); | |
| 257 | + | tempBrushVector.push_back(brush); | |
| 258 | + | ||
| 259 | + | tileset.previousId = id; | |
| 260 | + | } | |
| 261 | + | ||
| 262 | + | auto insertPosition = brushlist.end(); | |
| 263 | + | if (!brushName.empty()) { | |
| 264 | + | for (auto itt = brushlist.begin(); itt != brushlist.end(); ++itt) { | |
| 265 | + | if ((*itt)->getName() == brushName) { | |
| 266 | + | insertPosition = ++itt; | |
| 267 | + | break; | |
| 268 | + | } | |
| 269 | + | } | |
| 270 | + | } | |
| 271 | + | brushlist.insert(insertPosition, tempBrushVector.begin(), tempBrushVector.end()); | |
| 272 | + | } | |
| 273 | + | } |
| @@ -0,0 +1,97 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #ifndef RME_TILESET_H_ | |
| 19 | + | #define RME_TILESET_H_ | |
| 20 | + | ||
| 21 | + | class Brushes; | |
| 22 | + | ||
| 23 | + | enum TilesetCategoryType { | |
| 24 | + | TILESET_UNKNOWN, | |
| 25 | + | TILESET_TERRAIN, | |
| 26 | + | TILESET_CREATURE, | |
| 27 | + | TILESET_DOODAD, | |
| 28 | + | TILESET_COLLECTION, | |
| 29 | + | TILESET_ITEM, | |
| 30 | + | TILESET_RAW, | |
| 31 | + | TILESET_HOUSE, | |
| 32 | + | TILESET_WAYPOINT, | |
| 33 | + | }; | |
| 34 | + | ||
| 35 | + | class TilesetCategory { | |
| 36 | + | public: | |
| 37 | + | TilesetCategory(Tileset& parent, TilesetCategoryType type); | |
| 38 | + | ~TilesetCategory(); | |
| 39 | + | ||
| 40 | + | bool isTrivial() const; | |
| 41 | + | TilesetCategoryType getType() const { | |
| 42 | + | return type; | |
| 43 | + | } | |
| 44 | + | size_t size() const { | |
| 45 | + | return brushlist.size(); | |
| 46 | + | } | |
| 47 | + | ||
| 48 | + | void loadBrush(pugi::xml_node node, wxArrayString& warnings); | |
| 49 | + | void clear(); | |
| 50 | + | ||
| 51 | + | bool containsBrush(Brush* brush) const; | |
| 52 | + | ||
| 53 | + | protected: | |
| 54 | + | TilesetCategoryType type; | |
| 55 | + | ||
| 56 | + | public: | |
| 57 | + | std::vector<Brush*> brushlist; | |
| 58 | + | Tileset& tileset; | |
| 59 | + | ||
| 60 | + | private: | |
| 61 | + | TilesetCategory(const TilesetCategory&); | |
| 62 | + | TilesetCategory operator=(const TilesetCategory&); | |
| 63 | + | }; | |
| 64 | + | ||
| 65 | + | typedef std::vector<TilesetCategory*> TilesetCategoryArray; | |
| 66 | + | ||
| 67 | + | class Tileset { | |
| 68 | + | public: | |
| 69 | + | Tileset(Brushes& brushes, const std::string& name); | |
| 70 | + | ~Tileset(); | |
| 71 | + | ||
| 72 | + | TilesetCategory* getCategory(TilesetCategoryType type); | |
| 73 | + | const TilesetCategory* getCategory(TilesetCategoryType type) const; | |
| 74 | + | ||
| 75 | + | void loadCategory(pugi::xml_node node, wxArrayString& warnings); | |
| 76 | + | void clear(); | |
| 77 | + | ||
| 78 | + | bool containsBrush(Brush* brush) const; | |
| 79 | + | ||
| 80 | + | public: | |
| 81 | + | std::string name; | |
| 82 | + | int16_t previousId; | |
| 83 | + | TilesetCategoryArray categories; | |
| 84 | + | ||
| 85 | + | protected: | |
| 86 | + | Brushes& brushes; | |
| 87 | + | ||
| 88 | + | protected: | |
| 89 | + | Tileset(const Tileset&); | |
| 90 | + | Tileset operator=(const Tileset&); | |
| 91 | + | ||
| 92 | + | friend class TilesetCategory; | |
| 93 | + | }; | |
| 94 | + | ||
| 95 | + | typedef std::map<std::string, Tileset*> TilesetContainer; | |
| 96 | + | ||
| 97 | + | #endif |
| @@ -0,0 +1,126 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #include "main.h" | |
| 19 | + | ||
| 20 | + | #include <wx/grid.h> | |
| 21 | + | ||
| 22 | + | #include "tile.h" | |
| 23 | + | #include "item.h" | |
| 24 | + | #include "complexitem.h" | |
| 25 | + | #include "town.h" | |
| 26 | + | #include "house.h" | |
| 27 | + | #include "map.h" | |
| 28 | + | #include "editor.h" | |
| 29 | + | #include "creature.h" | |
| 30 | + | #include "materials.h" | |
| 31 | + | #include "tileset.h" | |
| 32 | + | ||
| 33 | + | #include "gui.h" | |
| 34 | + | #include "application.h" | |
| 35 | + | #include "tileset_window.h" | |
| 36 | + | #include "container_properties_window.h" | |
| 37 | + | ||
| 38 | + | // ============================================================================ | |
| 39 | + | // Tileset Window | |
| 40 | + | ||
| 41 | + | BEGIN_EVENT_TABLE(TilesetWindow, wxDialog) | |
| 42 | + | EVT_BUTTON(wxID_OK, TilesetWindow::OnClickOK) | |
| 43 | + | EVT_BUTTON(wxID_CANCEL, TilesetWindow::OnClickCancel) | |
| 44 | + | END_EVENT_TABLE() | |
| 45 | + | ||
| 46 | + | static constexpr int OUTFIT_COLOR_MAX = 133; | |
| 47 | + | ||
| 48 | + | TilesetWindow::TilesetWindow(wxWindow* win_parent, const Map* map, const Tile* tile_parent, Item* item, wxPoint pos) : | |
| 49 | + | ObjectPropertiesWindowBase(win_parent, "Move to Tileset", map, tile_parent, item, pos), | |
| 50 | + | palette_field(nullptr), | |
| 51 | + | tileset_field(nullptr) { | |
| 52 | + | ASSERT(edit_item); | |
| 53 | + | ||
| 54 | + | wxSizer* topsizer = newd wxBoxSizer(wxVERTICAL); | |
| 55 | + | wxString description = "Move to Tileset"; | |
| 56 | + | ||
| 57 | + | wxSizer* boxsizer = newd wxStaticBoxSizer(wxVERTICAL, this, description); | |
| 58 | + | ||
| 59 | + | wxFlexGridSizer* subsizer = newd wxFlexGridSizer(2, 10, 10); | |
| 60 | + | subsizer->AddGrowableCol(1); | |
| 61 | + | ||
| 62 | + | subsizer->Add(newd wxStaticText(this, wxID_ANY, "ID " + i2ws(item->getID()))); | |
| 63 | + | subsizer->Add(newd wxStaticText(this, wxID_ANY, "\"" + wxstr(item->getName()) + "\"")); | |
| 64 | + | ||
| 65 | + | subsizer->Add(newd wxStaticText(this, wxID_ANY, "Palette")); | |
| 66 | + | palette_field = newd wxChoice(this, wxID_ANY); | |
| 67 | + | ||
| 68 | + | palette_field->Append("Terrain", newd int(TILESET_TERRAIN)); | |
| 69 | + | palette_field->Append("Collections", newd int(TILESET_COLLECTION)); | |
| 70 | + | palette_field->Append("Doodad", newd int(TILESET_DOODAD)); | |
| 71 | + | palette_field->Append("Item", newd int(TILESET_ITEM)); | |
| 72 | + | palette_field->Append("Raw", newd int(TILESET_RAW)); | |
| 73 | + | palette_field->SetSelection(3); | |
| 74 | + | ||
| 75 | + | palette_field->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(TilesetWindow::OnChangePalette), NULL, this); | |
| 76 | + | subsizer->Add(palette_field, wxSizerFlags(1).Expand()); | |
| 77 | + | ||
| 78 | + | subsizer->Add(newd wxStaticText(this, wxID_ANY, "Tileset")); | |
| 79 | + | tileset_field = newd wxChoice(this, wxID_ANY); | |
| 80 | + | ||
| 81 | + | for (TilesetContainer::iterator iter = g_materials.tilesets.begin(); iter != g_materials.tilesets.end(); ++iter) { | |
| 82 | + | tileset_field->Append(wxstr(iter->second->name), newd std::string(iter->second->name)); | |
| 83 | + | } | |
| 84 | + | tileset_field->SetSelection(0); | |
| 85 | + | subsizer->Add(tileset_field, wxSizerFlags(1).Expand()); | |
| 86 | + | ||
| 87 | + | boxsizer->Add(subsizer, wxSizerFlags(1).Expand()); | |
| 88 | + | ||
| 89 | + | topsizer->Add(boxsizer, wxSizerFlags(0).Expand().Border(wxLEFT | wxRIGHT, 20)); | |
| 90 | + | ||
| 91 | + | wxSizer* subsizer_ = newd wxBoxSizer(wxHORIZONTAL); | |
| 92 | + | subsizer_->Add(newd wxButton(this, wxID_OK, "OK"), wxSizerFlags(1).Center().Border(wxTOP | wxBOTTOM, 10)); | |
| 93 | + | subsizer_->Add(newd wxButton(this, wxID_CANCEL, "Cancel"), wxSizerFlags(1).Center().Border(wxTOP | wxBOTTOM, 10)); | |
| 94 | + | topsizer->Add(subsizer_, wxSizerFlags(0).Center().Border(wxLEFT | wxRIGHT, 20)); | |
| 95 | + | ||
| 96 | + | SetSizerAndFit(topsizer); | |
| 97 | + | Centre(wxBOTH); | |
| 98 | + | } | |
| 99 | + | ||
| 100 | + | void TilesetWindow::OnChangePalette(wxCommandEvent& WXUNUSED(event)) { | |
| 101 | + | tileset_field->Clear(); | |
| 102 | + | ||
| 103 | + | for (TilesetContainer::iterator iter = g_materials.tilesets.begin(); iter != g_materials.tilesets.end(); ++iter) { | |
| 104 | + | if (iter->second->getCategory(TilesetCategoryType(*static_cast<int*>(palette_field->GetClientData(palette_field->GetSelection()))))->brushlist.size() > 0) { | |
| 105 | + | tileset_field->Append(wxstr(iter->second->name), newd std::string(iter->second->name)); | |
| 106 | + | } | |
| 107 | + | } | |
| 108 | + | ||
| 109 | + | tileset_field->SetSelection(0); | |
| 110 | + | } | |
| 111 | + | ||
| 112 | + | void TilesetWindow::OnClickOK(wxCommandEvent& WXUNUSED(event)) { | |
| 113 | + | if (edit_item) { | |
| 114 | + | TilesetCategoryType categoryType = TilesetCategoryType(*reinterpret_cast<int*>(palette_field->GetClientData(palette_field->GetSelection()))); | |
| 115 | + | std::string tilesetName = *static_cast<std::string*>(tileset_field->GetClientData(tileset_field->GetSelection())); | |
| 116 | + | ||
| 117 | + | g_materials.addToTileset(tilesetName, edit_item->getID(), categoryType); | |
| 118 | + | g_gui.PopupDialog("Added to Tileset", "'" + edit_item->getName() + "' has been added to tileset '" + tilesetName + "' of palette '" + palette_field->GetStringSelection() + "'", wxOK); | |
| 119 | + | } | |
| 120 | + | EndModal(1); | |
| 121 | + | } | |
| 122 | + | ||
| 123 | + | void TilesetWindow::OnClickCancel(wxCommandEvent& WXUNUSED(event)) { | |
| 124 | + | // Just close this window | |
| 125 | + | EndModal(0); | |
| 126 | + | } |
| @@ -0,0 +1,45 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #ifndef RME_TILESET_WINDOW_H_ | |
| 19 | + | #define RME_TILESET_WINDOW_H_ | |
| 20 | + | ||
| 21 | + | #include "main.h" | |
| 22 | + | ||
| 23 | + | #include "common_windows.h" | |
| 24 | + | ||
| 25 | + | class ContainerItemButton; | |
| 26 | + | class ContainerItemPopupMenu; | |
| 27 | + | ||
| 28 | + | class TilesetWindow : public ObjectPropertiesWindowBase { | |
| 29 | + | public: | |
| 30 | + | TilesetWindow(wxWindow* parent, const Map* map, const Tile* tile, Item* item, wxPoint = wxDefaultPosition); | |
| 31 | + | ||
| 32 | + | void OnChangePalette(wxCommandEvent& event); | |
| 33 | + | ||
| 34 | + | void OnClickOK(wxCommandEvent&); | |
| 35 | + | void OnClickCancel(wxCommandEvent&); | |
| 36 | + | ||
| 37 | + | protected: | |
| 38 | + | // tileset | |
| 39 | + | wxChoice* palette_field; | |
| 40 | + | wxChoice* tileset_field; | |
| 41 | + | ||
| 42 | + | DECLARE_EVENT_TABLE(); | |
| 43 | + | }; | |
| 44 | + | ||
| 45 | + | #endif |
| @@ -0,0 +1,80 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #include "main.h" | |
| 19 | + | ||
| 20 | + | #include "town.h" | |
| 21 | + | ||
| 22 | + | #include "map.h" | |
| 23 | + | #include "tile.h" | |
| 24 | + | ||
| 25 | + | Towns::Towns() { | |
| 26 | + | //// | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | Towns::~Towns() { | |
| 30 | + | clear(); | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | void Towns::clear() { | |
| 34 | + | TownMap::const_iterator it = begin(); | |
| 35 | + | while (it != end()) { | |
| 36 | + | delete it->second; | |
| 37 | + | ++it; | |
| 38 | + | } | |
| 39 | + | towns.clear(); | |
| 40 | + | } | |
| 41 | + | ||
| 42 | + | bool Towns::addTown(Town* town) { | |
| 43 | + | TownMap::iterator it = find(town->getID()); | |
| 44 | + | if (it != end()) { | |
| 45 | + | return false; | |
| 46 | + | } | |
| 47 | + | towns[town->getID()] = town; | |
| 48 | + | return true; | |
| 49 | + | } | |
| 50 | + | ||
| 51 | + | uint32_t Towns::getEmptyID() { | |
| 52 | + | uint32_t empty = 0; | |
| 53 | + | for (TownMap::iterator it = begin(); it != end(); ++it) { | |
| 54 | + | if (it->second->getID() > empty) { | |
| 55 | + | empty = it->second->getID(); | |
| 56 | + | } | |
| 57 | + | } | |
| 58 | + | return empty + 1; | |
| 59 | + | } | |
| 60 | + | ||
| 61 | + | Town* Towns::getTown(std::string& name) { | |
| 62 | + | for (TownMap::iterator it = begin(); it != end(); ++it) { | |
| 63 | + | if (it->second->getName() == name) { | |
| 64 | + | return it->second; | |
| 65 | + | } | |
| 66 | + | } | |
| 67 | + | return nullptr; | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | Town* Towns::getTown(uint32_t id) { | |
| 71 | + | TownMap::iterator it = find(id); | |
| 72 | + | if (it != end()) { | |
| 73 | + | return it->second; | |
| 74 | + | } | |
| 75 | + | return nullptr; | |
| 76 | + | } | |
| 77 | + | ||
| 78 | + | void Town::setTemplePosition(const Position& pos) { | |
| 79 | + | templepos = pos; | |
| 80 | + | } |
| @@ -0,0 +1,108 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #ifndef RME_TOWN_H_ | |
| 19 | + | #define RME_TOWN_H_ | |
| 20 | + | ||
| 21 | + | #include "position.h" | |
| 22 | + | ||
| 23 | + | class Town { | |
| 24 | + | public: | |
| 25 | + | Town(uint32_t _id) : | |
| 26 | + | id(_id), name("") { } | |
| 27 | + | Town(const Town& copy) : | |
| 28 | + | id(copy.id), name(copy.name), templepos(copy.templepos) { } | |
| 29 | + | ~Town() { } | |
| 30 | + | ||
| 31 | + | const std::string& getName() const { | |
| 32 | + | return name; | |
| 33 | + | } | |
| 34 | + | void setName(const std::string& newName) { | |
| 35 | + | name = newName; | |
| 36 | + | } | |
| 37 | + | ||
| 38 | + | const Position& getTemplePosition() const { | |
| 39 | + | return templepos; | |
| 40 | + | } | |
| 41 | + | void setTemplePosition(const Position& _pos); | |
| 42 | + | ||
| 43 | + | uint32_t getID() const { | |
| 44 | + | return id; | |
| 45 | + | } | |
| 46 | + | void setID(uint32_t _id) { | |
| 47 | + | id = _id; | |
| 48 | + | } | |
| 49 | + | ||
| 50 | + | private: | |
| 51 | + | uint32_t id; | |
| 52 | + | std::string name; | |
| 53 | + | Position templepos; | |
| 54 | + | }; | |
| 55 | + | ||
| 56 | + | typedef std::map<uint32_t, Town*> TownMap; | |
| 57 | + | ||
| 58 | + | class Towns { | |
| 59 | + | public: | |
| 60 | + | Towns(); | |
| 61 | + | ~Towns(); | |
| 62 | + | ||
| 63 | + | // Clears the townmap | |
| 64 | + | void clear(); | |
| 65 | + | ||
| 66 | + | uint32_t count() const { | |
| 67 | + | return towns.size(); | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | bool addTown(Town* town); | |
| 71 | + | uint32_t getEmptyID(); | |
| 72 | + | ||
| 73 | + | Town* getTown(std::string& townname); | |
| 74 | + | Town* getTown(uint32_t _townid); | |
| 75 | + | ||
| 76 | + | TownMap::const_iterator begin() const { | |
| 77 | + | return towns.begin(); | |
| 78 | + | } | |
| 79 | + | TownMap::const_iterator end() const { | |
| 80 | + | return towns.end(); | |
| 81 | + | } | |
| 82 | + | TownMap::const_iterator find(uint32_t id) const { | |
| 83 | + | return towns.find(id); | |
| 84 | + | } | |
| 85 | + | TownMap::iterator begin() { | |
| 86 | + | return towns.begin(); | |
| 87 | + | } | |
| 88 | + | TownMap::iterator end() { | |
| 89 | + | return towns.end(); | |
| 90 | + | } | |
| 91 | + | TownMap::iterator find(uint32_t id) { | |
| 92 | + | return towns.find(id); | |
| 93 | + | } | |
| 94 | + | #ifdef __VISUALC__ // C++0x compliance to some degree :) | |
| 95 | + | TownMap::iterator erase(TownMap::iterator iter) { | |
| 96 | + | return towns.erase(iter); | |
| 97 | + | } | |
| 98 | + | #else | |
| 99 | + | void erase(TownMap::iterator iter) { | |
| 100 | + | towns.erase(iter); | |
| 101 | + | } | |
| 102 | + | #endif | |
| 103 | + | ||
| 104 | + | private: | |
| 105 | + | TownMap towns; | |
| 106 | + | }; | |
| 107 | + | ||
| 108 | + | #endif |
| @@ -0,0 +1,91 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #include "main.h" | |
| 19 | + | ||
| 20 | + | #ifdef _USE_UPDATER_ | |
| 21 | + | ||
| 22 | + | #include <wx/url.h> | |
| 23 | + | ||
| 24 | + | #include "json.h" | |
| 25 | + | ||
| 26 | + | #include "updater.h" | |
| 27 | + | ||
| 28 | + | const wxEventType EVT_UPDATE_CHECK_FINISHED = wxNewEventType(); | |
| 29 | + | ||
| 30 | + | UpdateChecker::UpdateChecker() { | |
| 31 | + | //// | |
| 32 | + | } | |
| 33 | + | ||
| 34 | + | UpdateChecker::~UpdateChecker() { | |
| 35 | + | //// | |
| 36 | + | } | |
| 37 | + | ||
| 38 | + | void UpdateChecker::connect(wxEvtHandler* receiver) { | |
| 39 | + | wxString address = "http://www.remeresmapeditor.com/update.php"; | |
| 40 | + | address << "?os=" | |
| 41 | + | << | |
| 42 | + | #ifdef __WINDOWS__ | |
| 43 | + | "windows"; | |
| 44 | + | #elif __LINUX__ | |
| 45 | + | "linux"; | |
| 46 | + | #else | |
| 47 | + | "unknown"; | |
| 48 | + | #endif | |
| 49 | + | address << "&verid=" << __RME_VERSION_ID__; | |
| 50 | + | #ifdef __EXPERIMENTAL__ | |
| 51 | + | address << "&beta"; | |
| 52 | + | #endif | |
| 53 | + | wxURL* url = newd wxURL(address); | |
| 54 | + | UpdateConnectionThread* connection = newd UpdateConnectionThread(receiver, url); | |
| 55 | + | connection->Execute(); | |
| 56 | + | } | |
| 57 | + | ||
| 58 | + | UpdateConnectionThread::UpdateConnectionThread(wxEvtHandler* receiver, wxURL* url) : | |
| 59 | + | receiver(receiver), | |
| 60 | + | url(url) { | |
| 61 | + | //// | |
| 62 | + | } | |
| 63 | + | ||
| 64 | + | UpdateConnectionThread::~UpdateConnectionThread() { | |
| 65 | + | //// | |
| 66 | + | } | |
| 67 | + | ||
| 68 | + | wxThread::ExitCode UpdateConnectionThread::Entry() { | |
| 69 | + | wxInputStream* input = url->GetInputStream(); | |
| 70 | + | if (!input) { | |
| 71 | + | delete input; | |
| 72 | + | delete url; | |
| 73 | + | return 0; | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | std::string data; | |
| 77 | + | while (!input->Eof()) { | |
| 78 | + | data += input->GetC(); | |
| 79 | + | } | |
| 80 | + | ||
| 81 | + | delete input; | |
| 82 | + | delete url; | |
| 83 | + | wxCommandEvent event(EVT_UPDATE_CHECK_FINISHED); | |
| 84 | + | event.SetClientData(newd std::string(data)); | |
| 85 | + | if (receiver) { | |
| 86 | + | receiver->AddPendingEvent(event); | |
| 87 | + | } | |
| 88 | + | return 0; | |
| 89 | + | } | |
| 90 | + | ||
| 91 | + | #endif |
| @@ -0,0 +1,57 @@ | |||
| 1 | + | ////////////////////////////////////////////////////////////////////// | |
| 2 | + | // This file is part of Remere's Map Editor | |
| 3 | + | ////////////////////////////////////////////////////////////////////// | |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify | |
| 5 | + | // it under the terms of the GNU General Public License as published by | |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or | |
| 7 | + | // (at your option) any later version. | |
| 8 | + | // | |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, | |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + | // GNU General Public License for more details. | |
| 13 | + | // | |
| 14 | + | // You should have received a copy of the GNU General Public License | |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | ////////////////////////////////////////////////////////////////////// | |
| 17 | + | ||
| 18 | + | #ifdef _USE_UPDATER_ | |
| 19 | + | ||
| 20 | + | #ifndef RME_UPDATER_H_ | |
| 21 | + | #define RME_UPDATER_H_ | |
| 22 | + | ||
| 23 | + | #include "threads.h" | |
| 24 | + | ||
| 25 | + | extern const wxEventType EVT_UPDATE_CHECK_FINISHED; | |
| 26 | + | ||
| 27 | + | #define EVT_ON_UPDATE_CHECK_FINISHED(id, fn) \ | |
| 28 | + | DECLARE_EVENT_TABLE_ENTRY( \ | |
| 29 | + | EVT_UPDATE_CHECK_FINISHED, id, wxID_ANY, \ | |
| 30 | + | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCommandEventFunction, &fn), \ | |
| 31 | + | (wxObject*)nullptr \ | |
| 32 | + | ), | |
| 33 | + | ||
| 34 | + | class wxURL; | |
| 35 | + | ||
| 36 | + | class UpdateConnectionThread : public DetachedThread { | |
| 37 | + | public: | |
| 38 | + | UpdateConnectionThread(wxEvtHandler* receiver, wxURL* url); | |
| 39 | + | virtual ~UpdateConnectionThread(); | |
| 40 | + | ||
| 41 | + | protected: | |
| 42 | + | virtual ExitCode Entry(); | |
| 43 | + | wxEvtHandler* receiver; | |
| 44 | + | wxURL* url; | |
| 45 | + | }; | |
| 46 | + | ||
| 47 | + | class UpdateChecker { | |
| 48 | + | public: | |
| 49 | + | UpdateChecker(); | |
| 50 | + | ~UpdateChecker(); | |
| 51 | + | ||
| 52 | + | void connect(wxEvtHandler* receiver); | |
| 53 | + | }; | |
| 54 | + | ||
| 55 | + | #endif | |
| 56 | + | ||
| 57 | + | #endif |