Code:
//Copies original zones information into a new zone entry replacing the old zoneidnumber with the instflagnum
void ZoneDatabase::LoadInstZone(int32 target_zone_ID, int32 instFlagNum){
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
int32 affected_rows = 0;
string tmpzonename = database.GetZoneName(target_zone_ID);
string temp;
const char* temp2;
stringstream tmpFlag; // used for converting int32 instFlagNum to a string
tmpFlag << instFlagNum;
temp = tmpFlag.str();
temp.append(tmpzonename);
temp2 = temp.c_str();
if (RunQuery(query, MakeAnyLenString(&query, "INSERT INTO zone (short_name, file_name, long_name, safe_x, safe_y, safe_z, graveyard_id, min_level, min_status, zoneidnumber, timezone, maxclients, weather, note, underworld, minclip, maxclip, fog_minclip, fog_maxclip, fog_blue, fog_red, fog_green, sky, ztype, zone_exp_multiplier, walkspeed, time_type, fog_red1, fog_green1, fog_blue1, fog_minclip1, fog_maxclip1, fog_red2, fog_green2, fog_blue2, fog_minclip2, fog_maxclip2, fog_red3, fog_green3, fog_blue3, fog_minclip3, fog_maxclip3, fog_red4, fog_green4, fog_blue4, fog_minclip4, fog_maxclip4, flag_needed, canbind, cancombat, canlevitate, castoutdoor, insttype, insttimer) SELECT '%s', file_name, long_name, safe_x, safe_y, safe_z, graveyard_id, min_level, min_status, %i, timezone, maxclients, weather, note, underworld, minclip, maxclip, fog_minclip, fog_maxclip, fog_blue, fog_red, fog_green, sky, ztype, zone_exp_multiplier, walkspeed, time_type, fog_red1, fog_green1, fog_blue1, fog_minclip1, fog_maxclip1, fog_red2, fog_green2, fog_blue2, fog_minclip2, fog_maxclip2, fog_red3, fog_green3, fog_blue3, fog_minclip3, fog_maxclip3, fog_red4, fog_green4, fog_blue4, fog_minclip4, fog_maxclip4, flag_needed, canbind, cancombat, canlevitate, castoutdoor, insttype, insttimer FROM zone WHERE zoneidnumber =%i", temp2,instFlagNum,target_zone_ID), errbuf, 0, &affected_rows)){
safe_delete_array(query);}
else {
cerr << "Error in LoadInstZone query '" << query << "' " << errbuf << endl;
safe_delete_array(query);
}
The section of code in red bothers me because every time the zone table's columns change it will need updated. Anyone have a better method for copying one zones info and inserting it back into the database changing only the zonename and zoneidnumber? We may be able to simply eliminate this copy/paste as long as the code always queries the database based on the original zone id not the instance zone id.
Also, I am reluctant to enable inheriting of instance flags in groups and raids because it may allow players to circumvent zone limitations. For example,
The group then invites another character.
To keep players from doing this we would either have to boot them from the instance when they disband or have a hidden NPC check the zone every few minutes for players without the correct instance flag.
Another side note, I may have a fix for the goto command but I need to test it.