void CObject::Load (LPCSTR section ) { // Name R_ASSERT (section); cName_set (section); cNameSect_set (section); // Visual and light-track if (pSettings->line_exist(section,"visual")){ string_path tmp; strcpy (tmp, pSettings->r_string(section,"visual")); if(strext(tmp)) *strext(tmp) =0; xr_strlwr (tmp); cNameVisual_set (tmp); } setVisible (false); }
CObject::~CObject ( ) { cNameVisual_set ( 0 ); cName_set ( 0 ); cNameSect_set ( 0 ); }
BOOL CGameObject::net_Spawn (CSE_Abstract* DC) { VERIFY (!m_spawned); m_spawned = true; m_spawn_time = Device.dwFrame; m_ai_obstacle = xr_new<ai_obstacle>(this); CSE_Abstract *E = (CSE_Abstract*)DC; VERIFY (E); const CSE_Visual *visual = smart_cast<const CSE_Visual*>(E); if (visual) { cNameVisual_set (visual_name(E)); if (visual->flags.test(CSE_Visual::flObstacle)) { ISpatial *self = smart_cast<ISpatial*>(this); self->spatial.type |= STYPE_OBSTACLE; } } // Naming cName_set (E->s_name); cNameSect_set (E->s_name); if (E->name_replace()[0]) cName_set (E->name_replace()); bool demo_spectator = false; if (Level().IsDemoPlayStarted() && E->ID == u16(-1)) { Msg("* Spawning demo spectator ..."); demo_spectator = true; } else { R_ASSERT(Level().Objects.net_Find(E->ID) == NULL); } setID (E->ID); // if (GameID() != eGameIDSingle) // Msg ("CGameObject::net_Spawn -- object %s[%x] setID [%d]", *(E->s_name), this, E->ID); // XForm XFORM().setXYZ (E->o_Angle); Position().set (E->o_Position); #ifdef DEBUG if(ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject)&&stricmp(PH_DBG_ObjectTrackName(),*cName())==0) { Msg("CGameObject::net_Spawn obj %s Position set from CSE_Abstract %f,%f,%f",PH_DBG_ObjectTrackName(),Position().x,Position().y,Position().z); } #endif VERIFY (_valid(renderable.xform)); VERIFY (!fis_zero(DET(renderable.xform))); CSE_ALifeObject *O = smart_cast<CSE_ALifeObject*>(E); if (O && xr_strlen(O->m_ini_string)) { #pragma warning(push) #pragma warning(disable:4238) m_ini_file = xr_new<CInifile>( &IReader ( (void*)(*(O->m_ini_string)), O->m_ini_string.size() ), FS.get_path("$game_config$")->m_Path ); #pragma warning(pop) } m_story_id = ALife::_STORY_ID(-1); if (O) m_story_id = O->m_story_id; // Net params setLocal (E->s_flags.is(M_SPAWN_OBJECT_LOCAL)); if (Level().IsDemoPlay()) //&& OnClient()) { if (!demo_spectator) { setLocal(FALSE); } }; setReady (TRUE); if (!demo_spectator) g_pGameLevel->Objects.net_Register (this); m_server_flags.one (); if (O) { m_server_flags = O->m_flags; if (O->m_flags.is(CSE_ALifeObject::flVisibleForAI)) spatial.type |= STYPE_VISIBLEFORAI; else spatial.type = (spatial.type | STYPE_VISIBLEFORAI) ^ STYPE_VISIBLEFORAI; } reload (*cNameSect()); if(!g_dedicated_server) CScriptBinder::reload (*cNameSect()); reinit (); if(!g_dedicated_server) CScriptBinder::reinit (); #ifdef DEBUG if(ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject)&&stricmp(PH_DBG_ObjectTrackName(),*cName())==0) { Msg("CGameObject::net_Spawn obj %s After Script Binder reinit %f,%f,%f",PH_DBG_ObjectTrackName(),Position().x,Position().y,Position().z); } #endif //load custom user data from server if(!E->client_data.empty()) { // Msg ("client data is present for object [%d][%s], load is processed",ID(),*cName()); IReader ireader = IReader(&*E->client_data.begin(), E->client_data.size()); net_Load (ireader); } else { // Msg ("no client data for object [%d][%s], load is skipped",ID(),*cName()); } // if we have a parent if ( ai().get_level_graph() ) { if ( E->ID_Parent == 0xffff ) { CSE_ALifeObject* l_tpALifeObject = smart_cast<CSE_ALifeObject*>(E); if (l_tpALifeObject && ai().level_graph().valid_vertex_id(l_tpALifeObject->m_tNodeID)) ai_location().level_vertex (l_tpALifeObject->m_tNodeID); else { CSE_Temporary* l_tpTemporary = smart_cast<CSE_Temporary*> (E); if (l_tpTemporary && ai().level_graph().valid_vertex_id(l_tpTemporary->m_tNodeID)) ai_location().level_vertex (l_tpTemporary->m_tNodeID); } if (l_tpALifeObject && ai().game_graph().valid_vertex_id(l_tpALifeObject->m_tGraphID)) ai_location().game_vertex (l_tpALifeObject->m_tGraphID); validate_ai_locations (false); // validating position if ( UsedAI_Locations() && ai().level_graph().inside( ai_location().level_vertex_id(), Position() ) && can_validate_position_on_spawn() ) Position().y = EPS_L + ai().level_graph().vertex_plane_y(*ai_location().level_vertex(),Position().x,Position().z); } else { CSE_ALifeObject* const alife_object = smart_cast<CSE_ALifeObject*>(E); if ( alife_object && ai().level_graph().valid_vertex_id(alife_object->m_tNodeID) ) { ai_location().level_vertex (alife_object->m_tNodeID); ai_location().game_vertex (alife_object->m_tGraphID); } } } inherited::net_Spawn (DC); m_bObjectRemoved = false; spawn_supplies (); #ifdef DEBUG if(ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject)&&stricmp(PH_DBG_ObjectTrackName(),*cName())==0) { Msg("CGameObject::net_Spawn obj %s Before CScriptBinder::net_Spawn %f,%f,%f",PH_DBG_ObjectTrackName(),Position().x,Position().y,Position().z); } BOOL ret =CScriptBinder::net_Spawn(DC); #else return (CScriptBinder::net_Spawn(DC)); #endif #ifdef DEBUG if(ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject)&&stricmp(PH_DBG_ObjectTrackName(),*cName())==0) { Msg("CGameObject::net_Spawn obj %s Before CScriptBinder::net_Spawn %f,%f,%f",PH_DBG_ObjectTrackName(),Position().x,Position().y,Position().z); } return ret; #endif }