Exemplo n.º 1
0
Arquivo: server.c Projeto: Asiron/ucs
int change_room(MSG_ROOM room_action, int client_id){
    
lock_repo();
    int i;
    int room_exists_on_server = FALSE;
    for(i=0; i<REPO_SIZE; ++i){
        if( !strcmp(SHM_ROOM_SERVER_ADRESS[i].room_name, room_action.room_name) &&
           SHM_ROOM_SERVER_ADRESS[i].server_id == MSG_RECEIVER){
            room_exists_on_server = TRUE;
            break;
        }
    }
unlock_repo();
    
    if (!room_exists_on_server) {
        int return_flag = create_room(room_action.room_name);
        if (return_flag == FULL) {
            return FULL;
        }
    }
    
    char* old_room = change_users_room_in_local_repo(client_id, room_action.room_name);
    if( count_people_in_room(old_room) == 0){
        delete_room(old_room);
    }
    
    log_data("USER %s CHANGED ROOM FROM  %s TO %s", room_action.user_name, old_room, room_action.room_name);
    free(old_room);
    
    return SUCCESS;
}
Exemplo n.º 2
0
/**
* WARNING: This function actually deletes a building.
*
* @param char_data *ch The person doing the deleting.
* @param bld_vnum vnum The vnum to delete.
*/
void olc_delete_building(char_data *ch, bld_vnum vnum) {
	void check_for_bad_buildings();
	extern bool delete_link_rule_by_type_value(struct adventure_link_rule **list, int type, any_vnum value);
	void remove_building_from_table(bld_data *bld);
	
	descriptor_data *desc;
	room_data *room, *next_room;
	craft_data *craft, *next_craft;
	adv_data *adv, *next_adv;
	bld_data *bld;
	int count;
	bool found, deleted = FALSE;
	
	if (!(bld = building_proto(vnum))) {
		msg_to_char(ch, "There is no such building %d.\r\n", vnum);
		return;
	}
	
	if (HASH_COUNT(building_table) <= 1) {
		msg_to_char(ch, "You can't delete the last building.\r\n");
		return;
	}
	
	// pull from hash
	remove_building_from_table(bld);

	// save index and building file now
	save_index(DB_BOOT_BLD);
	save_library_file_for_vnum(DB_BOOT_BLD, vnum);
	
	// update world
	count = 0;
	HASH_ITER(world_hh, world_table, room, next_room) {
		if (IS_ANY_BUILDING(room) && BUILDING_VNUM(room) == vnum) {
			if (GET_ROOM_VNUM(room) >= MAP_SIZE) {
				delete_room(room, FALSE);	// must call check_all_exits
				deleted = TRUE;
			}
			else {
				// map room
				if (ROOM_PEOPLE(room)) {
					act("The building has been deleted.", FALSE, ROOM_PEOPLE(room), NULL, NULL, TO_CHAR | TO_ROOM);
				}
				disassociate_building(room);
			}
		}
	}
	if (deleted) {
		check_all_exits();
	}
	
	// adventure zones
	HASH_ITER(hh, adventure_table, adv, next_adv) {
		found = delete_link_rule_by_type_value(&GET_ADV_LINKING(adv), ADV_LINK_BUILDING_EXISTING, vnum);
		found |= delete_link_rule_by_type_value(&GET_ADV_LINKING(adv), ADV_LINK_BUILDING_NEW, vnum);
		found |= delete_link_rule_by_type_value(&GET_ADV_LINKING(adv), ADV_LINK_PORTAL_BUILDING_EXISTING, vnum);
		found |= delete_link_rule_by_type_value(&GET_ADV_LINKING(adv), ADV_LINK_PORTAL_BUILDING_NEW, vnum);
		
		if (found) {
			save_library_file_for_vnum(DB_BOOT_ADV, GET_ADV_VNUM(adv));
		}
	}