]>
jfr.im git - irc/gameservirc.git/blob - gameserv/config.cpp
9 void load_config_file(char *config
);
10 void unload_config_file();
12 /* Random Configuration Stuff Goes Here until I code it to load from a .conf file :)*/
14 char *s_GameServ
; // GameServ's nickname
15 char *gshost
; // GameServ's Hostname
16 char *gsident
; // GameServ's ident/username
17 char *servername
; // GameServ's Server
18 char *c_Forest
; // Forest channel
19 char *c_ForestTopic
; // Forest Channel Topic
20 char *adminpass
; // Administrator password
21 char *welcomemsg
; // Welcome Message
22 int welcomedelay
; // Welcome Message Delay
23 int updateperiod
; // Seconds until another player database update
24 int forestfights
; // Forest fights per day
26 // Remote server stuff. This is used for the outgoing connection gameserv needs to make
28 char *remoteserver
; // Server to connect to
29 char *remoteport
; // Port to connect to on remoteserver
30 char *remotepass
; // Password for the server link
32 char *playerdata
; // File to store player data in
33 char *monsterdata
; // File to load monster data from
36 char *gsnum
= "[]AAA"; // GameServ Numeric
39 void unload_config_file()
52 delete [] c_ForestTopic
;
54 delete [] remoteserver
;
62 delete [] monsterdata
;
69 void load_config_file(char *config
)
71 char *buf
, *directive
, *value
;
80 log("Error opening %s", config
);
84 while (infile
.getline(buf
, 1024, '\n'))
90 if (buf
[0] == '#' || buf
[0] == ' ' || buf
[0] == '\0' || buf
[0] == '\n' || buf
[0] == '\r')
93 directive
= strtok(buf
, " ");
95 if (stricmp(directive
, "DIE") == 0)
97 value
= strtok(NULL
, "");
98 log("You should read the entire %s file!", config
);
101 if (stricmp(directive
, "S_GAMESERV") == 0)
103 value
= strtok(NULL
, " ");
104 s_GameServ
= new char[strlen(value
) + 1];
105 strcpy(s_GameServ
, value
);
107 else if (stricmp(directive
, "GSHOST") == 0)
109 value
= strtok(NULL
, " ");
110 gshost
= new char[strlen(value
) + 1];
111 strcpy(gshost
, value
);
113 else if (stricmp(directive
, "GSIDENT") == 0)
115 value
= strtok(NULL
, " ");
116 gsident
= new char[strlen(value
) + 1];
117 strcpy(gsident
, value
);
119 else if (stricmp(directive
, "SERVERNAME") == 0)
121 value
= strtok(NULL
, " ");
122 servername
= new char[strlen(value
) + 1];
123 strcpy(servername
, value
);
125 else if (stricmp(directive
, "C_FOREST") == 0)
127 value
= strtok(NULL
, " ");
128 c_Forest
= new char[strlen(value
) + 1];
129 strcpy(c_Forest
, value
);
131 else if (stricmp(directive
, "C_FORESTTOPIC") == 0)
133 value
= strtok(NULL
, "");
134 c_ForestTopic
= new char[strlen(value
) + 1];
135 strcpy(c_ForestTopic
, value
);
137 else if (stricmp(directive
, "REMOTESERVER") == 0)
139 value
= strtok(NULL
, " ");
140 remoteserver
= new char[strlen(value
) + 1];
141 strcpy(remoteserver
, value
);
143 else if (stricmp(directive
, "REMOTEPORT") == 0)
145 value
= strtok(NULL
, " ");
146 remoteport
= new char[strlen(value
) + 1];
147 strcpy(remoteport
, value
);
149 else if (stricmp(directive
, "REMOTEPASS") == 0)
151 value
= strtok(NULL
, "");
152 remotepass
= new char[strlen(value
) + 1];
153 strcpy(remotepass
, value
);
155 else if (stricmp(directive
, "PLAYERDATA") == 0)
157 value
= strtok(NULL
, "");
158 playerdata
= new char[strlen(value
) + 1];
159 strcpy(playerdata
, value
);
161 else if (stricmp(directive
, "MONSTERDATA") == 0)
163 value
= strtok(NULL
, "");
164 monsterdata
= new char[strlen(value
) + 1];
165 strcpy(monsterdata
, value
);
167 else if (stricmp(directive
, "ADMINPASS") == 0)
169 value
= strtok(NULL
, "");
170 adminpass
= new char[strlen(value
) + 1];
171 strcpy(adminpass
, value
);
173 else if (stricmp(directive
, "WELCOMEDELAY") == 0)
175 value
= strtok(NULL
, " ");
176 welcomedelay
= stringtoint(value
);
178 else if (stricmp(directive
, "FORESTFIGHTS") == 0)
180 value
= strtok(NULL
, " ");
181 forestfights
= stringtoint(value
);
183 else if (stricmp(directive
, "UPDATEPERIOD") == 0)
185 value
= strtok(NULL
, " ");
186 updateperiod
= stringtoint(value
);
188 else if (stricmp(directive
, "WELCOMEMSG") == 0)
190 value
= strtok(NULL
, "");
191 welcomemsg
= new char[strlen(value
) + 1];
192 strcpy(welcomemsg
, value
);
197 log("Unknown Directive. Buffer: %s", buf
);