Change the struct list initialisation

This commit is contained in:
Shadow15510 2021-11-05 17:33:19 +01:00
parent ea342532a0
commit 48abaf9cd9
3 changed files with 314 additions and 301 deletions

View File

@ -5,417 +5,417 @@ const struct building buildings[41] = {
// Menu 1
{
.name = "TERRE",
.id = (unsigned char []){48, 49, 110, 111, 112, 113, 114, 120, 121, 122, 123, 124, 130, 131, 132, 133, 134},
.cost = 10,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"TERRE",
(unsigned char []){48, 49, 110, 111, 112, 113, 114, 120, 121, 122, 123, 124, 130, 131, 132, 133, 134},
10, // cost
{1, 1}, //size
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // stat
{0, 0, 0}, // taxes
{0, 0, 0} // funds
},
{
.name = "EAU",
.id = (unsigned char []){139},
.cost = 15,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"EAU",
(unsigned char []){139},
15,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "FORET",
.id = (unsigned char []){76},
.cost = 15,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"FORET",
(unsigned char []){76},
15,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "HABITATIONS TYPE 1",
.id = (unsigned char []){66},
.cost = 100,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"HABITATIONS TYPE 1",
(unsigned char []){66},
100,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "HABITATIONS TYPE 2",
.id = (unsigned char []){67},
.cost = 150,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"HABITATIONS TYPE 2",
(unsigned char []){67},
150,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "HABITATIONS TYPE 3",
.id = (unsigned char []){68},
.cost = 200,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"HABITATIONS TYPE 3",
(unsigned char []){68},
200,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "BUREAUX TYPE 1",
.id = (unsigned char []){45},
.cost = 50,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"BUREAUX TYPE 1",
(unsigned char []){45},
50,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "BUREAUX TYPE 2",
.id = (unsigned char []){46},
.cost = 100,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"BUREAUX TYPE 2",
(unsigned char []){46},
100,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "BUREAUX TYPE 3",
.id = (unsigned char []){47},
.cost = 150,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"BUREAUX TYPE 3",
(unsigned char []){47},
150,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "USINE TYPE 1",
.id = (unsigned char []){54},
.cost = 200,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"USINE TYPE 1",
(unsigned char []){54},
200,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "USINE TYPE 2",
.id = (unsigned char []){55},
.cost = 300,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"USINE TYPE 2",
(unsigned char []){55},
300,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "USINE TYPE 3",
.id = (unsigned char []){56},
.cost = 400,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"USINE TYPE 3",
(unsigned char []){56},
400,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "FERME TYPE 1",
.id = (unsigned char []){9},
.cost = 50,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"FERME TYPE 1",
(unsigned char []){9},
50,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "FERME TYPE 2",
.id = (unsigned char []){19},
.cost = 75,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"FERME TYPE 2",
(unsigned char []){19},
75,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "FERME TYPE 3",
.id = (unsigned char []){44},
.cost = 100,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"FERME TYPE 3",
(unsigned char []){44},
100,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
// Menu 2
{
.name = "ROUTE",
.id = (unsigned char []){80, 81, 82, 83, 90, 91, 92, 93, 100, 101, 102},
.cost = 10,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"ROUTE",
(unsigned char []){80, 81, 82, 83, 90, 91, 92, 93, 100, 101, 102},
10,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "PORT",
.id = (unsigned char []){62, 63, 64, 65},
.cost = 500,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"PORT",
(unsigned char []){62, 63, 64, 65},
500,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "AEROPORT",
.id = (unsigned char []){0, 1, 2, 12},
.cost = 3500,
.size = {2, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"AEROPORT",
(unsigned char []){0, 1, 2, 12},
3500,
{2, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "RAIL",
.id = (unsigned char []){84, 85, 86, 87, 94, 95, 96, 97, 104, 105, 106},
.cost = 50,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"RAIL",
(unsigned char []){84, 85, 86, 87, 94, 95, 96, 97, 104, 105, 106},
50,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "CENTRALE ELECTRIQUE 1",
.id = (unsigned char []){71},
.cost = 500,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"CENTRALE ELECTRIQUE 1",
(unsigned char []){71},
500,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "CENTRALE ELECTRIQUE 2",
.id = (unsigned char []){72},
.cost = 1000,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"CENTRALE ELECTRIQUE 2",
(unsigned char []){72},
1000,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "CENTALE NUCLEAIRE",
.id = (unsigned char []){50, 51, 60, 61},
.cost = 25000,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
"CENTALE NUCLEAIRE",
(unsigned char []){50, 51, 60, 61},
25000,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "INCINERATEUR",
.id = (unsigned char []){3, 4, 13, 14},
.cost = 2500,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0},
"INCINERATEUR",
(unsigned char []){3, 4, 13, 14},
2500,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
}
{
.name = "STATION D'EPURATION",
.id = (unsigned char []){77},
.cost = 50,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"STATION D'EPURATION",
(unsigned char []){77},
50,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "TERRAIN DE SPORT",
.id = (unsigned char []){78},
.cost = 250,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"TERRAIN DE SPORT",
(unsigned char []){78},
250,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "AIRE DE JEUX",
.id = (unsigned char []){69},
.cost = 150,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"AIRE DE JEUX",
(unsigned char []){69},
150,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "STADE",
.id = (unsigned char []){42, 43, 52, 53},
.cost = 10000,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
"STADE",
(unsigned char []){42, 43, 52, 53},
10000,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "CASERNE DE POLICE",
.id = (unsigned char []){70},
.cost = 250,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"CASERNE DE POLICE",
(unsigned char []){70},
250,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "CASERNE DE POMPIERS",
.id = (unsigned char []){58},
.cost = 250,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"CASERNE DE POMPIERS",
(unsigned char []){58},
250,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "HOPITAL",
.id = (unsigned char []){59},
.cost = 250,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"HOPITAL",
(unsigned char []){59},
250,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "CENTRE ECOLOGIQUE",
.id = (unsigned char []){75},
.cost = 2500,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"CENTRE ECOLOGIQUE",
(unsigned char []){75},
2500,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "ECOLE TYPE 1",
.id = (unsigned char []){73},
.cost = 250,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"ECOLE TYPE 1",
(unsigned char []){73},
250,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "ECOLE TYPE 2",
.id = (unsigned char []){74},
.cost = 500,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
"ECOLE TYPE 2",
(unsigned char []){74},
500,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "UNIVERSITE",
.id = (unsigned char []){28, 29, 38, 39},
.cost = 2500,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
"UNIVERSITE",
(unsigned char []){28, 29, 38, 39},
2500,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "EGLISE ET CIMETIERE",
.id = (unsigned char []){10, 11, 20, 21},
.cost = 2500,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
"EGLISE ET CIMETIERE",
(unsigned char []){10, 11, 20, 21},
2500,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
// Others buildings
{
.name = "IMMEUBLE";
.id = (unsigned char []){5, 6, 15, 56},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0},
"IMMEUBLE";
(unsigned char []){5, 6, 15, 56},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
}
{
.name = "TOUR DE BUREAUX",
.id = (unsigned char []){7, 8, 17, 18},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
"TOUR DE BUREAUX",
(unsigned char []){7, 8, 17, 18},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "USINE",
.id = (unsigned char []){30, 31, 40, 41},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
"USINE",
(unsigned char []){30, 31, 40, 41},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "CASERNE DE POLICE",
.id = (unsigned char []){26, 27, 36, 37},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
"CASERNE DE POLICE",
(unsigned char []){26, 27, 36, 37},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "CASERNE DE POMPIERS",
.id = (unsigned char []){22, 23, 32, 33},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
"CASERNE DE POMPIERS",
(unsigned char []){22, 23, 32, 33},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
{
.name = "HOPITAL",
.id = (unsigned char []){24, 25, 34, 35},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
"HOPITAL",
(unsigned char []){24, 25, 34, 35},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0}
},
};

View File

@ -207,7 +207,7 @@ int keyboard_managment(struct calccity *calccity, struct camera *camera, struct
int build_mode = 0;
struct building selected_building = menu_1(calccity, camera, map, &build_mode);
if (build_mode)
if (build_mode == 1)
build(calccity, camera, map, &selected_building);
break;
@ -256,8 +256,8 @@ void build(struct calccity *calccity, struct camera *camera, struct map *map, st
dclear(C_WHITE);
main_display(calccity, camera, map, 1);
dprint_opt(4, 8, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "$%d %d,%d", building->cost, building->size[0], building->size[1]);
dprint_opt(4, 15, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "%s", building->name);
dprint_opt(4, 7, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "$%d %d,%d", building->cost, building->size[0], building->size[1]);
dprint_opt(4, 13, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "%s", building->name);
dupdate();
key = rtc_key();
@ -294,4 +294,9 @@ void build(struct calccity *calccity, struct camera *camera, struct map *map, st
}
if (t >= 0) timer_stop(t);
camera->cursor_size[0] = 8;
camera->cursor_size[1] = 8;
camera->cursor_x = 1;
camera->cursor_y = 1;
}

View File

@ -8,10 +8,10 @@
struct building menu_1(struct calccity *calccity, struct camera *camera, struct map *map, int *build_mode)
{
extern const bopti_image_t img_fn_1;
int key = 0, x = 0, y = 0;
int key = 0, end = 0, x = 0, y = 0;
struct building default_building = {
.name = "",
.name = "TEST",
.id = (unsigned char []){0},
.cost = 0,
.size = {1, 1},
@ -20,14 +20,11 @@ struct building menu_1(struct calccity *calccity, struct camera *camera, struct
.funds = {0}
};
while (key != KEY_ALPHA)
while (!end)
{
dclear(C_WHITE);
display_large_map(calccity, camera, map);
display_around(calccity, camera, 0);
main_display(calccity, camera, map, 0);
drect(3, 57, 19, 64, C_INVERT);
dimage(3, 11, &img_fn_1);
drect(9 * x + 4, 9 * y + 12, 9 * x + 4 + 7, 9 * y + 12 + 7, C_INVERT);
dupdate();
@ -52,14 +49,25 @@ struct building menu_1(struct calccity *calccity, struct camera *camera, struct
if (x < 2) x ++;
break;
case KEY_ALPHA:
end = 2;
break;
case KEY_SHIFT:
*build_mode = 1;
return buildings[x + y * 3];
end = 1;
break;
}
}
*build_mode = 0;
return default_building;
if (end == 1)
{
*build_mode = 1;
return buildings[x + y * 3];
}
else
{
*build_mode = 0;
return default_building;
}
}