1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

intermidiate comit

This commit is contained in:
Jørn Lomax
2014-05-12 17:29:16 +02:00
parent 7d4a80cea2
commit 3382be1430
4 changed files with 105 additions and 21 deletions

View File

@@ -96,16 +96,24 @@ void config_load()
// Read options
ReadFile(hFile, (void*)0x009AAC5C, 2155, &bytesRead, NULL);
CloseHandle(hFile);
if (RCT2_GLOBAL(0x009AB4C6, sint8) == 1)
return;
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, sint8) = gGeneral_config.edge_scrolling;
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, sint8) = gGeneral_config.currency_format; //i think this is curency
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) = gGeneral_config.measurement_format;
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FAHRENHEIT, sint8) = gGeneral_config.temperature_format;
//if (RCT2_GLOBAL(0x009AB4C6, sint8) == 1)
// return;
RCT2_GLOBAL(0x009AB4C6, sint8) = 1;
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FAHRENHEIT, sint8) = 1;
RCT2_GLOBAL(0x009AACBB, sint8) = 1;
RCT2_GLOBAL(0x009AACBD, sint16) = 0;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS))
RCT2_GLOBAL(0x009AACBD, sint16) = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) + 1) * 256;
RCT2_GLOBAL(0x009AA00D, sint8) = 1;
RCT2_GLOBAL(0x009AA00D, sint8) = 0;
}
}
@@ -122,7 +130,7 @@ void config_load()
RCT2_GLOBAL(0x009AACBD, sint16) = 0;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS))
RCT2_GLOBAL(0x009AACBD, sint16) = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) + 1) * 256;
RCT2_GLOBAL(0x009AA00D, sint8) = 1;
RCT2_GLOBAL(0x009AA00D, sint8) = 0; //no idea what this does
}
/**
@@ -144,7 +152,7 @@ void config_save()
// New config format
configuration_t gConfig;
general_configuration_t gGeneral_config;
static void config_parse_settings(FILE *fp);
static int config_get_line(FILE *fp, char *setting, char *value);
@@ -152,6 +160,7 @@ static int config_parse_setting(FILE *fp, char *setting);
static int config_parse_value(FILE *fp, char *value);
static int config_parse_section(FILE *fp, char *setting, char *value);
static void config_create_default(char *path);
static int config_parse_currency(char* currency);
static void config_error(char *msg);
/**
@@ -227,16 +236,20 @@ static void config_create_default(char *path)
{
FILE* fp;
if (!config_find_rct2_path(gConfig.game_path)) {
if (!config_find_rct2_path(gGeneral_config.game_path)) {
MessageBox(NULL, "Unable to find RCT2 installation directory. Please correct in config.ini.", "OpenRCT2", MB_OK);
strcpy(gConfig.game_path, "C:\\");
strcpy(gGeneral_config.game_path, "C:\\");
}
fp = fopen(path, "w");
fprintf(fp, "[general]\n");
fprintf(fp, "game_path = %s\n", gConfig.game_path);
fprintf(fp, "game_path = %s\n", gGeneral_config.game_path);
fprintf(fp, "screenshot_format = PNG\n");
fprintf(fp, "play_intro = false\n");
fprintf(fp, "edge_scrolling = true\n");
fprintf(fp, "currency = GBP");
fprintf(fp, "use_imperial = false\n");
fprintf(fp, "use_farenheit = false\n");
fclose(fp);
}
@@ -263,19 +276,51 @@ static void config_parse_settings(FILE *fp)
if (strcmp(setting, "game_path") == 0){
strcpy(gConfig.game_path, value);
strcpy(gGeneral_config.game_path, value);
} else if(strcmp(setting, "screenshot_format") == 0) {
if (strcmp(value, "png") == 0 || strcmp(value, "PNG") == 0) {
gConfig.screenshot_format = SCREENSHOT_FORMAT_PNG;
gGeneral_config.screenshot_format = SCREENSHOT_FORMAT_PNG;
} else if (strcmp(value, "1") == 0) { //TODO: REMOVE LINE AT LATER DATE WHEN EVERYONE HAS NEW CONFIG FORMAT
gConfig.screenshot_format = SCREENSHOT_FORMAT_PNG;
gGeneral_config.screenshot_format = SCREENSHOT_FORMAT_PNG;
} else {
gConfig.screenshot_format = SCREENSHOT_FORMAT_BMP;
gGeneral_config.screenshot_format = SCREENSHOT_FORMAT_BMP;
}
} else if (strcmp(setting, "play_intro") == 0) {
gConfig.play_intro = (strcmp(value, "true") == 0);
gGeneral_config.play_intro = (strcmp(value, "true") == 0);
}
else if (strcmp(setting, "edge_scrolling") == 0){
if (strcmp(value, "true") == 0){
gGeneral_config.edge_scrolling = 1;
}
else {
gGeneral_config.edge_scrolling = 0;
}
}
else if (strcmp(setting, "use_imperial") == 0){
if (strcmp(value, "true") == 0){
gGeneral_config.measurement_format = MEASUREMENT_FORMAT_IMPRIAL;
}
else{
gGeneral_config.measurement_format = MEASUREMENT_FORMAT_METRIC;
}
}
else if (strcmp(setting, "use_farenheit") == 0){
if (strcmp(value, "true") == 0){
gGeneral_config.temperature_format = TEMPERATURE_FORMAT_F;
}
else{
gGeneral_config.temperature_format = TEMPERATURE_FORMAT_C;
}
}
else if (strcmp(setting, "currency") == 0){
config_parse_currency(value);
}
}
//RCT2_GLOBAL(0x009AACBC, sint8) = CURRENCY_KRONA;
free(setting);
free(value);
free(section);
@@ -452,13 +497,51 @@ static int config_parse_section(FILE *fp, char *setting, char *value){
}
static int config_parse_currency(char* currency){
if (strcmp(currency, "GBP") == 0 || strcmp(currency, "£") == 0){
gGeneral_config.currency_format = CURRENCY_POUNDS;
}
else if(strcmp(currency, "USD") == 0 || strcmp(currency, "$") == 0){
gGeneral_config.currency_format = CURRENCY_DOLLARS;
}
else if(strcmp(currency, "FRF") == 0){
gGeneral_config.currency_format = CURRENCY_FRANC;
}
else if (strcmp(currency, "DEM") == 0){
gGeneral_config.currency_format = CURRENCY_DEUTSCHMARK;
}
else if(strcmp(currency, "YEN") == 0){
gGeneral_config.currency_format = CURRENCY_YEN;
}
else if (strcmp(currency, "ESP") == 0){
gGeneral_config.currency_format = CURRENCY_PESETA;
}
else if (strcmp(currency, "ITL") == 0){
gGeneral_config.currency_format = CURRENCY_LIRA;
}
else if (strcmp(currency, "NLG") == 0){
gGeneral_config.currency_format = CURRENCY_GUILDERS;
}
else if (strcmp(currency, "NOK") == 0 || strcmp(currency, "SEK") == 0 || strcmp(currency, "DEK") == 0){
gGeneral_config.currency_format = CURRENCY_KRONA;
}
else if (strcmp(currency, "EUR") == 0 || strcmp(currency, "") == 0){
gGeneral_config.currency_format = CURRENCY_EUROS;
}
else{
config_error("Invalid currency set in config file");
return -1;
}
return 1;
}
/**
* Error with config file. Print error message an quit the game
* @param msg Message to print in message box
*/
static void config_error(char *msg){
MessageBox(NULL, msg, "OpenRCT2", MB_OK);
//TODO:SHUT DOWN EVERYTHING!
exit(-1);
}