From e5349c58cd129ccd43b663a11f9a517cbdd5c9f4 Mon Sep 17 00:00:00 2001 From: Frank Zago Date: Wed, 31 Aug 2011 04:11:44 +0000 Subject: [PATCH] Created wall_pos.json from wall_pos.txt. --- client/Graphics.cpp | 35 ++---- config/wall_pos.json | 280 +++++++++++++++++++++++++++++++++++++++++++ config/wall_pos.txt | 201 ------------------------------- 3 files changed, 289 insertions(+), 227 deletions(-) create mode 100644 config/wall_pos.json delete mode 100644 config/wall_pos.txt diff --git a/client/Graphics.cpp b/client/Graphics.cpp index 8664ea39e..1078bc5d6 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -367,35 +367,18 @@ void Graphics::loadHeroPortraits() void Graphics::loadWallPositions() { - std::ifstream inp; - inp.open(DATA_DIR "/config/wall_pos.txt", std::ios_base::in|std::ios_base::binary); - if(!inp.is_open()) - { - tlog1<<"missing file: config/wall_pos.txt"<> dump; - for(int b = 0; b < 21; ++b) - { - Point pt; - inp >> pt.x; - inp >> pt.y; - wallPositions[g].push_back(pt); - } + BOOST_FOREACH(const JsonNode &town, config["towns"].Vector()) { + int townID = town["id"].Float(); + + BOOST_FOREACH(const JsonNode &coords, town["pos"].Vector()) { + Point pt(coords["x"].Float(), coords["y"].Float()); + wallPositions[townID].push_back(pt); } + + assert(wallPositions[townID].size() == 21); } - inp.close(); } void Graphics::loadHeroAnims() diff --git a/config/wall_pos.json b/config/wall_pos.json new file mode 100644 index 000000000..ee13009bf --- /dev/null +++ b/config/wall_pos.json @@ -0,0 +1,280 @@ +{ + + // Description of positions of wall parts' positions. + // pos is a set of coordinates (x, y): + // 1. background wall + // 2. keep + // 3. bottom tower + // 4. bottom wall + // 5. wall below gate + // 6. wall over gate + // 7. upper wall + // 8. upper tower + // 9. gate + // 10. gate arch + // 11. bottom static wall + // 12. upper static wall + // 13. moat + // 14. mlip + // 15. keep turret cover + // 16. lower turret cover + // 17. upper turret cover + // 18. keep creature + // 19. lower turret creature + // 20. upper turret creature + // 21. y=turret height(from top of def image); x is not used + + "towns": [ + { + "id": 0, + "name": "Castle", + "pos": [ + { "x": 600, "y": 49 }, + { "x": 720, "y": 158 }, + { "x": 602, "y": 500 }, + { "x": 528, "y": 350 }, + { "x": 469, "y": 291 }, + { "x": 470, "y": 127 }, + { "x": 524, "y": 32 }, + { "x": 569, "y": 35 }, + { "x": 399, "y": 274 }, + { "x": 477, "y": 238 }, + { "x": 512, "y": 347 }, + { "x": 489, "y": 79 }, + { "x": 410, "y": 90 }, + { "x": 403, "y": 80 }, + { "x": 720, "y": 158 }, + { "x": 602, "y": 500 }, + { "x": 557, "y": 24 }, + { "x": 526, "y": -29 }, + { "x": 394, "y": 299 }, + { "x": 342, "y": -187 }, + { "x": 0, "y": 231 } + ] + }, + + { + "id": 1, + "name": "Rampart", + "pos": [ + { "x": 608, "y": 46 }, + { "x": 724, "y": 189 }, + { "x": 594, "y": 511 }, + { "x": 549, "y": 451 }, + { "x": 469, "y": 309 }, + { "x": 469, "y": 186 }, + { "x": 530, "y": 57 }, + { "x": 565, "y": 31 }, + { "x": 403, "y": 271 }, + { "x": 460, "y": 220 }, + { "x": 510, "y": 364 }, + { "x": 492, "y": 103 }, + { "x": 410, "y": 77 }, + { "x": 410, "y": 97 }, + { "x": 724, "y": 189 }, + { "x": 594, "y": 511 }, + { "x": 566, "y": 31 }, + { "x": 532, "y": -27 }, + { "x": 371, "y": 296 }, + { "x": 341, "y": -186 }, + { "x": 0, "y": 232 } + ] + }, + + { + "id": 2, + "name": "Tower", + "pos": [ + { "x": 615, "y": 57 }, + { "x": 726, "y": 148 }, + { "x": 592, "y": 516 }, + { "x": 547, "y": 452 }, + { "x": 475, "y": 298 }, + { "x": 488, "y": 190 }, + { "x": 547, "y": 66 }, + { "x": 580, "y": 36 }, + { "x": 400, "y": 253 }, + { "x": 471, "y": 187 }, + { "x": 517, "y": 365 }, + { "x": 514, "y": 79 }, + { "x": 410, "y": 90 }, + { "x": 410, "y": 80 }, + { "x": 726, "y": 148 }, + { "x": 592, "y": 516 }, + { "x": 580, "y": 36 }, + { "x": 499, "y": -16 }, + { "x": 355, "y": 311 }, + { "x": 346, "y": -175 }, + { "x": 0, "y": 231 } + ] + }, + + { + "id": 3, + "name": "Inferno", + "pos": [ + { "x": 606, "y": 52 }, + { "x": 730, "y": 179 }, + { "x": 595, "y": 514 }, + { "x": 561, "y": 451 }, + { "x": 485, "y": 316 }, + { "x": 480, "y": 151 }, + { "x": 532, "y": 71 }, + { "x": 569, "y": 27 }, + { "x": 408, "y": 254 }, + { "x": 477, "y": 221 }, + { "x": 522, "y": 376 }, + { "x": 502, "y": 92 }, + { "x": 403, "y": 68 }, + { "x": 403, "y": 68 }, + { "x": 730, "y": 179 }, + { "x": 595, "y": 514 }, + { "x": 569, "y": 27 }, + { "x": 511, "y": -37 }, + { "x": 369, "y": 298 }, + { "x": 341, "y": -187 }, + { "x": 0, "y": 231 } + ] + }, + + { + "id": 4, + "name": "Necropolis", + "pos": [ + { "x": 604, "y": 58 }, + { "x": 730, "y": 164 }, + { "x": 592, "y": 512 }, + { "x": 536, "y": 445 }, + { "x": 478, "y": 323 }, + { "x": 487, "y": 164 }, + { "x": 543, "y": 66 }, + { "x": 561, "y": 26 }, + { "x": 401, "y": 262 }, + { "x": 474, "y": 240 }, + { "x": 509, "y": 372 }, + { "x": 504, "y": 97 }, + { "x": 406, "y": 77 }, + { "x": -1, "y": -1 }, + { "x": 730, "y": 164 }, + { "x": 592, "y": 512 }, + { "x": 561, "y": 26 }, + { "x": 501, "y": 98 }, + { "x": 371, "y": 303 }, + { "x": 339, "y": -177 }, + { "x": 0, "y": 231 } + ] + }, + + { + "id": 5, + "name": "Dungeon", + "pos": [ + { "x": 608, "y": 50 }, + { "x": 732, "y": 162 }, + { "x": 560, "y": 495 }, + { "x": 559, "y": 448 }, + { "x": 471, "y": 296 }, + { "x": 477, "y": 180 }, + { "x": 523, "y": 56 }, + { "x": 565, "y": 15 }, + { "x": 395, "y": 260 }, + { "x": 471, "y": 164 }, + { "x": 522, "y": 305 }, + { "x": 494, "y": 53 }, + { "x": 283, "y": 94 }, + { "x": 283, "y": 94 }, + { "x": 732, "y": 162 }, + { "x": 600, "y": 495 }, + { "x": 565, "y": 15 }, + { "x": 570, "y": -50 }, + { "x": 410, "y": 293 }, + { "x": 381, "y": -187 }, + { "x": 0, "y": 230 } + ] + }, + + { + "id": 6, + "name": "Stronghold", + "pos": [ + { "x": 617, "y": 62 }, + { "x": 731, "y": 168 }, + { "x": 586, "y": 508 }, + { "x": 553, "y": 440 }, + { "x": 483, "y": 304 }, + { "x": 476, "y": 189 }, + { "x": 534, "y": 69 }, + { "x": 568, "y": 30 }, + { "x": 407, "y": 266 }, + { "x": 478, "y": 235 }, + { "x": 511, "y": 380 }, + { "x": 499, "y": 107 }, + { "x": 410, "y": 90 }, + { "x": 410, "y": 91 }, + { "x": 731, "y": 168 }, + { "x": 586, "y": 508 }, + { "x": 568, "y": 30 }, + { "x": 531, "y": -45 }, + { "x": 361, "y": 290 }, + { "x": 342, "y": -187 }, + { "x": 0, "y": 231 } + ] + }, + + { + "id": 7, + "name": "Fortress", + "pos": [ + { "x": 599, "y": 62 }, + { "x": 721, "y": 178 }, + { "x": 599, "y": 505 }, + { "x": 546, "y": 441 }, + { "x": 486, "y": 306 }, + { "x": 498, "y": 184 }, + { "x": 526, "y": 80 }, + { "x": 548, "y": 27 }, + { "x": 392, "y": 253 }, + { "x": 483, "y": 236 }, + { "x": 522, "y": 382 }, + { "x": 508, "y": 130 }, + { "x": 383, "y": 95 }, + { "x": 376, "y": 70 }, + { "x": 721, "y": 178 }, + { "x": 599, "y": 505 }, + { "x": 548, "y": 27 }, + { "x": 541, "y": -37 }, + { "x": 372, "y": 308 }, + { "x": 326, "y": -182 }, + { "x": 0, "y": 231 } + ] + }, + + { + "id": 8, + "name": "Conflux", + "pos": [ + { "x": 600, "y": 50 }, + { "x": 736, "y": 159 }, + { "x": 608, "y": 505 }, + { "x": 509, "y": 346 }, + { "x": 468, "y": 299 }, + { "x": 471, "y": 147 }, + { "x": 521, "y": 41 }, + { "x": 576, "y": 28 }, + { "x": 408, "y": 254 }, + { "x": 486, "y": 232 }, + { "x": 509, "y": 346 }, + { "x": 490, "y": 97 }, + { "x": 407, "y": 80 }, + { "x": 407, "y": 80 }, + { "x": 736, "y": 159 }, + { "x": 608, "y": 505 }, + { "x": 576, "y": 28 }, + { "x": 529, "y": -42 }, + { "x": 382, "y": 308 }, + { "x": 341, "y": -162 }, + { "x": 0, "y": 229 } + ] + } + ] +} diff --git a/config/wall_pos.txt b/config/wall_pos.txt deleted file mode 100644 index f9696c314..000000000 --- a/config/wall_pos.txt +++ /dev/null @@ -1,201 +0,0 @@ -//this file is a description of positions of wall parts' positions, following lines contain positions of: 1. background wall, 2. keep, 3. bottom tower, 4. bottom wall, 5. wall below gate, -//6. wall over gate, 7. upper wall, 8. upper tower, 9. gate, 10. gate arch, 11. bottom static wall, 12. upper static wall, 13. moat, 14. mlip, -//15. keep turret cover, 16. lower turret cover, 17. upper turret cover, 18. keep creature, 19. lower turret creature, 20. upper turret creature (x, y), 21. 2nd value: turret height(from top of def image), 1st value: not used -//Castle -600 49 -720 158 -602 500 -528 350 -469 291 -470 127 -524 32 -569 35 -399 274 -477 238 -512 347 -489 79 -410 90 -403 80 -720 158 -602 500 -557 24 -526 -29 -394 299 -342 -187 -0 231 -//Rampart -608 46 -724 189 -594 511 -549 451 -469 309 -469 186 -530 57 -565 31 -403 271 -460 220 -510 364 -492 103 -410 77 -410 97 -724 189 -594 511 -566 31 -532 -27 -371 296 -341 -186 -0 232 -//Tower -615 57 -726 148 -592 516 -547 452 -475 298 -488 190 -547 66 -580 36 -400 253 -471 187 -517 365 -514 79 -410 90 -410 80 -726 148 -592 516 -580 36 -499 -16 -355 311 -346 -175 -0 231 -//Inferno -606 52 -730 179 -595 514 -561 451 -485 316 -480 151 -532 71 -569 27 -408 254 -477 221 -522 376 -502 92 -403 68 -403 68 -730 179 -595 514 -569 27 -511 -37 -369 298 -341 -187 -0 231 -//Necropolis -604 58 -730 164 -592 512 -536 445 -478 323 -487 164 -543 66 -561 26 -401 262 -474 240 -509 372 -504 97 -406 77 --1 -1 -730 164 -592 512 -561 26 -501 98 -371 303 -339 -177 -0 231 -//Dungeon -608 50 -732 162 -560 495 -559 448 -471 296 -477 180 -523 56 -565 15 -395 260 -471 164 -522 305 -494 53 -283 94 -283 94 -732 162 -600 495 -565 15 -570 -50 -410 293 -381 -187 -0 230 -//Stronghold -617 62 -731 168 -586 508 -553 440 -483 304 -476 189 -534 69 -568 30 -407 266 -478 235 -511 380 -499 107 -410 90 -410 91 -731 168 -586 508 -568 30 -531 -45 -361 290 -342 -187 -0 231 -//Fortress -599 62 -721 178 -599 505 -546 441 -486 306 -498 184 -526 80 -548 27 -392 253 -483 236 -522 382 -508 130 -383 95 -376 70 -721 178 -599 505 -548 27 -541 -37 -372 308 -326 -182 -0 231 -//Conflux -600 50 -736 159 -608 505 -509 346 -468 299 -471 147 -521 41 -576 28 -408 254 -486 232 -509 346 -490 97 -407 80 -407 80 -736 159 -608 505 -576 28 -529 -42 -382 308 -341 -162 -0 229 \ No newline at end of file