void do_check_areas(CHAR_DATA * ch, char * argument) { hash_table * room_hash; hash_table * obj_hash; hash_table * mob_hash; int min_vnum, max_vnum; int new_vnum,old_vnum; char buffer[MAX_INPUT_LENGTH]; FILE * out_file; AREA_DATA * CurArea; BUILD_DATA_LIST * pList; ROOM_INDEX_DATA * pRoomIndex; OBJ_INDEX_DATA * pObjIndex; /* Create hash tables for rooms, mobiles, objects */ room_hash=create_hash_table(MAX_KEY_HASH); obj_hash=create_hash_table(MAX_KEY_HASH); mob_hash=create_hash_table(MAX_KEY_HASH); out_file=fopen("area_changes.txt","a"); for (CurArea=first_area; CurArea != NULL; CurArea=CurArea->next) { min_vnum=CurArea->min_vnum; max_vnum=CurArea->max_vnum; fprintf(out_file,"%s:\n",CurArea->name); /* Go through rooms */ for (pList=CurArea->first_area_room; pList != NULL; pList=pList->next) { pRoomIndex=pList->data; if (pRoomIndex->vnum < min_vnum || pRoomIndex->vnum > max_vnum) { old_vnum=pRoomIndex->vnum; /* Find a free slot */ for (new_vnum=min_vnum; new_vnum <= max_vnum; new_vnum++) if (get_room_index(new_vnum)==NULL) break; if (new_vnum > max_vnum) { sprintf(buffer,"Not enough vnums in area %s\n\r",CurArea->name); send_to_char(buffer,ch); } else { fprintf(out_file,"Room: [%5i] -> [%5i]\n",old_vnum,new_vnum); /* Delete from room hashing table, and put new vnum in. */ add_hash_entry(room_hash,old_vnum,(void *) new_vnum); swap_global_hash('R',pRoomIndex,old_vnum,new_vnum); pRoomIndex->vnum=new_vnum; area_modified(CurArea); } } } /* Go through objs */ for (pList=CurArea->first_area_object; pList != NULL; pList=pList->next) { pObjIndex=pList->data; if (pObjIndex->vnum < min_vnum || pObjIndex->vnum > max_vnum) { old_vnum=pObjIndex->vnum; /* Find a free slot */ for (new_vnum=min_vnum; new_vnum <= max_vnum; new_vnum++) if (get_obj_index(new_vnum)==NULL) break; if (new_vnum > max_vnum) { sprintf(buffer,"Not enough vnums in area %s\n\r",CurArea->name); send_to_char(buffer,ch); } else { fprintf(out_file,"Obj: [%5i] -> [%5i] %s\n",old_vnum,new_vnum,pObjIndex->short_descr); /* Delete from obj hashing table, and put new vnum in. */ add_hash_entry(obj_hash,old_vnum,(void *) new_vnum); swap_global_hash('O',pObjIndex,old_vnum,new_vnum); pObjIndex->vnum=new_vnum; area_modified(CurArea); } } } } fclose(out_file); return; }
void do_check_areas(CHAR_DATA * ch, char * argument) { hash_table * room_hash; hash_table * obj_hash; hash_table * mob_hash; int min_vnum,max_vnum; int new_vnum,old_vnum; char buffer[MAX_INPUT_LENGTH]; FILE * out_file; int a; RESET_DATA * pReset; AREA_DATA * CurArea; BUILD_DATA_LIST * pList; ROOM_INDEX_DATA * pRoomIndex; OBJ_INDEX_DATA * pObjIndex; MOB_INDEX_DATA * pMobIndex; /* Create hash tables for rooms, mobiles, objects */ room_hash=create_hash_table(MAX_KEY_HASH); obj_hash=create_hash_table(MAX_KEY_HASH); mob_hash=create_hash_table(MAX_KEY_HASH); out_file=fopen("area_changes.txt","a"); for (CurArea=first_area; CurArea != NULL; CurArea=CurArea->next) { min_vnum=CurArea->min_vnum; max_vnum=CurArea->max_vnum; fprintf(out_file,"%s:\n",CurArea->name); /* Go through rooms */ for (pList=CurArea->first_area_room; pList != NULL; pList=pList->next) { pRoomIndex=pList->data; if (pRoomIndex->vnum < min_vnum || pRoomIndex->vnum > max_vnum) { old_vnum=pRoomIndex->vnum; /* Find a free slot */ for (new_vnum=min_vnum; new_vnum <= max_vnum; new_vnum++) if (get_room_index(new_vnum)==NULL) break; if (new_vnum > max_vnum) { sprintf(buffer,"Not enough vnums in area %s\n\r",CurArea->name); send_to_char(buffer,ch); } else { fprintf(out_file,"Room: [%5i] -> [%5i] %s\n",old_vnum,new_vnum,pRoomIndex->name); /* Delete from room hashing table, and put new vnum in. */ add_hash_entry(room_hash,old_vnum,(void *) new_vnum); swap_global_hash('R',pRoomIndex,old_vnum,new_vnum); pRoomIndex->vnum=new_vnum; area_modified(CurArea); } } } /* Go through objs */ for (pList=CurArea->first_area_object; pList != NULL; pList=pList->next) { pObjIndex=pList->data; if (pObjIndex->vnum < min_vnum || pObjIndex->vnum > max_vnum) { old_vnum=pObjIndex->vnum; /* Find a free slot */ for (new_vnum=min_vnum; new_vnum <= max_vnum; new_vnum++) if (get_obj_index(new_vnum)==NULL) break; if (new_vnum > max_vnum) { sprintf(buffer,"Not enough vnums in area %s\n\r",CurArea->name); send_to_char(buffer,ch); } else { fprintf(out_file,"Obj: [%5i] -> [%5i] %s\n",old_vnum,new_vnum,pObjIndex->short_descr); /* Delete from obj hashing table, and put new vnum in. */ add_hash_entry(obj_hash,old_vnum,(void *) new_vnum); swap_global_hash('O',pObjIndex,old_vnum,new_vnum); pObjIndex->vnum=new_vnum; area_modified(CurArea); } } } /* Go through mobs */ for (pList=CurArea->first_area_mobile; pList != NULL; pList=pList->next) { pMobIndex=pList->data; if (pMobIndex->vnum < min_vnum || pMobIndex->vnum > max_vnum) { old_vnum=pMobIndex->vnum; /* Find a free slot */ for (new_vnum=min_vnum; new_vnum <= max_vnum; new_vnum++) if (get_mob_index(new_vnum)==NULL) break; if (new_vnum > max_vnum) { sprintf(buffer,"Not enough vnums in area %s\n\r",CurArea->name); send_to_char(buffer,ch); } else { fprintf(out_file,"Mob: [%5i] -> [%5i] %s\n",old_vnum,new_vnum,pMobIndex->short_descr); /* Delete from mob hashing table, and put new vnum in. */ add_hash_entry(mob_hash,old_vnum,(void *) new_vnum); swap_global_hash('M',pMobIndex,old_vnum,new_vnum); pMobIndex->vnum=new_vnum; area_modified(CurArea); /* Check for shops */ if (pMobIndex->pShop != NULL) pMobIndex->pShop->keeper=new_vnum; } } } } fclose(out_file); /* Now go through all things referencing the changes * * Resets * exit->key * */ for (CurArea=first_area; CurArea != NULL; CurArea=CurArea->next) { for (pList=CurArea->first_area_room; pList != NULL; pList=pList->next) { /* Check keys and exits*/ pRoomIndex=pList->data; for (a=0; a<=5; a++) { if ( pRoomIndex->exit[a] != NULL ) { if ( pRoomIndex->exit[a]->key != 0 && (new_vnum=(int) get_hash_entry(obj_hash,pRoomIndex->exit[a]->key)) != 0) { pRoomIndex->exit[a]->key = new_vnum; area_modified(CurArea); } if ( (new_vnum=(int) get_hash_entry(room_hash,pRoomIndex->exit[a]->vnum)) != 0) { pRoomIndex->exit[a]->vnum = new_vnum; area_modified(CurArea); } } } } /* Scan through resets */ for (pReset=CurArea->first_reset; pReset != NULL; pReset=pReset->next) { switch (pReset->command) { case 'M': if ( (new_vnum=(int) get_hash_entry(mob_hash,pReset->arg1)) != 0) { area_modified(CurArea); pReset->arg1=new_vnum; } if ( (new_vnum=(int) get_hash_entry(room_hash,pReset->arg3)) != 0) { area_modified(CurArea); pReset->arg3=new_vnum; } break; case 'O': if ( (new_vnum=(int) get_hash_entry(obj_hash,pReset->arg1)) != 0) { area_modified(CurArea); pReset->arg1=new_vnum; } if ( (new_vnum=(int) get_hash_entry(room_hash,pReset->arg3)) != 0) { area_modified(CurArea); pReset->arg3=new_vnum; } break; case 'P': if ( (new_vnum=(int) get_hash_entry(obj_hash,pReset->arg1)) != 0) { area_modified(CurArea); pReset->arg1=new_vnum; } if ( (new_vnum=(int) get_hash_entry(obj_hash,pReset->arg3)) != 0) { area_modified(CurArea); pReset->arg3=new_vnum; } break; case 'G': case 'E': if ( (new_vnum=(int) get_hash_entry(obj_hash,pReset->arg1)) != 0) { area_modified(CurArea); pReset->arg1=new_vnum; } break; case 'D': case 'R': if ( (new_vnum=(int) get_hash_entry(room_hash,pReset->arg1)) != 0) { area_modified(CurArea); pReset->arg1=new_vnum; } break; } } } /* FINISHED */ delete_hash_table(room_hash); delete_hash_table(obj_hash); delete_hash_table(mob_hash); return; }