ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/init.C
(Generate patch)

Comparing deliantra/server/server/init.C (file contents):
Revision 1.6 by root, Thu Aug 31 17:54:15 2006 UTC vs.
Revision 1.7 by root, Sun Sep 3 00:18:42 2006 UTC

1/* 1/*
2 * static char *rcsid_init_c = 2 * static char *rcsid_init_c =
3 * "$Id: init.C,v 1.6 2006/08/31 17:54:15 root Exp $"; 3 * "$Id: init.C,v 1.7 2006/09/03 00:18:42 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
203 exit(1); 203 exit(1);
204 } 204 }
205 } 205 }
206} 206}
207 207
208//TODO: make this a constructor
208static materialtype_t *get_empty_mat(void) { 209static materialtype_t *get_empty_mat(void) {
209 materialtype_t *mt; 210 materialtype_t *mt;
210 int i; 211 int i;
211 212
212 mt = (materialtype_t *)malloc(sizeof(materialtype_t)); 213 mt = new materialtype_t;
213 if (mt == NULL) 214
214 fatal(OUT_OF_MEMORY);
215 mt->name = NULL; 215 mt->name = NULL;
216 mt->description = NULL; 216 mt->description = NULL;
217 for (i=0; i < NROFATTACKS; i++) { 217 for (i=0; i < NROFATTACKS; i++) {
218 mt->save[i] = 0; 218 mt->save[i] = 0;
219 mt->mod[i] = 0; 219 mt->mod[i] = 0;
259 cp++; 259 cp++;
260 if (!strncmp(cp, "name", 4)) { 260 if (!strncmp(cp, "name", 4)) {
261 /* clean up the previous entry */ 261 /* clean up the previous entry */
262 if (mt->next != NULL) { 262 if (mt->next != NULL) {
263 if (mt->description == NULL) 263 if (mt->description == NULL)
264 mt->description = add_string(mt->name); 264 mt->description = mt->name;
265 mt = mt->next; 265 mt = mt->next;
266 } 266 }
267 mt->next = get_empty_mat(); 267 mt->next = get_empty_mat ();
268 mt->name = add_string(strchr(cp, ' ') + 1); 268 mt->name = strchr(cp, ' ') + 1;
269 } else if (!strncmp(cp, "description", 11)) { 269 } else if (!strncmp(cp, "description", 11)) {
270 mt->description = add_string(strchr(cp, ' ') + 1); 270 mt->description = strchr(cp, ' ') + 1;
271 } else if (sscanf(cp, "material %d", &value)) { 271 } else if (sscanf(cp, "material %d", &value)) {
272 mt->material = value; 272 mt->material = value;
273 } else if (!strncmp(cp, "saves", 5)) { 273 } else if (!strncmp(cp, "saves", 5)) {
274 cp = strchr(cp, ' ') + 1; 274 cp = strchr(cp, ' ') + 1;
275 for (i=0; i < NROFATTACKS; i++) { 275 for (i=0; i < NROFATTACKS; i++) {
316 mt->value = value; 316 mt->value = value;
317 } 317 }
318 } 318 }
319 if (mt->next) 319 if (mt->next)
320 { 320 {
321 free(mt->next); 321 delete mt->next;
322 mt->next = NULL; 322 mt->next = NULL;
323 } 323 }
324 LOG(llevDebug, "Done.\n"); 324 LOG(llevDebug, "Done.\n");
325 fclose(fp); 325 fclose(fp);
326} 326}
1047 LOG(llevError,"\nCreature %s in race file lacks archetype",cp); 1047 LOG(llevError,"\nCreature %s in race file lacks archetype",cp);
1048 else { 1048 else {
1049 if(set_race&&(!mon->clone.race||strcmp(mon->clone.race,race))) { 1049 if(set_race&&(!mon->clone.race||strcmp(mon->clone.race,race))) {
1050 if(mon->clone.race) { 1050 if(mon->clone.race) {
1051 LOG(llevDebug,"\n Resetting race to %s from %s for archetype %s", 1051 LOG(llevDebug,"\n Resetting race to %s from %s for archetype %s",
1052 race,mon->clone.race,mon->name); 1052 race,&mon->clone.race,&mon->name);
1053 free_string(mon->clone.race);
1054 } 1053 }
1055 mon->clone.race=add_string(race); 1054 mon->clone.race = race;
1056 } 1055 }
1057 /* if the arch is a monster, add it to the race list */ 1056 /* if the arch is a monster, add it to the race list */
1058 if(set_list&&QUERY_FLAG(&mon->clone,FLAG_MONSTER)) 1057 if(set_list&&QUERY_FLAG(&mon->clone,FLAG_MONSTER))
1059 add_to_racelist(race, &mon->clone); 1058 add_to_racelist(race, &mon->clone);
1060 } 1059 }
1069 racelink *list; 1068 racelink *list;
1070 objectlink *tmp; 1069 objectlink *tmp;
1071 for(list=first_race;list;list=list->next) { 1070 for(list=first_race;list;list=list->next) {
1072 fprintf(stderr,"\nRACE %s:\t",list->name); 1071 fprintf(stderr,"\nRACE %s:\t",list->name);
1073 for(tmp=list->member;tmp;tmp=tmp->next) 1072 for(tmp=list->member;tmp;tmp=tmp->next)
1074 fprintf(stderr,"%s(%d), ",tmp->ob->arch->name,tmp->ob->level); 1073 fprintf(stderr,"%s(%d), ",&tmp->ob->arch->name,tmp->ob->level);
1075 } 1074 }
1076 fprintf(stderr,"\n"); 1075 fprintf(stderr,"\n");
1077} 1076}
1078 1077
1079void add_to_racelist (const char *race_name, object *op) { 1078void add_to_racelist (const char *race_name, object *op) {
1084 1083
1085 if(!race) { /* add in a new race list */ 1084 if(!race) { /* add in a new race list */
1086 race = get_racelist(); 1085 race = get_racelist();
1087 race->next = first_race; 1086 race->next = first_race;
1088 first_race = race; 1087 first_race = race;
1089 race->name=add_string(race_name); 1088 race->name = race_name;
1090 } 1089 }
1091 1090
1092 if(race->member->ob) { 1091 if(race->member->ob) {
1093 objectlink *tmp = get_objectlink(); 1092 objectlink *tmp = get_objectlink();
1094 tmp->next=race->member; 1093 tmp->next=race->member;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines