void game_sv_GameState::assign_RP (CSE_Abstract* E, game_PlayerState* ps_who) { VERIFY (E); u8 l_uc_team = u8(-1); CSE_Spectator *tpSpectator = smart_cast<CSE_Spectator*>(E); if (tpSpectator) { l_uc_team = tpSpectator->g_team(); #ifdef DEBUG Msg("--- game_sv_GameState RPoint for Spectators uses team [%d]", l_uc_team); #endif // #ifdef DEBUG } else { CSE_ALifeCreatureAbstract *tpTeamed = smart_cast<CSE_ALifeCreatureAbstract*>(E); if (tpTeamed) { l_uc_team = tpTeamed->g_team(); #ifdef DEBUG Msg("--- game_sv_GameState RPoint for AlifeCreature uses team [%d]", l_uc_team); #endif // #ifdef DEBUG } else { R_ASSERT2(false/*tpTeamed*/,"Non-teamed object is assigning to respawn point!"); } } R_ASSERT2(l_uc_team < TEAM_COUNT, make_string("not found rpoint for team [%d]", l_uc_team).c_str()); xr_vector<RPoint>& rp = rpoints[l_uc_team]; #ifdef DEBUG Msg("---Size of rpoints of team [%d] is [%d]", l_uc_team, rp.size()); #endif //----------------------------------------------------------- xr_vector<u32> xrp;// = rpoints[l_uc_team]; for (u32 i=0; i<rp.size(); i++) { if (rp[i].TimeToUnfreeze < Level().timeServer()) xrp.push_back(i); } u32 rpoint = 0; if (xrp.size() && !tpSpectator) { rpoint = xrp[::Random.randI((int)xrp.size())]; } else { if (!tpSpectator) { for (u32 i=0; i<rp.size(); i++) { rp[i].TimeToUnfreeze = 0; }; }; rpoint = ::Random.randI((int)rp.size()); } //----------------------------------------------------------- #ifdef DEBUG Msg("--- Result rpoint is [%d]", rpoint); #endif // #ifdef DEBUG RPoint& r = rp[rpoint]; if (!tpSpectator) { r.TimeToUnfreeze = Level().timeServer() + g_sv_base_dwRPointFreezeTime; }; E->o_Position.set (r.P); E->o_Angle.set (r.A); }
BOOL CEntity::net_Spawn (CSE_Abstract* DC) { m_level_death_time = 0; m_game_death_time = 0; m_killer_id = ALife::_OBJECT_ID(-1); CSE_Abstract *e = (CSE_Abstract*)(DC); CSE_ALifeCreatureAbstract *E = smart_cast<CSE_ALifeCreatureAbstract*>(e); // Initialize variables if (E) { SetfHealth (E->get_health()); R_ASSERT2(!((E->get_killer_id() != ALife::_OBJECT_ID(-1)) && g_Alive()), make_string("server entity [%s][%d] has an killer [%d] and not dead", E->name_replace(), E->ID, E->get_killer_id()).c_str()); m_killer_id = E->get_killer_id(); if (m_killer_id == ID()) m_killer_id = ALife::_OBJECT_ID(-1); } else SetfHealth (1.0f); // load damage params if (!E) { // Car or trader only!!!! CSE_ALifeCar *C = smart_cast<CSE_ALifeCar*>(e); CSE_ALifeTrader *T = smart_cast<CSE_ALifeTrader*>(e); CSE_ALifeHelicopter *H = smart_cast<CSE_ALifeHelicopter*>(e); R_ASSERT2 (C||T||H,"Invalid entity (no inheritance from CSE_CreatureAbstract, CSE_ALifeItemCar and CSE_ALifeTrader and CSE_ALifeHelicopter)!"); id_Team = id_Squad = id_Group = 0; } else { id_Team = E->g_team(); id_Squad = E->g_squad(); id_Group = E->g_group(); CSE_ALifeMonsterBase *monster = smart_cast<CSE_ALifeMonsterBase*>(E); if (monster) { MONSTER_COMMUNITY monster_community; monster_community.set (pSettings->r_string(*cNameSect(), "species")); if(monster_community.team() != 255) id_Team = monster_community.team(); } } if (g_Alive() && IsGameTypeSingle()) { m_registered_member = true; Level().seniority_holder().team(g_Team()).squad(g_Squad()).group(g_Group()).register_member(this); ++Level().seniority_holder().team(g_Team()).squad(g_Squad()).group(g_Group()).m_dwAliveCount; } if(!g_Alive()) { m_level_death_time = Device.dwTimeGlobal; m_game_death_time = E->m_game_death_time;; } if (!inherited::net_Spawn(DC)) return (FALSE); // SetfHealth (E->fHealth); IKinematics* pKinematics=smart_cast<IKinematics*>(Visual()); CInifile* ini = NULL; if(pKinematics) ini = pKinematics->LL_UserData(); if (ini) { if (ini->section_exist("damage_section") && !use_simplified_visual()) CDamageManager::reload(pSettings->r_string("damage_section","damage"),ini); CParticlesPlayer::LoadParticles(pKinematics); } return TRUE; }