mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Created hall.json from hall.txt.
This commit is contained in:
parent
4f2bc1cc35
commit
35350aeeff
114
config/hall.json
Normal file
114
config/hall.json
Normal file
@ -0,0 +1,114 @@
|
||||
{
|
||||
// for each castle:
|
||||
// id: town ID
|
||||
// boxes: row buildings containing sets of ids for each box
|
||||
"town": [
|
||||
{
|
||||
"id": 0,
|
||||
"image": "TPTHBKCS.BMP",
|
||||
"boxes": [
|
||||
[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5, 22 ], [ 16 ] ],
|
||||
[ [ 14, 15 ], [ 0, 1, 2, 3 ], [ 6, 17 ] ],
|
||||
[ [ 21 ], [ 18, 19 ] ],
|
||||
[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
|
||||
[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"image": "TPTHBKRM.BMP",
|
||||
"boxes": [
|
||||
[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
|
||||
[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 17, 21 ] ],
|
||||
[ [ 22 ], [ 24, 25 ], [ 18, 19 ] ],
|
||||
[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
|
||||
[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"id": 2,
|
||||
"image": "TPTHBKTW.BMP",
|
||||
"boxes": [
|
||||
[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
|
||||
[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 22 ], [ 23 ] ],
|
||||
[ [ 17 ], [ 21 ], [ 18, 19 ] ],
|
||||
[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
|
||||
[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"id": 3,
|
||||
"image": "TPTHBKIN.BMP",
|
||||
"boxes": [
|
||||
[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
|
||||
[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 23 ], [ 21 ] ],
|
||||
[ [ 22 ], [ 18, 19 ], [ 24, 25 ] ],
|
||||
[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
|
||||
[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"id": 4,
|
||||
"image": "TPTHBKNC.BMP",
|
||||
"boxes": [
|
||||
[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
|
||||
[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 21 ], [ 6 ] ],
|
||||
[ [ 17 ], [ 22 ], [ 18, 19 ] ],
|
||||
[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
|
||||
[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"id": 5,
|
||||
"image": "TPTHBKDG.BMP",
|
||||
"boxes": [
|
||||
[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
|
||||
[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 21 ], [ 22 ] ],
|
||||
[ [ 17 ], [ 23 ], [ 18, 19 ] ],
|
||||
[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
|
||||
[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"id": 6,
|
||||
"image": "TPTHBKTW.BMP",
|
||||
"boxes": [
|
||||
[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
|
||||
[ [ 14, 15 ], [ 0, 1, 2 ], [ 23 ], [ 17 ] ],
|
||||
[ [ 21 ], [ 22 ], [ 18, 19 ] ],
|
||||
[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
|
||||
[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"id": 7,
|
||||
"image": "TPTHBKFR.BMP",
|
||||
"boxes": [
|
||||
[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
|
||||
[ [ 14, 15 ], [ 0, 1, 2 ], [ 6 ] ],
|
||||
[ [ 17 ], [ 21, 22 ], [ 18, 19 ] ],
|
||||
[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
|
||||
[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"id": 8,
|
||||
"image": "TPTHBKFR.BMP",
|
||||
"boxes": [
|
||||
[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
|
||||
[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 6 ] ],
|
||||
[ [ 21 ], [ 17 ], [ 18, 19 ] ],
|
||||
[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
|
||||
[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
9
|
||||
0
|
||||
TPTHBKCS.BMP
|
||||
10 11 12 13 | 7 8 9 | 5 22 | 16
|
||||
14 15 | 0 1 2 3 | 6 17
|
||||
21 | 18 19
|
||||
30 37 | 31 38 | 32 39 | 33 40
|
||||
34 41 | 35 42 | 36 43
|
||||
1
|
||||
TPTHBKRM.BMP
|
||||
10 11 12 13 | 7 8 9 | 5 | 16
|
||||
14 15 | 0 1 2 3 4 | 17 21
|
||||
22 | 24 25 | 18 19
|
||||
30 37 | 31 38 | 32 39 | 33 40
|
||||
34 41 | 35 42 | 36 43
|
||||
2
|
||||
TPTHBKTW.BMP
|
||||
10 11 12 13 | 7 8 9 | 5 | 16
|
||||
14 15 | 0 1 2 3 4 | 22 | 23
|
||||
17 | 21 | 18 19
|
||||
30 37 | 31 38 | 32 39 | 33 40
|
||||
34 41 | 35 42 | 36 43
|
||||
3
|
||||
TPTHBKIN.BMP
|
||||
10 11 12 13 | 7 8 9 | 5 | 16
|
||||
14 15 | 0 1 2 3 4 | 23 | 21
|
||||
22 | 18 19 | 24 25
|
||||
30 37 | 31 38 | 32 39 | 33 40
|
||||
34 41 | 35 42 | 36 43
|
||||
4
|
||||
TPTHBKNC.BMP
|
||||
10 11 12 13 | 7 8 9 | 5 | 16
|
||||
14 15 | 0 1 2 3 4 | 21 | 6
|
||||
17 | 22 | 18 19
|
||||
30 37 | 31 38 | 32 39 | 33 40
|
||||
34 41 | 35 42 | 36 43
|
||||
5
|
||||
TPTHBKDG.BMP
|
||||
10 11 12 13 | 7 8 9 | 5 | 16
|
||||
14 15 | 0 1 2 3 4 | 21 | 22
|
||||
17 | 23 | 18 19
|
||||
30 37 | 31 38 | 32 39 | 33 40
|
||||
34 41 | 35 42 | 36 43
|
||||
6
|
||||
TPTHBKTW.BMP
|
||||
10 11 12 13 | 7 8 9 | 5 | 16
|
||||
14 15 | 0 1 2 | 23 | 17
|
||||
21 | 22 | 18 19
|
||||
30 37 | 31 38 | 32 39 | 33 40
|
||||
34 41 | 35 42 | 36 43
|
||||
7
|
||||
TPTHBKFR.BMP
|
||||
10 11 12 13 | 7 8 9 | 5 | 16
|
||||
14 15 | 0 1 2 | 6
|
||||
17 | 21 22 | 18 19
|
||||
30 37 | 31 38 | 32 39 | 33 40
|
||||
34 41 | 35 42 | 36 43
|
||||
8
|
||||
TPTHBKFR.BMP
|
||||
10 11 12 13 | 7 8 9 | 5 | 16
|
||||
14 15 | 0 1 2 3 4 | 6
|
||||
21 | 17 | 18 19
|
||||
30 37 | 31 38 | 32 39 | 33 40
|
||||
34 41 | 35 42 | 36 43
|
||||
|
||||
|
||||
file format:
|
||||
numberof castles
|
||||
* for each castle:
|
||||
castle ID
|
||||
first row buildings (ids for each box, boxes are separated with '|')
|
||||
sencond row buildings
|
||||
etc...
|
||||
|
||||
Warning: file is whitespace sensitive, don't add any spaces at end of the lines, or remove spaces between numbers and separators
|
@ -8,6 +8,8 @@
|
||||
#include <fstream>
|
||||
#include <assert.h>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include "../lib/JsonNode.h"
|
||||
|
||||
extern CLodHandler * bitmaph;
|
||||
|
||||
@ -99,50 +101,33 @@ void CBuildingHandler::loadBuildings()
|
||||
}
|
||||
}
|
||||
/////done reading BUILDING.TXT*****************************
|
||||
const JsonNode config(DATA_DIR "/config/hall.json");
|
||||
|
||||
char line[100]; //bufor
|
||||
std::ifstream ofs(DATA_DIR "/config/hall.txt");
|
||||
int castles;
|
||||
ofs>>castles;
|
||||
for(int i=0;i<castles;i++)
|
||||
BOOST_FOREACH(const JsonNode &town, config["town"].Vector())
|
||||
{
|
||||
int tid;
|
||||
unsigned int it, box=0;
|
||||
std::string pom;
|
||||
ofs >> tid >> pom;
|
||||
hall[tid].first = pom;
|
||||
(hall[tid].second).resize(5); //rows
|
||||
for(int j=0;j<5;j++)
|
||||
{
|
||||
box = it = 0;
|
||||
ofs.getline(line,100);
|
||||
if(!line[0] || line[0] == '\n' || line[0] == '\r')
|
||||
ofs.getline(line,100);
|
||||
std::string linia(line);
|
||||
bool areboxes=true;
|
||||
while(areboxes) //read all boxes
|
||||
{
|
||||
(hall[tid].second)[j].push_back(std::vector<int>()); //push new box
|
||||
int seppos = linia.find_first_of('|',it); //position of end of this box data
|
||||
if(seppos<0)
|
||||
seppos = linia.length();
|
||||
while(it<seppos)
|
||||
{
|
||||
int last = linia.find_first_of(' ',it);
|
||||
std::istringstream ss(linia.substr(it,last-it));
|
||||
it = last + 1;
|
||||
ss >> last;
|
||||
(hall[tid].second)[j][box].push_back(last);
|
||||
areboxes = it; //wyzeruje jak nie znajdzie kolejnej spacji = koniec linii
|
||||
if(!it)
|
||||
it = seppos+1;
|
||||
}
|
||||
box++;
|
||||
it+=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
int tid = town["id"].Float();
|
||||
|
||||
hall[tid].first = town["image"].String();
|
||||
(hall[tid].second).resize(5); //rows
|
||||
|
||||
int row_num = 0;
|
||||
BOOST_FOREACH(const JsonNode &row, town["boxes"].Vector())
|
||||
{
|
||||
BOOST_FOREACH(const JsonNode &box, row.Vector())
|
||||
{
|
||||
(hall[tid].second)[row_num].push_back(std::vector<int>()); //push new box
|
||||
std::vector<int> &box_vec = (hall[tid].second)[row_num].back();
|
||||
|
||||
BOOST_FOREACH(const JsonNode &value, box.Vector())
|
||||
{
|
||||
box_vec.push_back(value.Float());
|
||||
}
|
||||
}
|
||||
row_num ++;
|
||||
}
|
||||
|
||||
assert (row_num == 5);
|
||||
}
|
||||
}
|
||||
|
||||
CBuildingHandler::~CBuildingHandler()
|
||||
|
Loading…
Reference in New Issue
Block a user