]>
jfr.im git - irc/gameservirc.git/blob - gameserv/config.cpp
7 void load_config_file(char *config
);
8 void unload_config_file();
10 /* Random Configuration Stuff Goes Here until I code it to load from a .conf file :)*/
12 char *s_GameServ
; // GameServ's nickname
13 char *gshost
; // GameServ's Hostname
14 char *gsident
; // GameServ's ident/username
15 char *servername
; // GameServ's Server
16 char *c_Forest
; // Forest channel
17 char *c_ForestTopic
; // Forest Channel Topic
18 char *adminpass
; // Administrator password
19 char *welcomemsg
; // Welcome Message
20 int welcomedelay
; // Welcome Message Delay
21 int updateperiod
; // Seconds until another player database update
22 int forestfights
; // Forest fights per day
24 // Remote server stuff. This is used for the outgoing connection gameserv needs to make
26 char *remoteserver
; // Server to connect to
27 char *remoteport
; // Port to connect to on remoteserver
28 char *remotepass
; // Password for the server link
30 char *playerdata
; // File to store player data in
31 char *monsterdata
; // File to load monster data from
32 char *logfile
; // File to log errors and info to
34 void unload_config_file()
47 delete [] c_ForestTopic
;
49 delete [] remoteserver
;
57 delete [] monsterdata
;
66 void load_config_file(char *config
)
68 char *buf
, *directive
, *value
;
77 cout
<< "Error opening " << config
<< endl
;
81 while (infile
.getline(buf
, 1024, '\n'))
83 cout
<< "Buf: " << buf
<< endl
;
85 if (buf
[0] == '#' || buf
[0] == ' ' || buf
[0] == '\0' || buf
[0] == '\n' || buf
[0] == '\r')
88 directive
= strtok(buf
, " ");
90 if (stricmp(directive
, "DIE") == 0)
92 value
= strtok(NULL
, "");
93 cerr
<< value
<< endl
;
96 if (stricmp(directive
, "S_GAMESERV") == 0)
98 value
= strtok(NULL
, " ");
99 s_GameServ
= new char[strlen(value
) + 1];
100 strcpy(s_GameServ
, value
);
102 else if (stricmp(directive
, "GSHOST") == 0)
104 value
= strtok(NULL
, " ");
105 gshost
= new char[strlen(value
) + 1];
106 strcpy(gshost
, value
);
108 else if (stricmp(directive
, "GSIDENT") == 0)
110 value
= strtok(NULL
, " ");
111 gsident
= new char[strlen(value
) + 1];
112 strcpy(gsident
, value
);
114 else if (stricmp(directive
, "SERVERNAME") == 0)
116 value
= strtok(NULL
, " ");
117 servername
= new char[strlen(value
) + 1];
118 strcpy(servername
, value
);
120 else if (stricmp(directive
, "C_FOREST") == 0)
122 value
= strtok(NULL
, " ");
123 c_Forest
= new char[strlen(value
) + 1];
124 strcpy(c_Forest
, value
);
126 else if (stricmp(directive
, "C_FORESTTOPIC") == 0)
128 value
= strtok(NULL
, "");
129 c_ForestTopic
= new char[strlen(value
) + 1];
130 strcpy(c_ForestTopic
, value
);
132 else if (stricmp(directive
, "REMOTESERVER") == 0)
134 value
= strtok(NULL
, " ");
135 remoteserver
= new char[strlen(value
) + 1];
136 strcpy(remoteserver
, value
);
138 else if (stricmp(directive
, "REMOTEPORT") == 0)
140 value
= strtok(NULL
, " ");
141 remoteport
= new char[strlen(value
) + 1];
142 strcpy(remoteport
, value
);
144 else if (stricmp(directive
, "REMOTEPASS") == 0)
146 value
= strtok(NULL
, "");
147 remotepass
= new char[strlen(value
) + 1];
148 strcpy(remotepass
, value
);
150 else if (stricmp(directive
, "PLAYERDATA") == 0)
152 value
= strtok(NULL
, "");
153 playerdata
= new char[strlen(value
) + 1];
154 strcpy(playerdata
, value
);
156 else if (stricmp(directive
, "LOGFILE") == 0)
158 value
= strtok(NULL
, "");
159 logfile
= new char[strlen(value
) + 1];
160 strcpy(logfile
, value
);
162 else if (stricmp(directive
, "MONSTERDATA") == 0)
164 value
= strtok(NULL
, "");
165 monsterdata
= new char[strlen(value
) + 1];
166 strcpy(monsterdata
, value
);
168 else if (stricmp(directive
, "ADMINPASS") == 0)
170 value
= strtok(NULL
, "");
171 adminpass
= new char[strlen(value
) + 1];
172 strcpy(adminpass
, value
);
174 else if (stricmp(directive
, "WELCOMEDELAY") == 0)
176 value
= strtok(NULL
, " ");
177 welcomedelay
= stringtoint(value
);
179 else if (stricmp(directive
, "FORESTFIGHTS") == 0)
181 value
= strtok(NULL
, " ");
182 forestfights
= stringtoint(value
);
184 else if (stricmp(directive
, "UPDATEPERIOD") == 0)
186 value
= strtok(NULL
, " ");
187 updateperiod
= stringtoint(value
);
189 else if (stricmp(directive
, "WELCOMEMSG") == 0)
191 value
= strtok(NULL
, "");
192 welcomemsg
= new char[strlen(value
) + 1];
193 strcpy(welcomemsg
, value
);
197 cout
<< "Unknown Directive. Buffer: " << buf
<< endl
;