/** * @sa G_RecalcRouting */ void G_CompleteRecalcRouting (void) { edict_t *ent = NULL; while ((ent = G_EdictsGetNextInUse(ent))) if (IS_BMODEL(ent)) G_RecalcRouting(ent->model); }
static bool Destroy_Breakable (edict_t *self) { vec3_t origin; const char *model = self->model; VectorCenterFromMinsMaxs(self->absmin, self->absmax, origin); /* the HP value is used to decide whether this was a triggered call or a * call during a fight - a triggered call will be handled differently in * terms of timing and the related particle effects in the client code */ if (self->HP == 0) G_EventModelExplodeTriggered(self); else G_EventModelExplode(self); if (self->particle) G_SpawnParticle(origin, self->spawnflags, self->particle); switch (self->material) { case MAT_GLASS: G_EventSpawnSound(PM_ALL, false, self, origin, "misc/breakglass+"); break; case MAT_METAL: G_EventSpawnSound(PM_ALL, false, self, origin, "misc/breakmetal+"); break; case MAT_ELECTRICAL: G_EventSpawnSound(PM_ALL, false, self, origin, "misc/breakelectric+"); break; case MAT_WOOD: G_EventSpawnSound(PM_ALL, false, self, origin, "misc/breakwood+"); break; case MAT_MAX: break; } G_TouchEdicts(self, 10.0f); /* destroy the door trigger */ if (self->child) G_FreeEdict(self->child); /* now we can destroy the edict completely */ G_FreeEdict(self); AABB oldAABB(vec3_origin, vec3_origin); gi.GetInlineModelAABB(model, oldAABB); GridBox rerouteOldBox(oldAABB); G_RecalcRouting(model, rerouteOldBox); return true; }
/** * @brief Opens/closes a door * @note Use function for func_door * @todo Check if the door can be opened or closed - there should not be * anything in the way (e.g. an actor) */ static bool Door_Use (edict_t *door, edict_t *activator) { if (door->doorState == STATE_CLOSED) { door->doorState = STATE_OPENED; /* change rotation/origin and relink */ if (door->type == ET_DOOR) { if (door->dir & DOOR_OPEN_REVERSE) door->angles[door->dir & 3] -= DOOR_ROTATION_ANGLE; else door->angles[door->dir & 3] += DOOR_ROTATION_ANGLE; } else if (door->type == ET_DOOR_SLIDING) { Door_SlidingUse(door); } gi.LinkEdict(door); /* maybe the server called this because the door starts opened */ if (G_MatchIsRunning()) { /* let everybody know, that the door opens */ G_EventDoorOpen(door); if (door->noise[0] != '\0') G_EventSpawnSound(PM_ALL, false, door, door->origin, door->noise); } } else if (door->doorState == STATE_OPENED) { door->doorState = STATE_CLOSED; /* change rotation and relink */ if (door->type == ET_DOOR) { if (door->dir & DOOR_OPEN_REVERSE) door->angles[door->dir & 3] += DOOR_ROTATION_ANGLE; else door->angles[door->dir & 3] -= DOOR_ROTATION_ANGLE; } else if (door->type == ET_DOOR_SLIDING) { Door_SlidingUse(door); } gi.LinkEdict(door); /* closed is the standard, opened is handled above - we need an active * team here already */ if (G_MatchIsRunning()) { /* let everybody know, that the door closes */ G_EventDoorClose(door); if (door->noise[0] != '\0') G_EventSpawnSound(PM_ALL, false, door, door->origin, door->noise); } } else return false; /* Update model orientation */ gi.SetInlineModelOrientation(door->model, door->origin, door->angles); Com_DPrintf(DEBUG_GAME, "Server processed door movement.\n"); /* Update path finding table */ G_RecalcRouting(door->model); if (activator && G_IsLivingActor(activator)) { /* Check if the player appears/perishes, seen from other teams. */ G_CheckVis(activator, true); /* Calc new vis for the activator. */ G_CheckVisTeamAll(activator->team, false, activator); } return true; }
/** * @brief Opens/closes a door * @note Use function for func_door * @todo Check if the door can be opened or closed - there should not be * anything in the way (e.g. an actor) */ static bool Door_Use (edict_t *door, edict_t *activator) { int opening = 1; if (door->doorState == STATE_CLOSED) { door->doorState = STATE_OPENED; opening = 1; } else if (door->doorState == STATE_OPENED) { door->doorState = STATE_CLOSED; opening = -1; } else return false; /* remember the old location */ AABB oldAABB; gi.GetInlineModelAABB(door->model, oldAABB); GridBox rerouteOldBox(oldAABB); /* change rotation and relink */ if (door->type == ET_DOOR) { if (door->dir & DOOR_OPEN_REVERSE) opening *= -1; door->angles[door->dir & 3] += DOOR_ROTATION_ANGLE * opening; } else if (door->type == ET_DOOR_SLIDING) { Door_SlidingUse(door); } gi.LinkEdict(door); /* maybe the server called this because the door starts opened */ if (G_MatchIsRunning()) { /* let everybody know, that the door moves */ if (door->doorState == STATE_OPENED) G_EventDoorOpen(door); else G_EventDoorClose(door); if (door->noise[0] != '\0') { const playermask_t playerMask = G_GetClosePlayerMask(door->origin, UNIT_SIZE * 10); G_EventSpawnSound(playerMask, false, door, door->origin, door->noise); } } /* Update model orientation */ gi.SetInlineModelOrientation(door->model, door->origin, door->angles); AABB newAabb; gi.GetInlineModelAABB(door->model, newAabb); GridBox rerouteNewBox(newAabb); Com_DPrintf(DEBUG_GAME, "Server processed door movement.\n"); /* Update path finding table for the new location of the model */ G_RecalcRouting(door->model, rerouteOldBox); /* Update path finding table */ G_RecalcRouting(door->model, rerouteNewBox); if (activator && G_IsLivingActor(activator)) { /* Check if the player appears/perishes, seen from other teams. */ G_CheckVis(activator); /* Calc new vis for the activator. */ G_CheckVisTeamAll(activator->team, 0, activator); } return true; }