bool Location::CreateUpdate(iDataConnection* db) { const char* fields[] = { "type_id", "id_prev_loc_in_region", "name", "x", "y", "z", "angle", "radius", "flags", "loc_sector_id" }; psStringArray values; values.FormatPush("%d",type->GetID()); values.FormatPush("%d",id_prev_loc_in_region); values.Push(name); values.FormatPush("%.2f",pos.x); values.FormatPush("%.2f",pos.y); values.FormatPush("%.2f",pos.z); values.FormatPush("%.2f",rot_angle); values.FormatPush("%.2f",radius); csString flagStr; values.Push(flagStr.GetDataSafe()); values.FormatPush("%d",GetSectorID(db,sectorName)); if(id == -1) { id = db->GenericInsertWithID("sc_locations",fields,values); if(id == 0) { id = -1; return false; } } else { csString idStr; idStr.Format("%d",id); return db->GenericUpdateWithID("sc_locations","id",idStr,fields,values); } return false; }
/* * Send confirmation to a player. */ void AWormHole::Confirmation(bool Confirm, long AbilityID, long GameID) { Player *p = g_PlayerMgr->GetPlayer(GameID); if (Confirm && p) { // Make the player wormhole p->WormHole(GetSectorID(m_SkillRank)); } //reguardless of what the player chooses, this is the "end" of the skill, mark it as such. if(p == m_Player) { m_Player->SetCurrentSkill(); m_DamageTaken = 0.0f; m_InUse = false; } }
bool Location::Import(iDocumentNode* node, iDataConnection* db,int typeID) { name = node->GetAttributeValue("name"); pos.x = node->GetAttributeValueAsFloat("x"); pos.y = node->GetAttributeValueAsFloat("y"); pos.z = node->GetAttributeValueAsFloat("z"); rot_angle = node->GetAttributeValueAsFloat("angle"); radius = node->GetAttributeValueAsFloat("radius"); sectorName = node->GetAttributeValue("sector"); id_prev_loc_in_region = 0; // Not suppored for import. const char* fields[] = {"type_id","id_prev_loc_in_region","name","x","y","z","angle","radius","flags","loc_sector_id"}; psStringArray values; values.FormatPush("%d",typeID); values.FormatPush("%d",id_prev_loc_in_region); values.Push(name); values.FormatPush("%.2f",pos.x); values.FormatPush("%.2f",pos.y); values.FormatPush("%.2f",pos.z); values.FormatPush("%.2f",rot_angle); values.FormatPush("%.2f",radius); csString flagStr; values.Push(flagStr); values.FormatPush("%d",GetSectorID(db,sectorName)); if(id == -1) { id = db->GenericInsertWithID("sc_locations",fields,values); if(id == 0) { return false; } } else { csString idStr; idStr.Format("%d",id); return db->GenericUpdateWithID("sc_locations","id",idStr,fields,values); } return true; }
void Tribe::SaveMemory(Memory* memory) { const char* fields[] = {"tribe_id","name","loc_x","loc_y","loc_z","sector_id","radius"}; psStringArray values; values.FormatPush("%d",GetID()); values.FormatPush("%s",memory->name.GetDataSafe()); values.FormatPush("%.2f",memory->pos.x); values.FormatPush("%.2f",memory->pos.y); values.FormatPush("%.2f",memory->pos.z); values.FormatPush("%d",GetSectorID(db,memory->GetSector()->QueryObject()->GetName())); values.FormatPush("%.2f",memory->radius); memory->id = db->GenericInsertWithID("sc_tribe_memories",fields,values); if(id == 0) { CPrintf(CON_ERROR, "Failed to save memory for tribe: %s.\n", db->GetLastError()); return; } }