This repository has been archived by the owner on Jan 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.c
227 lines (219 loc) · 5.88 KB
/
init.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
//meta_flag_tabme
//startup
//you arived here from main
unsigned char sealevel;
bool forcebten;
bool yinv;
char joypath[16];
char mappath[256];
char logpath[64];
bool dologs;
unsigned char base_role;
mesurements TAILOR;
FILE *logfile;
init__setup ()
{
FILE *ini_file;
for (unsigned char n;;n++)
{
switch (n)
{
case 0 :
{
ini_file = fopen("~/.iwannaflyini","r");
break;
}
case 1 :
{
ini_file = fopen("/etc/iwannafly/conf.ini","r");
break;
}
case 2 :
{
ini_file = fopen("./conf.ini","r");
break;
}
default :
{
HARD_ERROR_MACRO
break;
}
}
if (ini_file != NULL)
break;
}
char ini_buffer[BUFFER_MAX];
char dimpath[BUFFER_MAX];
char *ini_key;
char *ini_data;
while (fgets(ini_buffer,BUFFER_MAX,ini_file) != NULL)
{
ini_key = strtok(ini_buffer,"=");
if (ini_key != NULL)
{
ini_data = strtok(NULL,"\n");
if (ini_data != NULL)
{
volatile short ini_key_hash = HASH5(ini_key[0],ini_key[1],ini_key[2]); //optimizer issues
if (ini_key_hash > 0)
{
switch (ini_key_hash)
{
case HASH5('r','o','l') ://the macro HASH5 truncates 3 chars to the lower 5 bits of each (so is not case sensitive) and returns a short
{
base_role = atoi(ini_data);
break;
}
case HASH5('f','o','r') :
{
forcebten = atoi(ini_data);
break;
}
case HASH5('s','e','a') :
{
sealevel = atoi(ini_data);
break;
}
case HASH5('m','a','p') :
{
strncpy(mappath,ini_data,sizeof(mappath) - 1);
break;
}
case HASH5('d','i','m') :
{
strncpy(dimpath,ini_data,sizeof(dimpath) - 1);
break;
}
default :
{
puts("invalid key in config file");
break;
}
}
}
}
}
}
fclose(ini_file);
int temp_mesure;
FILE *dim_file;
dim_file = fopen(dimpath,"r");
if (dim_file != NULL)
{
for (unsigned char n = 0;n<16;n++)
{
fscanf(dim_file,"%i",&temp_mesure);
TAILOR[n] = temp_mesure;
}
fclose(dim_file);
}
else
{
HARD_ERROR_MACRO
}
switch (base_role)
{
case 0 :
{
summon_avian(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = !forcebten;
file_cat("/usr/share/iwannafly/avianquest.txt");
break;
}/*
case 1 :
{
summon_human(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = 0;
file_cat("/usr/share/iwannafly/knightquest.txt");
break;
}
case 2 :
{
summon_elf(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = -!forcebten;
file_cat("/usr/share/iwannafly/elfquest.txt");
break;
}
case 3 :
{
summon_dwarf(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = 0;
file_cat("/usr/share/iwannafly/dwarfquest.txt");
break;
}
case 4 :
{
summon_gnome(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = -!forcebten;
file_cat("/usr/share/iwannafly/gnomequest.txt");
break;
}
case 5 :
{
summon_wizard(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = 0;
file_cat("/usr/share/iwannafly/wizardquest.txt");
break;
}
case 6 :
{
summon_cleric(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = 0;
file_cat("/usr/share/iwannafly/clericquest.txt");
break;
}
case 7 :
{
summon_rogue(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = 0;
file_cat("/usr/share/iwannafly/roguequest.txt");
break;
}
case 8 :
{
summon_drow(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = -!forcebten;
file_cat("/usr/share/iwannafly/drowquest.txt");
break;
}
case 9 :
{
summon_draconic(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = -!forcebten;
file_cat("/usr/share/iwannafly/draconquest.txt");
break;
}
case 10 :
{
summon_merfolk(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = 0;
file_cat("/usr/share/iwannafly/merquest.txt");
break;
}
case 11 :
{
summon_seaelf(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = -!forcebten;
file_cat("/usr/share/iwannafly/seaelfquest.txt");
break;
}*/
default :
{
summon_avian(0.0,0.0,groundmake(0.0,0.0),TAILOR,(truecolor)color6(-1,-1,-1,-1),(truecolor)color6(2,2,2,-1));
CAMERA->format.base = 0;
BORKEDCONF
break;
}
}
FILE *heightmap_file = fopen(mappath,"r");
if (heightmap_file != NULL)
{
fread(MAP->dots,sizeof(char),360*360,heightmap_file);
}
else
{
HARD_ERROR_MACRO
}
fclose(heightmap_file);
MAP->sealevel = sealevel;
}