]>
jfr.im git - irc/gameservirc.git/blob - gameserv/config.cpp
6 void load_config_file(char *config
);
7 void unload_config_file();
9 /* Random Configuration Stuff Goes Here until I code it to load from a .conf file :)*/
11 char *s_GameServ
; // GameServ's nickname
12 char *gshost
; // GameServ's Hostname
13 char *gsident
; // GameServ's ident/username
14 char *servername
; // GameServ's Server
15 char *c_Forest
; // Forest channel
16 char *c_ForestTopic
; // Forest Channel Topic
17 char *adminpass
; // Administrator password
18 char *welcomemsg
; // Welcome Message
19 int confloadtime
; // Welcome Message Delay
21 // Remote server stuff. This is used for the outgoing connection gameserv needs to make
23 char *remoteserver
; // Server to connect to
24 char *remoteport
; // Port to connect to on remoteserver
25 char *remotepass
; // Password for the server link
27 char *playerdata
; // File to store player data in
28 char *monsterdata
; // File to load monster data from
30 void unload_config_file()
43 delete [] c_ForestTopic
;
45 delete [] remoteserver
;
53 delete [] monsterdata
;
60 void load_config_file(char *config
)
62 char *buf
, *directive
, *value
;
71 cout
<< "Error opening " << config
<< endl
;
75 while (infile
.getline(buf
, 1024, '\n'))
77 cout
<< "Buf: " << buf
<< endl
;
79 if (buf
[0] == '#' || buf
[0] == ' ' || buf
[0] == '\0' || buf
[0] == '\n' || buf
[0] == '\r')
82 directive
= strtok(buf
, " ");
84 if (stricmp(directive
, "S_GAMESERV") == 0)
86 value
= strtok(NULL
, " ");
87 s_GameServ
= new char[strlen(value
) + 1];
88 strcpy(s_GameServ
, value
);
90 else if (stricmp(directive
, "GSHOST") == 0)
92 value
= strtok(NULL
, " ");
93 gshost
= new char[strlen(value
) + 1];
94 strcpy(gshost
, value
);
96 else if (stricmp(directive
, "GSIDENT") == 0)
98 value
= strtok(NULL
, " ");
99 gsident
= new char[strlen(value
) + 1];
100 strcpy(gsident
, value
);
102 else if (stricmp(directive
, "SERVERNAME") == 0)
104 value
= strtok(NULL
, " ");
105 servername
= new char[strlen(value
) + 1];
106 strcpy(servername
, value
);
108 else if (stricmp(directive
, "C_FOREST") == 0)
110 value
= strtok(NULL
, " ");
111 c_Forest
= new char[strlen(value
) + 1];
112 strcpy(c_Forest
, value
);
114 else if (stricmp(directive
, "C_FORESTTOPIC") == 0)
116 value
= strtok(NULL
, "");
117 c_ForestTopic
= new char[strlen(value
) + 1];
118 strcpy(c_ForestTopic
, value
);
120 else if (stricmp(directive
, "REMOTESERVER") == 0)
122 value
= strtok(NULL
, " ");
123 remoteserver
= new char[strlen(value
) + 1];
124 strcpy(remoteserver
, value
);
126 else if (stricmp(directive
, "REMOTEPORT") == 0)
128 value
= strtok(NULL
, " ");
129 remoteport
= new char[strlen(value
) + 1];
130 strcpy(remoteport
, value
);
132 else if (stricmp(directive
, "REMOTEPASS") == 0)
134 value
= strtok(NULL
, "");
135 remotepass
= new char[strlen(value
) + 1];
136 strcpy(remotepass
, value
);
138 else if (stricmp(directive
, "PLAYERDATA") == 0)
140 value
= strtok(NULL
, "");
141 playerdata
= new char[strlen(value
) + 1];
142 strcpy(playerdata
, value
);
144 else if (stricmp(directive
, "MONSTERDATA") == 0)
146 value
= strtok(NULL
, "");
147 monsterdata
= new char[strlen(value
) + 1];
148 strcpy(monsterdata
, value
);
150 else if (stricmp(directive
, "ADMINPASS") == 0)
152 value
= strtok(NULL
, "");
153 adminpass
= new char[strlen(value
) + 1];
154 strcpy(adminpass
, value
);
156 else if (stricmp(directive
, "CONFLOADTIME") == 0)
158 value
= strtok(NULL
, " ");
159 confloadtime
= stringtoint(value
);
161 else if (stricmp(directive
, "WELCOMEMSG") == 0)
163 value
= strtok(NULL
, "");
164 welcomemsg
= new char[strlen(value
) + 1];
165 strcpy(welcomemsg
, value
);
169 cout
<< "Unknown Directive. Buffer: " << buf
<< endl
;