]>
jfr.im git - irc/gameservirc.git/blob - gameserv/config.cpp
11 int load_config_file(char *config
);
12 void unload_config_file();
14 /* Random Configuration Stuff Goes Here until I code it to load from a .conf file :)*/
16 char *s_GameServ
; // GameServ's nickname
17 char *gshost
; // GameServ's Hostname
18 char *gsident
; // GameServ's ident/username
19 char *servername
; // GameServ's Server
20 char *c_Forest
; // Forest channel
21 char *c_ForestTopic
; // Forest Channel Topic
22 char *adminpass
; // Administrator password
23 char *welcomemsg
; // Welcome Message
24 int welcomedelay
; // Welcome Message Delay
25 int updateperiod
; // Seconds until another player database update
26 int forestfights
; // Forest fights per day
28 // Remote server stuff. This is used for the outgoing connection gameserv needs to make
30 char *remoteserver
; // Server to connect to
31 char *remoteport
; // Port to connect to on remoteserver
32 char *remotepass
; // Password for the server link
34 char *playerdata
; // File to store player data in
35 char *monsterdata
; // File to load monster data from
38 char *gsnum
= "[]AAA"; // GameServ Numeric
41 void unload_config_file()
54 delete [] c_ForestTopic
;
56 delete [] remoteserver
;
64 delete [] monsterdata
;
71 int load_config_file(char *config
)
73 char *buf
, *directive
, *value
;
82 log("Error opening %s", config
);
83 cerr
<< "Error opening " << config
<< endl
;
87 while (infile
.getline(buf
, 1024, '\n'))
90 log("Config file entry buf: %s", buf
);
93 if (buf
[0] == '#' || buf
[0] == ' ' || buf
[0] == '\0' || buf
[0] == '\n' || buf
[0] == '\r')
96 directive
= strtok(buf
, " ");
98 if (stricmp(directive
, "DIE") == 0)
100 value
= strtok(NULL
, "");
101 log("You should read the entire %s file!", config
);
102 cerr
<< "You should read the entire " << config
<< " file!"
106 if (stricmp(directive
, "S_GAMESERV") == 0)
108 value
= strtok(NULL
, " ");
109 s_GameServ
= new char[strlen(value
) + 1];
110 strcpy(s_GameServ
, value
);
112 else if (stricmp(directive
, "GSHOST") == 0)
114 value
= strtok(NULL
, " ");
115 gshost
= new char[strlen(value
) + 1];
116 strcpy(gshost
, value
);
118 else if (stricmp(directive
, "GSIDENT") == 0)
120 value
= strtok(NULL
, " ");
121 gsident
= new char[strlen(value
) + 1];
122 strcpy(gsident
, value
);
124 else if (stricmp(directive
, "SERVERNAME") == 0)
126 value
= strtok(NULL
, " ");
127 servername
= new char[strlen(value
) + 1];
128 strcpy(servername
, value
);
130 else if (stricmp(directive
, "C_FOREST") == 0)
132 value
= strtok(NULL
, " ");
133 c_Forest
= new char[strlen(value
) + 1];
134 strcpy(c_Forest
, value
);
136 else if (stricmp(directive
, "C_FORESTTOPIC") == 0)
138 value
= strtok(NULL
, "");
139 c_ForestTopic
= new char[strlen(value
) + 1];
140 strcpy(c_ForestTopic
, value
);
142 else if (stricmp(directive
, "REMOTESERVER") == 0)
144 value
= strtok(NULL
, " ");
145 remoteserver
= new char[strlen(value
) + 1];
146 strcpy(remoteserver
, value
);
148 else if (stricmp(directive
, "REMOTEPORT") == 0)
150 value
= strtok(NULL
, " ");
151 remoteport
= new char[strlen(value
) + 1];
152 strcpy(remoteport
, value
);
154 else if (stricmp(directive
, "REMOTEPASS") == 0)
156 value
= strtok(NULL
, "");
157 remotepass
= new char[strlen(value
) + 1];
158 strcpy(remotepass
, value
);
160 else if (stricmp(directive
, "PLAYERDATA") == 0)
162 value
= strtok(NULL
, "");
163 playerdata
= new char[strlen(value
) + 1];
164 strcpy(playerdata
, value
);
166 else if (stricmp(directive
, "MONSTERDATA") == 0)
168 value
= strtok(NULL
, "");
169 monsterdata
= new char[strlen(value
) + 1];
170 strcpy(monsterdata
, value
);
172 else if (stricmp(directive
, "ADMINPASS") == 0)
174 value
= strtok(NULL
, "");
175 adminpass
= new char[strlen(value
) + 1];
176 strcpy(adminpass
, value
);
178 else if (stricmp(directive
, "WELCOMEDELAY") == 0)
180 value
= strtok(NULL
, " ");
181 welcomedelay
= stringtoint(value
);
183 else if (stricmp(directive
, "FORESTFIGHTS") == 0)
185 value
= strtok(NULL
, " ");
186 forestfights
= stringtoint(value
);
188 else if (stricmp(directive
, "UPDATEPERIOD") == 0)
190 value
= strtok(NULL
, " ");
191 updateperiod
= stringtoint(value
);
193 else if (stricmp(directive
, "WELCOMEMSG") == 0)
195 value
= strtok(NULL
, "");
196 welcomemsg
= new char[strlen(value
) + 1];
197 strcpy(welcomemsg
, value
);
202 log("Unknown Directive. Buffer: %s", buf
);
203 cerr
<< "Unknown " << config
<< " directive. Buffer: "