| 106 | #endif // DEBUG |
| 107 | |
| 108 | void CLevel::g_sv_Spawn(CSE_Abstract* E) |
| 109 | { |
| 110 | //----------------------------------------------------------------- |
| 111 | // CTimer T(false); |
| 112 | |
| 113 | #ifdef DEBUG |
| 114 | Msg("* CLIENT: Spawn: %s, ID=%d", *E->s_name, E->ID); |
| 115 | #endif |
| 116 | |
| 117 | auto obj = Objects.net_Find(E->ID); |
| 118 | if (obj && obj->getDestroy()) |
| 119 | { |
| 120 | Msg("[%s]: %s[%u] already net_Spawn'ed, call ProcessDestroyQueue()", __FUNCTION__, obj->cName().c_str(), obj->ID()); |
| 121 | Objects.ProcessDestroyQueue(); |
| 122 | } |
| 123 | |
| 124 | // Client spawn |
| 125 | // T.Start (); |
| 126 | CObject* O = Objects.Create(*E->s_name); |
| 127 | // Msg ("--spawn--CREATE: %f ms",1000.f*T.GetAsync()); |
| 128 | |
| 129 | // T.Start (); |
| 130 | if (0 == O || (!O->net_Spawn(E))) |
| 131 | { |
| 132 | O->setDestroy(TRUE); |
| 133 | O->net_Destroy(); |
| 134 | client_spawn_manager().clear(O->ID()); |
| 135 | Objects.Destroy(O); |
| 136 | Msg("! Failed to spawn entity '%s'", *E->s_name); |
| 137 | } |
| 138 | else |
| 139 | { |
| 140 | client_spawn_manager().callback(O); |
| 141 | // Msg ("--spawn--SPAWN: %f ms",1000.f*T.GetAsync()); |
| 142 | if ((E->s_flags.is(M_SPAWN_OBJECT_LOCAL)) && (E->s_flags.is(M_SPAWN_OBJECT_ASPLAYER))) |
| 143 | { |
| 144 | if (CurrentEntity() != NULL) |
| 145 | { |
| 146 | CGameObject* pGO = smart_cast<CGameObject*>(CurrentEntity()); |
| 147 | if (pGO) |
| 148 | pGO->On_B_NotCurrentEntity(); |
| 149 | } |
| 150 | SetEntity(O); |
| 151 | SetControlEntity(O); |
| 152 | } |
| 153 | |
| 154 | if (0xffff != E->ID_Parent) |
| 155 | { |
| 156 | NET_Packet GEN; |
| 157 | GEN.write_start(); |
| 158 | GEN.read_start(); |
| 159 | GEN.w_u16(u16(O->ID())); |
| 160 | cl_Process_Event(E->ID_Parent, GE_OWNERSHIP_TAKE, GEN); |
| 161 | } |
| 162 | } |
| 163 | //--------------------------------------------------------- |
| 164 | Game().OnSpawn(O); |
| 165 | //--------------------------------------------------------- |
nothing calls this directly
no test coverage detected