]>
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
33 void unload_config_file()
46 delete [] c_ForestTopic
;
48 delete [] remoteserver
;
56 delete [] monsterdata
;
63 void load_config_file(char *config
)
65 char *buf
, *directive
, *value
;
74 cout
<< "Error opening " << config
<< endl
;
78 while (infile
.getline(buf
, 1024, '\n'))
80 cout
<< "Buf: " << buf
<< endl
;
82 if (buf
[0] == '#' || buf
[0] == ' ' || buf
[0] == '\0' || buf
[0] == '\n' || buf
[0] == '\r')
85 directive
= strtok(buf
, " ");
87 if (stricmp(directive
, "DIE") == 0)
89 value
= strtok(NULL
, "");
90 cerr
<< value
<< endl
;
93 if (stricmp(directive
, "S_GAMESERV") == 0)
95 value
= strtok(NULL
, " ");
96 s_GameServ
= new char[strlen(value
) + 1];
97 strcpy(s_GameServ
, value
);
99 else if (stricmp(directive
, "GSHOST") == 0)
101 value
= strtok(NULL
, " ");
102 gshost
= new char[strlen(value
) + 1];
103 strcpy(gshost
, value
);
105 else if (stricmp(directive
, "GSIDENT") == 0)
107 value
= strtok(NULL
, " ");
108 gsident
= new char[strlen(value
) + 1];
109 strcpy(gsident
, value
);
111 else if (stricmp(directive
, "SERVERNAME") == 0)
113 value
= strtok(NULL
, " ");
114 servername
= new char[strlen(value
) + 1];
115 strcpy(servername
, value
);
117 else if (stricmp(directive
, "C_FOREST") == 0)
119 value
= strtok(NULL
, " ");
120 c_Forest
= new char[strlen(value
) + 1];
121 strcpy(c_Forest
, value
);
123 else if (stricmp(directive
, "C_FORESTTOPIC") == 0)
125 value
= strtok(NULL
, "");
126 c_ForestTopic
= new char[strlen(value
) + 1];
127 strcpy(c_ForestTopic
, value
);
129 else if (stricmp(directive
, "REMOTESERVER") == 0)
131 value
= strtok(NULL
, " ");
132 remoteserver
= new char[strlen(value
) + 1];
133 strcpy(remoteserver
, value
);
135 else if (stricmp(directive
, "REMOTEPORT") == 0)
137 value
= strtok(NULL
, " ");
138 remoteport
= new char[strlen(value
) + 1];
139 strcpy(remoteport
, value
);
141 else if (stricmp(directive
, "REMOTEPASS") == 0)
143 value
= strtok(NULL
, "");
144 remotepass
= new char[strlen(value
) + 1];
145 strcpy(remotepass
, value
);
147 else if (stricmp(directive
, "PLAYERDATA") == 0)
149 value
= strtok(NULL
, "");
150 playerdata
= new char[strlen(value
) + 1];
151 strcpy(playerdata
, value
);
153 else if (stricmp(directive
, "MONSTERDATA") == 0)
155 value
= strtok(NULL
, "");
156 monsterdata
= new char[strlen(value
) + 1];
157 strcpy(monsterdata
, value
);
159 else if (stricmp(directive
, "ADMINPASS") == 0)
161 value
= strtok(NULL
, "");
162 adminpass
= new char[strlen(value
) + 1];
163 strcpy(adminpass
, value
);
165 else if (stricmp(directive
, "WELCOMEDELAY") == 0)
167 value
= strtok(NULL
, " ");
168 welcomedelay
= stringtoint(value
);
170 else if (stricmp(directive
, "FORESTFIGHTS") == 0)
172 value
= strtok(NULL
, " ");
173 forestfights
= stringtoint(value
);
175 else if (stricmp(directive
, "UPDATEPERIOD") == 0)
177 value
= strtok(NULL
, " ");
178 updateperiod
= stringtoint(value
);
180 else if (stricmp(directive
, "WELCOMEMSG") == 0)
182 value
= strtok(NULL
, "");
183 welcomemsg
= new char[strlen(value
) + 1];
184 strcpy(welcomemsg
, value
);
188 cout
<< "Unknown Directive. Buffer: " << buf
<< endl
;