LoadGeneralParameters and associated functions (#20)
* Adds LoadGeneralParameters, EncodeLine functions
This commit is contained in:
commit
2927bd184d
3
Makefile
3
Makefile
|
|
@ -16,7 +16,8 @@ clean:
|
|||
test: build
|
||||
@echo "Building tests"
|
||||
@$(MAKE) -C test build
|
||||
test/build/c1tests
|
||||
@cp -r test/assets/DATA test/build
|
||||
@(cd test/build && ./c1tests)
|
||||
|
||||
run: build
|
||||
@echo "Running dethrace"
|
||||
|
|
|
|||
2
run.sh
2
run.sh
|
|
@ -8,5 +8,5 @@ set -eu
|
|||
#
|
||||
|
||||
CODE_DIR=$(pwd)
|
||||
cd ${DETHRACE_ROOT_DIR}
|
||||
ln -s $CODE_DIR ${DETHRACE_ROOT_DIR}
|
||||
${CODE_DIR}/src/DETHRACE/build/c1
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ br_error BrV1dbBegin() {
|
|||
return 4103;
|
||||
}
|
||||
|
||||
printf("BrV1dbBegin\n");
|
||||
|
||||
BrMemSet(&v1db, 0, sizeof(br_v1db_state));
|
||||
v1db.active = 1;
|
||||
BrRegistryNew(&v1db.reg_models);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ DEPS := $(OBJS:.o=.d)
|
|||
INC_DIRS := $(shell find $(SRC_DIR) -type d) $(BR_SRC_DIR)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
|
||||
CFLAGS ?= $(INC_FLAGS) -Wno-return-type -Wno-missing-declarations -Werror=implicit-function-declaration
|
||||
LDFLAGS ?= -lm
|
||||
CFLAGS ?= $(INC_FLAGS) -g -Wno-return-type -Wno-missing-declarations -Werror=implicit-function-declaration
|
||||
LDFLAGS ?= -lm -fno-pie
|
||||
|
||||
.PHONY: clean build test
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "br_types.h"
|
||||
#include "dr_types.h"
|
||||
|
||||
extern int gDim_amount;
|
||||
|
||||
// Offset: 0
|
||||
// Size: 56
|
||||
// EAX: pStr
|
||||
|
|
|
|||
|
|
@ -4,4 +4,6 @@
|
|||
#include "br_types.h"
|
||||
#include "dr_types.h"
|
||||
|
||||
extern float gRecovery_cost[3];
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "br_types.h"
|
||||
#include "dr_types.h"
|
||||
|
||||
extern br_scalar gAmbient_adjustment;
|
||||
|
||||
// Offset: 0
|
||||
// Size: 44
|
||||
void TurnOnPaletteConversion();
|
||||
|
|
|
|||
|
|
@ -199,6 +199,7 @@ void InitialiseApplication(int pArgc, char** pArgv) {
|
|||
// EDX: pArgv
|
||||
void InitialiseDeathRace(int pArgc, char** pArgv) {
|
||||
PDInitialiseSystem();
|
||||
|
||||
InitialiseApplication(pArgc, pArgv);
|
||||
//dword_112DF8 = 1; // never checked by game
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
#include "br_types.h"
|
||||
#include "dr_types.h"
|
||||
|
||||
extern int gCredits_per_rank[3];
|
||||
extern int gInitial_credits[3];
|
||||
extern int gInitial_rank;
|
||||
|
||||
// Offset: 0
|
||||
// Size: 115
|
||||
void AllocateSelf();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,24 @@
|
|||
#include "loading.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "displays.h"
|
||||
#include "errors.h"
|
||||
#include "globvars.h"
|
||||
#include "globvrkm.h"
|
||||
#include "graphics.h"
|
||||
#include "init.h"
|
||||
#include "newgame.h"
|
||||
#include "opponent.h"
|
||||
#include "pc-dos/dossys.h"
|
||||
#include "pedestrn.h"
|
||||
#include "sound.h"
|
||||
#include "utility.h"
|
||||
#include "world.h"
|
||||
|
||||
#define HITHER_MULTIPLIER 2.0f
|
||||
#define AMBIENT_MULTIPLIER 0.0099999998f
|
||||
|
||||
char* gWheel_actor_names[6];
|
||||
int gFunk_groove_flags[30];
|
||||
|
|
@ -13,7 +28,7 @@ char* gDrivable_car_names[6];
|
|||
char* gYour_car_names[2][6];
|
||||
char gDef_def_water_screen_name[32];
|
||||
tHeadup_info gHeadup_image_info[31];
|
||||
int gAllow_open_to_fail;
|
||||
int gAllow_open_to_fail = 1;
|
||||
br_material* gDestn_screen_mat;
|
||||
br_material* gSource_screen_mat;
|
||||
char* gRaces_file_names[9];
|
||||
|
|
@ -182,6 +197,146 @@ void LoadGeneralParameters() {
|
|||
int temp;
|
||||
char s[256];
|
||||
char* str;
|
||||
|
||||
PathCat(the_path, gApplication_path, "ACTORS");
|
||||
PathCat(the_path, the_path, "PROG.ACT");
|
||||
f = fopen(the_path, "rb");
|
||||
if (f) {
|
||||
fgets(s, 255, f);
|
||||
fclose(f);
|
||||
for (i = 0; i < strlen(gDecode_string); i++) {
|
||||
gDecode_string[i] -= 50;
|
||||
}
|
||||
|
||||
// trim trailing CRLF etc
|
||||
while (s[0] != '\0' && s[strlen(s) - 1] < 0x20) {
|
||||
s[strlen(s) - 1] = 0;
|
||||
}
|
||||
|
||||
if (strcmp(s, gDecode_string) == 0) {
|
||||
gDecode_thing = 0;
|
||||
printf("Expecting decrypted text files!\n");
|
||||
}
|
||||
|
||||
for (i = 0; i < strlen(gDecode_string); i++) {
|
||||
gDecode_string[i] -= 50;
|
||||
}
|
||||
}
|
||||
PathCat(the_path, gApplication_path, "GENERAL.TXT");
|
||||
f = DRfopen(the_path, "rt");
|
||||
if (!f) {
|
||||
FatalError(8);
|
||||
}
|
||||
gCamera_hither = GetAFloat(f) * HITHER_MULTIPLIER;
|
||||
gCamera_yon = GetAFloat(f);
|
||||
gCamera_angle = GetAFloat(f);
|
||||
gAmbient_adjustment = GetAFloat(f) * AMBIENT_MULTIPLIER;
|
||||
gDim_amount = GetAnInt(f);
|
||||
gInitial_rank = GetAnInt(f);
|
||||
GetThreeInts(f, &gInitial_credits[0], &gInitial_credits[1], &gInitial_credits[2]);
|
||||
GetThreeInts(f, &gCredits_per_rank[0], &gCredits_per_rank[1], &gCredits_per_rank[2]);
|
||||
gCar_crush_min_fold = GetAFloat(f);
|
||||
gCar_crush_max_fold = GetAFloat(f);
|
||||
gCar_crush_wibble = GetAFloat(f);
|
||||
gCar_crush_limit_deviant = GetAFloat(f);
|
||||
gCar_crush_split_chance = GetAFloat(f);
|
||||
gCar_crush_softness = GetAFloat(f);
|
||||
GetThreeFloats(f, &gRepair_cost[0], &gRepair_cost[1], &gRepair_cost[2]);
|
||||
GetThreeFloats(f, &gRecovery_cost[0], &gRecovery_cost[1], &gRecovery_cost[2]);
|
||||
GetThreeInts(f, &gPed_time_value[0], &gPed_time_value[1], &gPed_time_value[2]);
|
||||
if (gProgram_state.sausage_eater_mode) {
|
||||
for (i = 0; i < 7; i++) {
|
||||
GetALineAndDontArgue(f, s);
|
||||
}
|
||||
|
||||
GetThreeFloats(f, gCar_time_value, &gCar_time_value[1], &gCar_time_value[2]);
|
||||
GetThreeFloats(f, gCar_cred_value, &gCar_cred_value[1], &gCar_cred_value[2]);
|
||||
GetThreeInts(f, gWasted_time, &gWasted_time[1], &gWasted_time[2]);
|
||||
GetThreeInts(f, gWasted_creds, &gWasted_creds[1], &gWasted_creds[2]);
|
||||
GetThreeInts(f, gRoll_over_time, &gRoll_over_time[1], &gRoll_over_time[2]);
|
||||
GetThreeInts(f, gRoll_over_creds, &gRoll_over_creds[1], &gRoll_over_creds[2]);
|
||||
GetThreeInts(f, gCheck_point_cash, &gCheck_point_cash[1], &gCheck_point_cash[2]);
|
||||
} else {
|
||||
GetThreeFloats(f, gCar_time_value, &gCar_time_value[1], &gCar_time_value[2]);
|
||||
GetThreeFloats(f, gCar_cred_value, &gCar_cred_value[1], &gCar_cred_value[2]);
|
||||
GetThreeInts(f, gWasted_time, &gWasted_time[1], &gWasted_time[2]);
|
||||
GetThreeInts(f, gWasted_creds, &gWasted_creds[1], &gWasted_creds[2]);
|
||||
GetThreeInts(f, gRoll_over_time, &gRoll_over_time[1], &gRoll_over_time[2]);
|
||||
GetThreeInts(f, gRoll_over_creds, &gRoll_over_creds[1], &gRoll_over_creds[2]);
|
||||
GetThreeInts(f, gCheck_point_cash, &gCheck_point_cash[1], &gCheck_point_cash[2]);
|
||||
for (i = 0; i < 7; i++) {
|
||||
GetALineAndDontArgue(f, s);
|
||||
}
|
||||
}
|
||||
GetThreeInts(f, gJump_start_fine, &gJump_start_fine[1], &gJump_start_fine[2]);
|
||||
GetThreeInts(f, gPoints_per_second, &gPoints_per_second[1], &gPoints_per_second[2]);
|
||||
GetThreeInts(f, gCunning_stunt_bonus, &gCunning_stunt_bonus[1], &gCunning_stunt_bonus[2]);
|
||||
GetAString(f, gBasic_car_names[0]);
|
||||
GetAString(f, gBasic_car_names[1]);
|
||||
gKnobbled_frame_period = GetAnInt(f);
|
||||
if (gKnobbled_frame_period) {
|
||||
gKnobbled_frame_period = 1000 / gKnobbled_frame_period;
|
||||
}
|
||||
gOpponent_nastyness_frigger = GetAFloat(f);
|
||||
ParseSpecialVolume(f, &gDefault_default_water_spec_vol, gDef_def_water_screen_name);
|
||||
GetALineAndDontArgue(f, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
for (i = 0; i < 5; i++) {
|
||||
sscanf(str, "%d", &gInitial_net_credits[i]);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
}
|
||||
|
||||
gTag_start_time = 1000 * GetAnInt(f);
|
||||
gFox_start_time = 1000 * GetAnInt(f);
|
||||
|
||||
GetALineAndDontArgue(f, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
for (i = 0; i < 7; i++) {
|
||||
sscanf(str, "%f", &gNet_repair_cost[i]);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
}
|
||||
GetALineAndDontArgue(f, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
for (i = 0; i < 7; i++) {
|
||||
sscanf(str, "%f", &gNet_recovery_cost[i]);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
}
|
||||
GetALineAndDontArgue(f, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
for (i = 0; i < 7; i++) {
|
||||
sscanf(str, "%f", &gNet_softness[i]);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
}
|
||||
GetALineAndDontArgue(f, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
for (i = 0; i < 7; i++) {
|
||||
sscanf(str, "%f", &gNet_offensive[i]);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
}
|
||||
GetALineAndDontArgue(f, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
for (i = 0; i < 7; i++) {
|
||||
sscanf(str, "%d", &gNet_target[i]);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
}
|
||||
|
||||
gMin_respawn_time = 1000 * GetAnInt(f);
|
||||
gRespawn_variance = 1000 * GetAnInt(f);
|
||||
gDemo_rank = GetAnInt(f);
|
||||
gDemo_armour = GetAnInt(f);
|
||||
gDemo_power = GetAnInt(f);
|
||||
gDemo_offensive = GetAnInt(f);
|
||||
for (i = 0; i < 5; i++) {
|
||||
gDemo_opponents[i] = GetAnInt(f);
|
||||
}
|
||||
|
||||
gGravity_multiplier = GetAFloat(f);
|
||||
gZombie_factor = GetAFloat(f);
|
||||
gCut_delay_1 = GetAFloat(f);
|
||||
gCut_delay_2 = GetAFloat(f);
|
||||
gCut_delay_3 = GetAFloat(f);
|
||||
gCut_delay_4 = 1.0f;
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
// Offset: 3472
|
||||
|
|
@ -822,6 +977,11 @@ int GetAnInt(FILE* pF) {
|
|||
char s[256];
|
||||
char* str;
|
||||
int result;
|
||||
|
||||
GetALineAndDontArgue(pF, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
sscanf(str, "%d", &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Offset: 33828
|
||||
|
|
@ -831,6 +991,11 @@ float GetAFloat(FILE* pF) {
|
|||
char s[256];
|
||||
char* str;
|
||||
float result;
|
||||
|
||||
GetALineAndDontArgue(pF, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
sscanf(str, "%f", &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Offset: 33932
|
||||
|
|
@ -850,6 +1015,12 @@ float GetAFloatPercent(FILE* pF) {
|
|||
void GetPairOfFloats(FILE* pF, float* pF1, float* pF2) {
|
||||
char s[256];
|
||||
char* str;
|
||||
|
||||
GetALineAndDontArgue(pF, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
sscanf(str, "%f", pF1);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
sscanf(str, "%f", pF2);
|
||||
}
|
||||
|
||||
// Offset: 34172
|
||||
|
|
@ -861,6 +1032,14 @@ void GetPairOfFloats(FILE* pF, float* pF1, float* pF2) {
|
|||
void GetThreeFloats(FILE* pF, float* pF1, float* pF2, float* pF3) {
|
||||
char s[256];
|
||||
char* str;
|
||||
|
||||
GetALineAndDontArgue(pF, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
sscanf(str, "%f", pF1);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
sscanf(str, "%f", pF2);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
sscanf(str, "%f", pF3);
|
||||
}
|
||||
|
||||
// Offset: 34344
|
||||
|
|
@ -871,6 +1050,12 @@ void GetThreeFloats(FILE* pF, float* pF1, float* pF2, float* pF3) {
|
|||
void GetPairOfInts(FILE* pF, int* pF1, int* pF2) {
|
||||
char s[256];
|
||||
char* str;
|
||||
|
||||
GetALineAndDontArgue(pF, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
sscanf(str, "%d", pF1);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
sscanf(str, "%d", pF2);
|
||||
}
|
||||
|
||||
// Offset: 34476
|
||||
|
|
@ -882,6 +1067,14 @@ void GetPairOfInts(FILE* pF, int* pF1, int* pF2) {
|
|||
void GetThreeInts(FILE* pF, int* pF1, int* pF2, int* pF3) {
|
||||
char s[256];
|
||||
char* str;
|
||||
|
||||
GetALineAndDontArgue(pF, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
sscanf(str, "%d", pF1);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
sscanf(str, "%d", pF2);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
sscanf(str, "%d", pF3);
|
||||
}
|
||||
|
||||
// Offset: 34648
|
||||
|
|
@ -904,12 +1097,23 @@ void GetThreeIntsAndAString(FILE* pF, int* pF1, int* pF2, int* pF3, char* pS) {
|
|||
void GetFourInts(FILE* pF, int* pF1, int* pF2, int* pF3, int* pF4) {
|
||||
char s[256];
|
||||
char* str;
|
||||
|
||||
GetALineAndDontArgue(pF, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
sscanf(str, "%d", pF1);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
sscanf(str, "%d", pF2);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
sscanf(str, "%d", pF3);
|
||||
str = strtok(NULL, "\t ,/");
|
||||
sscanf(str, "%d", pF4);
|
||||
}
|
||||
|
||||
// Offset: 35056
|
||||
// Size: 51
|
||||
// EAX: pF
|
||||
br_scalar GetAScalar(FILE* pF) {
|
||||
return GetAFloat(pF);
|
||||
}
|
||||
|
||||
// Offset: 35108
|
||||
|
|
@ -1000,6 +1204,10 @@ void GetThreeFloatPercents(FILE* pF, float* pF1, float* pF2, float* pF3) {
|
|||
void GetAString(FILE* pF, char* pString) {
|
||||
char s[256];
|
||||
char* str;
|
||||
|
||||
GetALineAndDontArgue(pF, s);
|
||||
str = strtok(s, "\t ,/");
|
||||
strcpy(pString, str);
|
||||
}
|
||||
|
||||
// Offset: 36396
|
||||
|
|
@ -1048,8 +1256,89 @@ FILE* OldDRfopen(char* pFilename, char* pMode) {
|
|||
tPath_name CD_dir;
|
||||
tPath_name path_file;
|
||||
tPath_name source_check;
|
||||
static int source_exists;
|
||||
static int source_exists = 1;
|
||||
int len;
|
||||
int c;
|
||||
|
||||
fp = fopen(pFilename, pMode);
|
||||
|
||||
if (fp) {
|
||||
len = strlen(pFilename) + 1;
|
||||
if (gDecode_thing != 0) {
|
||||
if (strcmp(&pFilename[len - 4], ".TXT") != 0
|
||||
&& strcmp(&pFilename[len - 12], "DKEYMAP0.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 12], "DKEYMAP1.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 12], "DKEYMAP2.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 12], "DKEYMAP3.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 12], "KEYMAP_0.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 12], "KEYMAP_1.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 12], "KEYMAP_2.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 12], "KEYMAP_3.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 11], "OPTIONS.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 12], "KEYNAMES.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 10], "KEYMAP.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 9], "PATHS.TXT") != 0
|
||||
&& strcmp(&pFilename[len - 11], "PRATCAM.TXT") != 0) {
|
||||
|
||||
c = fgetc(fp);
|
||||
if (c != gDecode_thing) {
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
ungetc(c, fp);
|
||||
return fp;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gCD_fully_installed) {
|
||||
return fp;
|
||||
}
|
||||
if (source_exists == 1) {
|
||||
strcpy(path_file, "DATA");
|
||||
strcat(path_file, gDir_separator);
|
||||
strcat(path_file, "PATHS.TXT");
|
||||
|
||||
if (!PDCheckDriveExists(path_file)) {
|
||||
source_exists = 0;
|
||||
return NULL;
|
||||
}
|
||||
test1 = fopen(path_file, "rt");
|
||||
if (!test1) {
|
||||
source_exists = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GetALineAndDontArgue(test1, source_check);
|
||||
strcat(source_check, gDir_separator);
|
||||
strcat(source_check, "DATA");
|
||||
strcat(source_check, gDir_separator);
|
||||
strcat(source_check, "GENERAL.TXT");
|
||||
|
||||
fclose(test1);
|
||||
if (PDCheckDriveExists(source_check)) {
|
||||
source_exists++;
|
||||
} else {
|
||||
PDFatalError("Carmageddon CD not in drive.");
|
||||
if (gCD_fully_installed) {
|
||||
source_exists = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!source_exists) {
|
||||
return fp;
|
||||
}
|
||||
|
||||
data_dir = strstr(pFilename, "DATA");
|
||||
if (data_dir != NULL) {
|
||||
if (GetCDPathFromPathsTxtFile(CD_dir)) {
|
||||
strcat(CD_dir, gDir_separator);
|
||||
strcat(CD_dir, data_dir);
|
||||
if (PDCheckDriveExists(CD_dir)) {
|
||||
fp = fopen(CD_dir, pMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
// Offset: 38332
|
||||
|
|
@ -1070,6 +1359,20 @@ FILE* DRfopen(char* pFilename, char* pMode) {
|
|||
FILE* result;
|
||||
tPath_name CD_dir;
|
||||
char msg[336];
|
||||
|
||||
result = OldDRfopen(pFilename, pMode);
|
||||
if (!result && !gAllow_open_to_fail) {
|
||||
if (GetCDPathFromPathsTxtFile(CD_dir) && !PDCheckDriveExists(CD_dir)) {
|
||||
if (gMisc_strings[0]) {
|
||||
PDFatalError(GetMiscString(243));
|
||||
} else {
|
||||
PDFatalError("Could not find the Carmageddon CD");
|
||||
}
|
||||
sprintf(msg, "DRfopen( \"%s\", \"%s\" ) failed", pFilename, pMode);
|
||||
PDFatalError(msg);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Offset: 38604
|
||||
|
|
@ -1083,6 +1386,7 @@ int GetCDPathFromPathsTxtFile(char* pPath_name) {
|
|||
|
||||
if (!got_it_already) {
|
||||
sprintf(paths_txt, "%s%s%s", gApplication_path, gDir_separator, "PATHS.TXT");
|
||||
printf("%s\n", paths_txt);
|
||||
paths_txt_fp = fopen(paths_txt, "rt");
|
||||
if (!paths_txt_fp) {
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include "newgame.h"
|
||||
|
||||
char* gBasic_car_names[2];
|
||||
char x[] = "xxxxxxxx.TXT";
|
||||
char y[] = "yyyyyyyy.TXT";
|
||||
char* gBasic_car_names[2] = { x, y };
|
||||
tNet_game_options gNet_settings[8];
|
||||
tRadio_bastards gRadio_bastards[11];
|
||||
tJoinable_game gGames_to_join[6];
|
||||
|
|
|
|||
|
|
@ -4,6 +4,29 @@
|
|||
#include "br_types.h"
|
||||
#include "dr_types.h"
|
||||
|
||||
extern char* gBasic_car_names[2];
|
||||
extern tNet_game_options gNet_settings[8];
|
||||
extern tRadio_bastards gRadio_bastards[11];
|
||||
extern tJoinable_game gGames_to_join[6];
|
||||
extern tNet_game_options* gOptions;
|
||||
extern int gNet_target[7];
|
||||
extern int gLast_graph_sel;
|
||||
extern tInterface_spec* gThe_interface_spec;
|
||||
extern tNet_sequence_type gNet_race_sequence;
|
||||
extern tNet_game_type gLast_game_type;
|
||||
extern int gCurrent_net_game_count;
|
||||
extern tU32 gAnne_flic_data_length;
|
||||
extern int gShifted_default_yet;
|
||||
extern int gNet_storage_allocated;
|
||||
extern tU8* gFrank_flic_data;
|
||||
extern char* gNet_name;
|
||||
extern tU32 gFrank_flic_data_length;
|
||||
extern tU8* gAnne_flic_data;
|
||||
extern int gLast_net_choose_box;
|
||||
extern int gCurrent_game_selection;
|
||||
extern int gRace_index;
|
||||
extern int gRadio_selected;
|
||||
|
||||
// Offset: 0
|
||||
// Size: 149
|
||||
void StartRollingPlayerNamesIn();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "br_types.h"
|
||||
#include "dr_types.h"
|
||||
|
||||
extern float gOpponent_nastyness_frigger;
|
||||
|
||||
// Offset: 0
|
||||
// Size: 137
|
||||
// EAX: pThe_actor
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
#include "br_types.h"
|
||||
#include "dr_types.h"
|
||||
|
||||
extern int gMin_respawn_time;
|
||||
extern int gRespawn_variance;
|
||||
extern float gZombie_factor;
|
||||
|
||||
// Offset: 0
|
||||
// Size: 152
|
||||
// EAX: pModel
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ tU32 gOther_long_key[] = { 0x26D6A867, 0x1B45DDB6, 0x13227E32, 0x3794C215 };
|
|||
char* gMisc_strings[250];
|
||||
int gIn_check_quit;
|
||||
tU32 gLost_time;
|
||||
int gEncryption_method = 1;
|
||||
int gEncryption_method = 0;
|
||||
br_pixelmap* g16bit_palette;
|
||||
br_pixelmap* gSource_for_16bit_palette;
|
||||
|
||||
|
|
@ -32,11 +32,6 @@ int CheckQuit() {
|
|||
int got_as_far_as_verify;
|
||||
}
|
||||
|
||||
// Offset: 144
|
||||
// Size: 50
|
||||
double sqr(double pN) {
|
||||
}
|
||||
|
||||
// Offset: 196
|
||||
// Size: 542
|
||||
// EAX: pS
|
||||
|
|
@ -47,6 +42,80 @@ void EncodeLine(char* pS) {
|
|||
char* key;
|
||||
unsigned char c;
|
||||
FILE* test;
|
||||
|
||||
tPath_name test_path;
|
||||
char temp[256];
|
||||
|
||||
len = strlen(pS);
|
||||
key = (char*)gLong_key;
|
||||
if (!gEncryption_method) {
|
||||
strcpy(test_path, gApplication_path);
|
||||
strcat(test_path, gDir_separator);
|
||||
strcat(test_path, "GENERAL.TXT");
|
||||
|
||||
test = fopen(test_path, "rt");
|
||||
if (test) {
|
||||
fgets(temp, 256, test);
|
||||
if (temp[0] != '@') {
|
||||
gEncryption_method = 2;
|
||||
} else {
|
||||
gEncryption_method = 1;
|
||||
EncodeLine(&temp[1]);
|
||||
temp[7] = '\0';
|
||||
if (strcmp(&temp[1], "0.01\t\t") != 0) {
|
||||
gEncryption_method = 2;
|
||||
}
|
||||
}
|
||||
fclose(test);
|
||||
} else {
|
||||
gEncryption_method = 2;
|
||||
}
|
||||
}
|
||||
while (len > 0 && (pS[len - 1] == '\r' || pS[len - 1] == '\n')) {
|
||||
--len;
|
||||
pS[len] = 0;
|
||||
}
|
||||
|
||||
seed = len % 16;
|
||||
for (i = 0; i < len; i++) {
|
||||
c = pS[i];
|
||||
if (i >= 2) {
|
||||
if (pS[i - 1] == '/' && pS[i - 2] == '/') {
|
||||
key = (char*)gOther_long_key;
|
||||
}
|
||||
}
|
||||
if (gEncryption_method == 1) {
|
||||
if (c == '\t') {
|
||||
c = 0x80;
|
||||
}
|
||||
c -= 0x20;
|
||||
if (!(c & 0x80)) {
|
||||
c = (c ^ key[seed]) & 0x7f;
|
||||
c += 0x20;
|
||||
}
|
||||
seed += 7;
|
||||
seed = seed % 16;
|
||||
|
||||
if (c == 0x80) {
|
||||
c = '\t';
|
||||
}
|
||||
} else {
|
||||
if (c == '\t') {
|
||||
c = 0x9f;
|
||||
}
|
||||
c -= 0x20;
|
||||
c = (c ^ key[seed]) & 0x7f;
|
||||
c += 0x20;
|
||||
|
||||
seed += 7;
|
||||
seed = seed % 16;
|
||||
|
||||
if (c == 0x9f) {
|
||||
c = '\t';
|
||||
}
|
||||
}
|
||||
pS[i] = c;
|
||||
}
|
||||
}
|
||||
|
||||
// Offset: 740
|
||||
|
|
@ -126,8 +195,9 @@ char* GetALineWithNoPossibleService(FILE* pF, /*unsigned*/ char* pS) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (ch != -1)
|
||||
if (ch != -1) {
|
||||
ungetc(ch, pF);
|
||||
}
|
||||
} while (!isalnum(s[0])
|
||||
&& s[0] != '-'
|
||||
&& s[0] != '.'
|
||||
|
|
@ -172,7 +242,9 @@ char* GetALineAndDontArgue(FILE* pF, char* pS) {
|
|||
// EDX: pStr_1
|
||||
// EBX: pStr_2
|
||||
void PathCat(char* pDestn_str, char* pStr_1, char* pStr_2) {
|
||||
strcpy(pDestn_str, pStr_1);
|
||||
if (pDestn_str != pStr_1) { // Added to avoid strcpy overlap checks
|
||||
strcpy(pDestn_str, pStr_1);
|
||||
}
|
||||
if (strlen(pStr_2) != 0) {
|
||||
strcat(pDestn_str, gDir_separator);
|
||||
strcat(pDestn_str, pStr_2);
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@
|
|||
#include "br_types.h"
|
||||
#include "dr_types.h"
|
||||
|
||||
extern char* gMisc_strings[250];
|
||||
extern int gEncryption_method;
|
||||
|
||||
// Offset: 0
|
||||
// Size: 144
|
||||
int CheckQuit();
|
||||
|
||||
// Offset: 144
|
||||
// Size: 50
|
||||
double sqr(double pN);
|
||||
|
||||
// Offset: 196
|
||||
// Size: 542
|
||||
// EAX: pS
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
#include "world.h"
|
||||
|
||||
#include "brender.h"
|
||||
#include "loading.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
br_actor* gActor_array[500];
|
||||
float* gGroove_funk_bindings[960];
|
||||
br_actor* gDelete_list[500];
|
||||
|
|
@ -872,6 +877,23 @@ int GetCarSimplificationLevel() {
|
|||
// EBX: pScreen_name_str
|
||||
void ParseSpecialVolume(FILE* pF, tSpecial_volume* pSpec, char* pScreen_name_str) {
|
||||
char s[256];
|
||||
pSpec->gravity_multiplier = GetAScalar(pF);
|
||||
pSpec->viscosity_multiplier = GetAScalar(pF);
|
||||
pSpec->car_damage_per_ms = GetAScalar(pF);
|
||||
pSpec->ped_damage_per_ms = GetAScalar(pF);
|
||||
pSpec->camera_special_effect_index = GetAnInt(pF);
|
||||
pSpec->sky_col = GetAnInt(pF);
|
||||
|
||||
GetAString(pF, s);
|
||||
if (pScreen_name_str) {
|
||||
strcpy(pScreen_name_str, s);
|
||||
} else {
|
||||
pSpec->screen_material = BrMaterialFind(s);
|
||||
}
|
||||
pSpec->entry_noise = GetAnInt(pF);
|
||||
pSpec->exit_noise = GetAnInt(pF);
|
||||
pSpec->engine_noise_index = GetAnInt(pF);
|
||||
pSpec->material_modifier_index = GetAnInt(pF);
|
||||
}
|
||||
|
||||
// Offset: 23584
|
||||
|
|
|
|||
|
|
@ -0,0 +1,316 @@
|
|||
// Based on https://gist.github.com/jvranish/4441299
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <imagehlp.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <err.h>
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
static int stack_nbr = 0;
|
||||
static char _program_name[1024];
|
||||
|
||||
/* Resolve symbol name and source location given the path to the executable
|
||||
and an address */
|
||||
int addr2line(char const* const program_name, void const* const addr) {
|
||||
char addr2line_cmd[512] = { 0 };
|
||||
|
||||
/* have addr2line map the address to the relent line in the code */
|
||||
#ifdef __APPLE__
|
||||
/* apple does things differently... */
|
||||
sprintf(addr2line_cmd, "atos -o %.256s %p", program_name, addr);
|
||||
#else
|
||||
sprintf(addr2line_cmd, "addr2line -f -p -e %.256s %p", program_name, addr);
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "%d: ", stack_nbr++);
|
||||
return system(addr2line_cmd);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void windows_print_stacktrace(CONTEXT* context) {
|
||||
SymInitialize(GetCurrentProcess(), 0, true);
|
||||
|
||||
STACKFRAME frame = { 0 };
|
||||
|
||||
/* setup initial stack frame */
|
||||
frame.AddrPC.Offset = context->Eip;
|
||||
frame.AddrPC.Mode = AddrModeFlat;
|
||||
frame.AddrStack.Offset = context->Esp;
|
||||
frame.AddrStack.Mode = AddrModeFlat;
|
||||
frame.AddrFrame.Offset = context->Ebp;
|
||||
frame.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
while (StackWalk(IMAGE_FILE_MACHINE_I386,
|
||||
GetCurrentProcess(),
|
||||
GetCurrentThread(),
|
||||
&frame,
|
||||
context,
|
||||
0,
|
||||
SymFunctionTableAccess,
|
||||
SymGetModuleBase,
|
||||
0)) {
|
||||
addr2line(_program_name, (void*)frame.AddrPC.Offset);
|
||||
}
|
||||
|
||||
SymCleanup(GetCurrentProcess());
|
||||
}
|
||||
|
||||
LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS* ExceptionInfo) {
|
||||
switch (ExceptionInfo->ExceptionRecord->ExceptionCode) {
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
fputs("Error: EXCEPTION_ACCESS_VIOLATION\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
||||
fputs("Error: EXCEPTION_ARRAY_BOUNDS_EXCEEDED\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_BREAKPOINT:
|
||||
fputs("Error: EXCEPTION_BREAKPOINT\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
||||
fputs("Error: EXCEPTION_DATATYPE_MISALIGNMENT\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
||||
fputs("Error: EXCEPTION_FLT_DENORMAL_OPERAND\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
||||
fputs("Error: EXCEPTION_FLT_DIVIDE_BY_ZERO\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_FLT_INEXACT_RESULT:
|
||||
fputs("Error: EXCEPTION_FLT_INEXACT_RESULT\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_FLT_INVALID_OPERATION:
|
||||
fputs("Error: EXCEPTION_FLT_INVALID_OPERATION\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_FLT_OVERFLOW:
|
||||
fputs("Error: EXCEPTION_FLT_OVERFLOW\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_FLT_STACK_CHECK:
|
||||
fputs("Error: EXCEPTION_FLT_STACK_CHECK\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_FLT_UNDERFLOW:
|
||||
fputs("Error: EXCEPTION_FLT_UNDERFLOW\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
||||
fputs("Error: EXCEPTION_ILLEGAL_INSTRUCTION\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_IN_PAGE_ERROR:
|
||||
fputs("Error: EXCEPTION_IN_PAGE_ERROR\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
||||
fputs("Error: EXCEPTION_INT_DIVIDE_BY_ZERO\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_INT_OVERFLOW:
|
||||
fputs("Error: EXCEPTION_INT_OVERFLOW\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_INVALID_DISPOSITION:
|
||||
fputs("Error: EXCEPTION_INVALID_DISPOSITION\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
|
||||
fputs("Error: EXCEPTION_NONCONTINUABLE_EXCEPTION\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_PRIV_INSTRUCTION:
|
||||
fputs("Error: EXCEPTION_PRIV_INSTRUCTION\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_SINGLE_STEP:
|
||||
fputs("Error: EXCEPTION_SINGLE_STEP\n", stderr);
|
||||
break;
|
||||
case EXCEPTION_STACK_OVERFLOW:
|
||||
fputs("Error: EXCEPTION_STACK_OVERFLOW\n", stderr);
|
||||
break;
|
||||
default:
|
||||
fputs("Error: Unrecognized Exception\n", stderr);
|
||||
break;
|
||||
}
|
||||
fflush(stderr);
|
||||
/* If this is a stack overflow then we can't walk the stack, so just show
|
||||
where the error happened */
|
||||
if (EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode) {
|
||||
windows_print_stacktrace(ExceptionInfo->ContextRecord);
|
||||
} else {
|
||||
addr2line(_program_name, (void*)ExceptionInfo->ContextRecord->Eip);
|
||||
}
|
||||
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
void set_signal_handler(char* program_name) {
|
||||
strcpy(_program_name, program_name);
|
||||
SetUnhandledExceptionFilter(windows_exception_handler);
|
||||
}
|
||||
#else
|
||||
|
||||
#define MAX_STACK_FRAMES 64
|
||||
static void* stack_traces[MAX_STACK_FRAMES];
|
||||
|
||||
void posix_print_stack_trace() {
|
||||
int i, trace_size = 0;
|
||||
char** messages = (char**)NULL;
|
||||
|
||||
fputs("\nStack trace:\n", stderr);
|
||||
|
||||
trace_size = backtrace(stack_traces, MAX_STACK_FRAMES);
|
||||
messages = backtrace_symbols(stack_traces, trace_size);
|
||||
|
||||
/* skip the first couple stack frames (as they are this function and
|
||||
our handler) and also skip the last frame as it's (always?) junk. */
|
||||
for (i = 3; i < (trace_size - 1); ++i) {
|
||||
if (addr2line(_program_name, stack_traces[i]) != 0) {
|
||||
printf(" error determining line # for: %s\n", messages[i]);
|
||||
}
|
||||
}
|
||||
if (messages) {
|
||||
free(messages);
|
||||
}
|
||||
}
|
||||
|
||||
void posix_signal_handler(int sig, siginfo_t* siginfo, void* context) {
|
||||
(void)context;
|
||||
fputs("\n******************\n", stderr);
|
||||
|
||||
switch (sig) {
|
||||
case SIGSEGV:
|
||||
fputs("Caught SIGSEGV\n", stderr);
|
||||
break;
|
||||
case SIGINT:
|
||||
fputs("Caught SIGINT\n", stderr);
|
||||
break;
|
||||
case SIGFPE:
|
||||
switch (siginfo->si_code) {
|
||||
case FPE_INTDIV:
|
||||
fputs("Caught SIGFPE: FPE_INTDIV\n", stderr);
|
||||
break;
|
||||
case FPE_INTOVF:
|
||||
fputs("Caught SIGFPE: FPE_INTOVF\n", stderr);
|
||||
break;
|
||||
case FPE_FLTDIV:
|
||||
fputs("Caught SIGFPE: FPE_FLTDIV\n", stderr);
|
||||
break;
|
||||
case FPE_FLTOVF:
|
||||
fputs("Caught SIGFPE: FPE_FLTOVF\n", stderr);
|
||||
break;
|
||||
case FPE_FLTUND:
|
||||
fputs("Caught SIGFPE: FPE_FLTUND\n", stderr);
|
||||
break;
|
||||
case FPE_FLTRES:
|
||||
fputs("Caught SIGFPE: FPE_FLTRES\n", stderr);
|
||||
break;
|
||||
case FPE_FLTINV:
|
||||
fputs("Caught SIGFPE: FPE_FLTINV\n", stderr);
|
||||
break;
|
||||
case FPE_FLTSUB:
|
||||
fputs("Caught SIGFPE: FPE_FLTSUB\n", stderr);
|
||||
break;
|
||||
default:
|
||||
fputs("Caught SIGFPE: Arithmetic Exception\n", stderr);
|
||||
break;
|
||||
}
|
||||
case SIGILL:
|
||||
switch (siginfo->si_code) {
|
||||
case ILL_ILLOPC:
|
||||
fputs("Caught SIGILL: ILL_ILLOPC\n", stderr);
|
||||
break;
|
||||
case ILL_ILLOPN:
|
||||
fputs("Caught SIGILL: ILL_ILLOPN\n", stderr);
|
||||
break;
|
||||
case ILL_ILLADR:
|
||||
fputs("Caught SIGILL: ILL_ILLADR\n", stderr);
|
||||
break;
|
||||
case ILL_ILLTRP:
|
||||
fputs("Caught SIGILL: ILL_ILLTRP\n", stderr);
|
||||
break;
|
||||
case ILL_PRVOPC:
|
||||
fputs("Caught SIGILL: ILL_PRVOPC\n", stderr);
|
||||
break;
|
||||
case ILL_PRVREG:
|
||||
fputs("Caught SIGILL: ILL_PRVREG\n", stderr);
|
||||
break;
|
||||
case ILL_COPROC:
|
||||
fputs("Caught SIGILL: ILL_COPROC\n", stderr);
|
||||
break;
|
||||
case ILL_BADSTK:
|
||||
fputs("Caught SIGILL: ILL_BADSTK\n", stderr);
|
||||
break;
|
||||
default:
|
||||
fputs("Caught SIGILL: Illegal Instruction\n", stderr);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SIGTERM:
|
||||
fputs("Caught SIGTERM\n", stderr);
|
||||
break;
|
||||
case SIGABRT:
|
||||
fputs("Caught SIGABRT\n", stderr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
fputs("******************\n", stderr);
|
||||
posix_print_stack_trace();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static uint8_t alternate_stack[SIGSTKSZ];
|
||||
void set_signal_handler(char* program_name) {
|
||||
|
||||
strcpy(_program_name, program_name);
|
||||
|
||||
/* setup alternate stack */
|
||||
{
|
||||
stack_t ss = {};
|
||||
/* malloc is usually used here, I'm not 100% sure my static allocation
|
||||
is valid but it seems to work just fine. */
|
||||
ss.ss_sp = (void*)alternate_stack;
|
||||
ss.ss_size = SIGSTKSZ;
|
||||
ss.ss_flags = 0;
|
||||
|
||||
if (sigaltstack(&ss, NULL) != 0) {
|
||||
err(1, "sigaltstack");
|
||||
}
|
||||
}
|
||||
|
||||
/* register our signal handlers */
|
||||
{
|
||||
struct sigaction sig_action = {};
|
||||
sig_action.sa_sigaction = posix_signal_handler;
|
||||
sigemptyset(&sig_action.sa_mask);
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* for some reason we backtrace() doesn't work on osx
|
||||
when we use an alternate stack */
|
||||
sig_action.sa_flags = SA_SIGINFO;
|
||||
#else
|
||||
sig_action.sa_flags = SA_SIGINFO | SA_ONSTACK;
|
||||
#endif
|
||||
|
||||
if (sigaction(SIGSEGV, &sig_action, NULL) != 0) {
|
||||
err(1, "sigaction");
|
||||
}
|
||||
if (sigaction(SIGFPE, &sig_action, NULL) != 0) {
|
||||
err(1, "sigaction");
|
||||
}
|
||||
if (sigaction(SIGINT, &sig_action, NULL) != 0) {
|
||||
err(1, "sigaction");
|
||||
}
|
||||
if (sigaction(SIGILL, &sig_action, NULL) != 0) {
|
||||
err(1, "sigaction");
|
||||
}
|
||||
if (sigaction(SIGTERM, &sig_action, NULL) != 0) {
|
||||
err(1, "sigaction");
|
||||
}
|
||||
if (sigaction(SIGABRT, &sig_action, NULL) != 0) {
|
||||
err(1, "sigaction");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#include "new/stack_trace_handler.h"
|
||||
#include "pc-dos/dossys.h"
|
||||
|
||||
extern int _main(int pArgc, char* pArgv[]);
|
||||
|
|
@ -5,6 +6,7 @@ extern int _main(int pArgc, char* pArgv[]);
|
|||
// EAX: pArgc
|
||||
// EDX: pArgv
|
||||
// Moved from pc-dos/dossys.c to enable unit testing
|
||||
int main(int pArgc, char* pArgv[]) {
|
||||
return _main(pArgc, pArgv);
|
||||
int main(int argc, char* argv[]) {
|
||||
set_signal_handler(argv[0]);
|
||||
return _main(argc, argv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,6 @@
|
|||
#include "pc-dos/dossys.h"
|
||||
|
||||
void test_dossys_PDInitialiseSystem() {
|
||||
|
||||
FILE* file = fopen("/tmp/KEYBOARD.COK", "wt");
|
||||
fprintf(file, "abcdef");
|
||||
fclose(file);
|
||||
|
||||
PDInitialiseSystem();
|
||||
TEST_ASSERT_EQUAL_STRING("abc", gASCII_table);
|
||||
TEST_ASSERT_EQUAL_STRING("def", gASCII_shift_table);
|
||||
|
|
|
|||
|
|
@ -4,27 +4,47 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "common/globvars.h"
|
||||
#include "common/init.h"
|
||||
#include "common/loading.h"
|
||||
#include "common/newgame.h"
|
||||
|
||||
void test_loading_GetCDPathFromPathsTxtFile() {
|
||||
int result;
|
||||
tPath_name cd_path;
|
||||
|
||||
unlink("/tmp/PATHS.TXT");
|
||||
|
||||
// should return false, path does not exist
|
||||
result = GetCDPathFromPathsTxtFile(cd_path);
|
||||
TEST_ASSERT_EQUAL_INT(0, result);
|
||||
|
||||
FILE* file = fopen("/tmp/PATHS.TXT", "wt");
|
||||
fprintf(file, "test_cd_path\r\n");
|
||||
fclose(file);
|
||||
|
||||
result = GetCDPathFromPathsTxtFile(cd_path);
|
||||
TEST_ASSERT_EQUAL_INT(1, result);
|
||||
TEST_ASSERT_EQUAL_STRING("test_cd_path", cd_path);
|
||||
TEST_ASSERT_EQUAL_STRING(".\\DATA\\MINICD", cd_path);
|
||||
}
|
||||
|
||||
void test_loading_OldDRfopen() {
|
||||
FILE* f;
|
||||
|
||||
f = OldDRfopen("DATA/i-dont-exist", "rt");
|
||||
TEST_ASSERT_NULL(f);
|
||||
|
||||
f = OldDRfopen("DATA/GENERAL.TXT", "rt");
|
||||
TEST_ASSERT_NOT_NULL(f);
|
||||
}
|
||||
|
||||
void test_loading_LoadGeneralParameters() {
|
||||
|
||||
LoadGeneralParameters();
|
||||
TEST_ASSERT_EQUAL_FLOAT(0.02f, gCamera_hither);
|
||||
TEST_ASSERT_EQUAL_INT(7500, gInitial_credits[0]);
|
||||
TEST_ASSERT_EQUAL_INT(5000, gInitial_credits[1]);
|
||||
TEST_ASSERT_EQUAL_INT(3000, gInitial_credits[2]);
|
||||
TEST_ASSERT_EQUAL_STRING("BLKEAGLE.TXT", gBasic_car_names[0]);
|
||||
TEST_ASSERT_EQUAL_FLOAT(0.2f, gDefault_default_water_spec_vol.gravity_multiplier);
|
||||
TEST_ASSERT_EQUAL_FLOAT(50.0f, gDefault_default_water_spec_vol.viscosity_multiplier);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, gInitial_net_credits[0]);
|
||||
TEST_ASSERT_EQUAL_INT(2000, gInitial_net_credits[1]);
|
||||
TEST_ASSERT_EQUAL_INT(1, gGravity_multiplier);
|
||||
}
|
||||
|
||||
void test_loading_suite() {
|
||||
RUN_TEST(test_loading_GetCDPathFromPathsTxtFile);
|
||||
RUN_TEST(test_loading_OldDRfopen);
|
||||
RUN_TEST(test_loading_LoadGeneralParameters);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,20 @@
|
|||
#include "common/utility.h"
|
||||
#include <string.h>
|
||||
|
||||
void test_utility_EncodeLinex() {
|
||||
char buf[50];
|
||||
// first line of GENERAL.TXT, "@" prefix and line ending stripped
|
||||
char input[] = "\x29\x2a\x9c\x22\x61\x4d\x5e\x5f\x60\x34\x64\x57\x8d\x2b\x82\x7b\x33\x4c";
|
||||
strcpy(buf, input);
|
||||
EncodeLine(buf);
|
||||
//TEST_ASSERT_EQUAL_INT(2, gEncryption_method);
|
||||
char expected[] = "0.01\t\t\t\t\t// Hither";
|
||||
TEST_ASSERT_EQUAL_STRING(expected, buf);
|
||||
}
|
||||
|
||||
void test_utility_DecodeLine2() {
|
||||
char buf[50];
|
||||
gEncryption_method = 1;
|
||||
// first line of GENERAL.TXT, "@" prefix and line ending stripped
|
||||
char input[] = "\x29\x2a\x9c\x22\x61\x4d\x5e\x5f\x60\x34\x64\x57\x8d\x2b\x82\x7b\x33\x4c";
|
||||
strcpy(buf, input);
|
||||
|
|
@ -69,6 +81,7 @@ void test_utility_PathCat() {
|
|||
}
|
||||
|
||||
void test_utility_suite() {
|
||||
RUN_TEST(test_utility_EncodeLinex);
|
||||
RUN_TEST(test_utility_DecodeLine2);
|
||||
RUN_TEST(test_utility_EncodeLine2);
|
||||
RUN_TEST(test_utility_StripCR);
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ DEPS := $(OBJS:.o=.d)
|
|||
INC_DIRS := $(shell find $(SRC_DIR) -type d) $(BR_SRC_DIR) $(DR_SRC_DIR)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
|
||||
CFLAGS ?= $(INC_FLAGS)
|
||||
LDFLAGS ?= -lm
|
||||
CFLAGS ?= $(INC_FLAGS) -g
|
||||
LDFLAGS ?= -lm -fno-pie
|
||||
|
||||
.PHONY: clean build run
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
********************************************************************************************************************************************************************************************************************************************************************
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
@)*ś"aM^_`4dWŤ+‚{3L
|
||||
@ź&O}n_`›KŽp3VJ9P
|
||||
@1™=Tx^_`›K!pb5r;[Uz4<{<7B>ŽŤ
|
||||
@n_`›KŽ_3V3—SErq3aF<61>Ś<EFBFBD>‚66›v8J
|
||||
@+yŽ™„,“Nb5.‡‰–‚5b”r5U@i{({‚BŠ ž"*‚}3MT;u0z“Śś
|
||||
@*XM^_`›K!pb?}?JNzx}g‡Ś<E280A1>
|
||||
@|;o,U;)4ś?R}no`›K!pb?}?JNzx}v”‡Ś›<C59A>6b<36>|$žBzw55•‰<E280A2>ž›e.“e3R
|
||||
@<)4ś#M~koP+g:o,I>™„<E284A2><4žg<C5BE>†<EFBFBD>†„e2“avLFu}s‰<73>H—–&*V`=WKw41p<31>‡„
|
||||
@z ośyŽ™„,<N}RŠŤŠ“›e!„f%Vxv}3J Ť„–W##•g9L
|
||||
@z ośyŽ™„,<N}RŠŤŠ“›e!„f%Vxvu%J Ť„–W##•g9L
|
||||
@n2IŽ™„,“abqF%„ť•$.Vp$KTsK*|„ „—W##•g9L
|
||||
@-W>™„,“aMqpB/ž<>'#š35LRh|‚yŹŹ<C5B9>†(!' z7PS;r<v’Ťš
|
||||
@oqP›KŽ_śy!6ž`w{?tŠB‹ ‚6*)`&RNoK>}‡Ś‹—W##•g9L
|
||||
@{ hśyŽ™„,<N}RŠŤŠ“›e!„f%Vxh{;a<>‡›<E280A1>W##•g9L
|
||||
@H>56ś?R}^_`›K!pb$v&_Ni4>z•–H”<48>7b“r5V‡h4yŠB„—<E2809E> .V;5LB4-p”BMR“$/—t3—
|
||||
@"Q}ns@){>o0Y:)4ś“abqF0Ť‘<C5A4>3'„jv]Hh`}s‰<73>H—–&*V`=WKw41p<31>‡„
|
||||
@mP7s"jśyŽ™+<2B>;@4x<34>B<EFBFBD>—…e2“wvUNwx}s‰<73>H—–&*V`=WKw41p<31>‡„
|
||||
@>q+L")*™?Qclj`›K!pb%v5QIg}e<><65>H‡™,6Vp7L‡u0t<30>‡H”<48>7b“r5V‡h4yŠB„—<E2809E> .V;!WSs4-p‚‘A
|
||||
@5ť?Yak_`›K!pb5a3ZNog}e<><65>H‡™,6Vp7L‡u0t<30>‡H”<48>7b“r5V‡h4yŠB„—<E2809E> .V;!WSs4-p‚‘A
|
||||
@-K>5=ś?W}^_`›d!e–ź~3žFlu/q<>†H”<48>7b<37>r%JNus}v‡<76>H”<48>7b“r5V‡h4yŠB„—<E2809E> .V;!WSs4-p‚‘A
|
||||
@J>)4 !Q}nsQ+{>_śy!6ždiq9|’‘H“ $0’v2žAtf}b‡‘ś›™"b•r$žAtf}p‡<70> R„.+švRBmq15N•<4E>†źe2“w%—
|
||||
@hoL({"n)yŽ™„<E284A2><4‰|‹‡H“ $0’v2žAtf}g‰Ž„›™"b•r$žAtf}p‡<70> R„.+švRBmq15N•<4E>†źe2“w%—
|
||||
@H>)4 "Q}nsQ+{>_śy!6ždiq9|’‘H“ $0’v2žAtf}g‰Ž„›™"b•r$žAtf}p‡<70> R„.+švRBmq15N•<4E>†źe2“w%—
|
||||
@){>o0L>)(™#aM^pOH1… &źg%žFlu/q<>†H”<48>7b•{3]Lk{4{’‘H”<48>7b“r5V‡h4yŠB„—<E2809E> .V;!WSs4-p‚‘A
|
||||
@>q+L")*™?Qclj`›K!pb%v5QIg}e<><65>H‡™,6Vp7L‡u0t<30>‡H”<48>7b“r5V‡h4yŠB„—<E2809E> .V;!WSs4-p‚‘A
|
||||
@5ť?Yak_`›K!pb5a3ZNog}e<><65>H‡™,6Vp7L‡u0t<30>‡H”<48>7b“r5V‡h4yŠB„—<E2809E> .V;!WSs4-p‚‘A
|
||||
@-K>5=ś?W}^_`›d!e–ź~3žFlu/q<>†H”<48>7b<37>r%JNus}v‡<76>H”<48>7b“r5V‡h4yŠB„—<E2809E> .V;!WSs4-p‚‘A
|
||||
@J>)4 !Q}nsQ+{>_śy!6ždiq9|’‘H“ $0’v2žAtf}b‡‘ś›™"b•r$žAtf}p‡<70> R„.+švRBmq15N•<4E>†źe2“w%—
|
||||
@hoL({"n)yŽ™„<E284A2><4‰|‹‡H“ $0’v2žAtf}g‰Ž„›™"b•r$žAtf}p‡<70> R„.+švRBmq15N•<4E>†źe2“w%—
|
||||
@H>)4 "Q}nsQ+{>_śy!6ždiq9|’‘H“ $0’v2žAtf}g‰Ž„›™"b•r$žAtf}p‡<70> R„.+švRBmq15N•<4E>†źe2“w%—
|
||||
@){>o0L>)(™#aM^pOH1… &źg%žFlu/q<>†H”<48>7b•{3]Lk{4{’‘H”<48>7b“r5V‡h4yŠB„—<E2809E> .V;!WSs4-p‚‘A
|
||||
@nP+{"n,I>55ś#QM^_`4dWŹ7›cvMSzf)5 ‹†—W#-„33_Ds41p<31>‡„
|
||||
@PxrnP7~Ž_śy!6ždiq9|’‘H‚’7b…v5QI42sF–<46>ź’e ™}#M
|
||||
@<)4ś?P}noL.{>_śy!6ždnz3|<7C>…H<E280A6><48>0,‚34QIng}s‰<73>H—–&*V`=WKw41p<31>‡„
|
||||
@!6ždzf.5’ŤH‡„ b—`vZB}u(y’‘R
|
||||
@ś“+^ŠI“YWZAP
|
||||
@ź‘.RŽMžNWZAP
|
||||
@)„,“abqF$š“š b„r"[‡pz2w„ŽŤ W#-„37]Sr{35”‡<E2809D>ž–<b…r WI|4uo<75><6F>‡RJe,™}3—
|
||||
@5‚#aM^_O4R852™}3PS;z<f’‹†—„6bź}0RR~z>p”NHNWtbK38WD~fq5XBYRJe,—`"WBi4uc‡Žť—„e “g![Bu4m;WB‰ś“esF3%VHnx95‚ŤA
|
||||
@!pb2v0_Rw`}`<60>†Ť $6“avMW~w4tŠBžť›0/“3&_Uzy8a<38><61>›
|
||||
@+e<_śyŽ™„,“abqF…š“<C5A1>,6Ź3;KKo}-yʇš
|
||||
@,4,“aM^_`›K!pb z%]Hh})lFŹťž<C5A5>,2šz3L
|
||||
@#aM^_`›KŽ_3V3•_U;p<x‡…ŤR‡ 0V~?RKrg8v‰ŚŚ
|
||||
@+e>o.yŽ™„,“aMqpB8—“ 1‚a?_I;p<x‡…ŤR‡ 0V~?RKrg8v‰ŚŚ
|
||||
@ś“aM^_`›KŽp3Vp7SBiu}p „Ť‘<C5A4>e+<2B>w3F
|
||||
@"aM^_`›KŽ_3V3…U^;w2y‰—š
|
||||
@“mU5†O‹śyŽ™„,“abqF5<46>ś“6!„v3P‡vu)p”‹‰žW1-Vf%[
|
||||
@j-I>™„,“aM^_O4R$*7<>wvwc;{;5<>Śś Že,™z%[
|
||||
@xooP›KŽ_śyŽ™+<2B>;G2`<60>†H;3e-<2D>33FNo43zŹ‘Ť
|
||||
@<_śyŽ™„,“abqF'†•ž+'V}9WT~44{‚‡<E2809A>
|
||||
@>™„,“aM^_`4dW(#‚v$WFw44{‚‡<E2809A>
|
||||
@)(ž#Q}rjP+{"n,I>)(ž#Q}n_`›d!e‘‚r$JNus}x‰ŚŤ‹W,,V}3JPtf65‹ŤŚ—Wm$™av[Fx|}fŤ‹„žW)' v:—
|
||||
@=ośyŽ™„,<N}F’<46>š†ž+%Vg?SB;}35<33>‡ś…<C59B>7)V~9Z‡33‰t<E280B0>EA
|
||||
@=ośyŽ™„,<N}F’<46>š†ž+%Vg?SB;}35<33>‡ś…<C59B>7)V~9Z‡33›zžEA
|
||||
@+<2B>;F8e‡‹šR”*1‚30QU;q<vŽB†—<E280A0>e%—~3žSbd85N<35>š—“e2“av›‡u0t<30>‡A
|
||||
@5™?PxrhN.g9q)U971 $OxrhN.
|
||||
@<N}G<><47>‡„’7;Vp9MS;r2gF‡‰‘źe,“gvYFvq}aź’Ť
|
||||
@(4ś#M|noP7z>o,U?)4ś?P}noL*{>o0H>)4
|
||||
@3V3•_U;g2s’ŚŤ<C59A>„e$—p"QU;r2gF‡‰‘źe,“gvYFvq}aź’Ť
|
||||
@?74 "OxrnN.g?q)U?71 "OxrnN.
|
||||
@p3VMxv<78>gŽ`=>’;/o2}žk9iY•$.3‰~9.9s‹.|eO{A#;+@|*c:<Ťwia
|
||||
@<74 O}rnN+g?q,U?74 "O}rnN+
|
||||
@<N}F…Ťš—W1#„t3JT;r2gF‡‰‘źe,“gvYFvq}aź’Ť
|
||||
@+g=s)I")(ś?W}rmT+
|
||||
@go`›KŽ_śV!vnNx(eF<65>Ť<EFBFBD>‡$5<>3;WI;`4x<34>B@<40>’&-<2D>w%—
|
||||
@/4,“aM^_O4R',!ťf&žU~g-t‘ŚHź–=b“k"LF;`4x<34>B@<40>’&-<2D>w%—
|
||||
@O>™„,“aMqpB,—š*b„r5[‡iu3~F‡™‡ž3#šv8J
|
||||
@<™„,“aMqpB,—š*b—a;QRi41p<31>‡„
|
||||
@Q›KŽ_śy!6žc~y25–Ťź—…e.“e3R
|
||||
@SM^_`›K!pb2v;Q‡tr;p<>‘<EFBFBD>„’e.“e3R
|
||||
@bqF-<2D>‚<EFBFBD>+'<27>g%žSsu)5‡’<E280A1>—–7bź}vZBv{}r‡ŹŤ
|
||||
@(2
|
||||
@(6
|
||||
@+6
|
||||
@(=
|
||||
@,
|
||||
@3V32[Aza1aF%š“<C5A1>,6Ź3›KKo}-yʇš
|
||||
@*
|
||||
@V!vxKrw}f‰—†–W!'šr/M
|
||||
@>_śyŽ™„<E284A2><4™pŠ<70>‘R_,,V`3]Hup.<F Ť”<C5A4>7'V`9KI49`”‹†•W50“>%SFx}sŠ‹‹
|
||||
@ś“aM^_`4dW<64>'šr/žŹrz}f<><66>‡ś“6kVq3XHiq}f‰—†–W!7„z8Y‡k{.aK‘…“”.b<>?]
|
||||
@o`›KŽ_śV!vzBwu$5N‹†R„ !™}2MŽ;v8s‰<73>ŤR„*7<>wvZRi}3rFE†ť<E280A0>e+<2B>32[Jt3}sŠ‹‹
|
||||
@4,“aM^_O4R3 .—jv–Nu4.p…Ť†–„lb”v0QU~4.z“ŚŚR“00ź}1žWtg)8‚‡…ťW6.źw3MOtc}sŠ‹‹
|
||||
|
|
@ -0,0 +1 @@
|
|||
abcdef
|
||||
|
|
@ -0,0 +1 @@
|
|||
Placeholder file for CD check...
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
.\DATA\MINICD
|
||||
.
|
||||
Full
|
||||
English
|
||||
..\CARMA
|
||||
|
|
@ -1606,6 +1606,8 @@ void UnityMessage(const char* msg, const UNITY_LINE_TYPE line) {
|
|||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) {
|
||||
Unity.CurrentTestName = FuncName;
|
||||
Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
|
||||
if (!UnityTestMatches())
|
||||
return;
|
||||
Unity.NumberOfTests++;
|
||||
UNITY_CLR_DETAILS();
|
||||
UNITY_EXEC_TIME_START();
|
||||
|
|
@ -1670,7 +1672,7 @@ int UnityEnd(void) {
|
|||
/*-----------------------------------------------
|
||||
* Command Line Argument Support
|
||||
*-----------------------------------------------*/
|
||||
#ifdef UNITY_USE_COMMAND_LINE_ARGS
|
||||
// #ifdef UNITY_USE_COMMAND_LINE_ARGS
|
||||
|
||||
char* UnityOptionIncludeNamed = NULL;
|
||||
char* UnityOptionExcludeNamed = NULL;
|
||||
|
|
@ -1842,5 +1844,5 @@ int UnityTestMatches(void) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
#endif /* UNITY_USE_COMMAND_LINE_ARGS */
|
||||
//#endif /* UNITY_USE_COMMAND_LINE_ARGS */
|
||||
/*-----------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -732,6 +732,10 @@ extern const char UnityStrErrShorthand[];
|
|||
#define UNITY_BEGIN() UnityBegin(__FILE__)
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_PARSE_OPTS
|
||||
#define UNITY_PARSE_OPTS() UnityParseOptions(argc, argv)
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_END
|
||||
#define UNITY_END() UnityEnd()
|
||||
#endif
|
||||
|
|
@ -750,10 +754,8 @@ extern const char UnityStrErrShorthand[];
|
|||
* Command Line Argument Support
|
||||
*-----------------------------------------------*/
|
||||
|
||||
#ifdef UNITY_USE_COMMAND_LINE_ARGS
|
||||
int UnityParseOptions(int argc, char** argv);
|
||||
int UnityTestMatches(void);
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------
|
||||
* Basic Fail and Ignore
|
||||
|
|
|
|||
29
test/main.c
29
test/main.c
|
|
@ -1,12 +1,19 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define UNITY_USE_COMMAND_LINE_ARGS 1
|
||||
|
||||
#include "framework/unity.h"
|
||||
|
||||
#include "CORE/V1DB/dbsetup.h"
|
||||
|
||||
#include "common/globvars.h"
|
||||
#include "new/stack_trace_handler.h"
|
||||
|
||||
#define debug(format_, ...) fprintf(stderr, format_, __VA_ARGS__)
|
||||
|
||||
#define debug(format_, ...) fprintf(stderr, format_, __VA_ARGS__)
|
||||
|
||||
|
|
@ -22,19 +29,31 @@ extern void test_fwsetup_suite();
|
|||
extern void test_resource_suite();
|
||||
|
||||
void setUp(void) {
|
||||
strcpy(gApplication_path, "/tmp");
|
||||
strcpy(gDir_separator, "/");
|
||||
|
||||
BrV1dbBeginWrapper_Float();
|
||||
}
|
||||
|
||||
void tearDown(void) {
|
||||
}
|
||||
|
||||
int main(int pArgc, char** pArgv) {
|
||||
void setupGlobalVars() {
|
||||
strcpy(gDir_separator, "/");
|
||||
getcwd(gApplication_path, 256);
|
||||
strcat(gApplication_path, "/DATA");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
UNITY_BEGIN();
|
||||
|
||||
if (UnityParseOptions(argc, argv) != 0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
set_signal_handler(argv[0]);
|
||||
|
||||
setupGlobalVars();
|
||||
|
||||
BrV1dbBeginWrapper_Float();
|
||||
|
||||
// BRSRC13
|
||||
test_brlists_suite();
|
||||
test_fwsetup_suite();
|
||||
|
|
|
|||
Loading…
Reference in New Issue