Started adding new C++ based entity system

This commit is contained in:
Walter Julius Hennecke 2018-07-18 20:13:45 +02:00
parent 0a8684db2d
commit c0b46ffd51
35 changed files with 791 additions and 193 deletions

88
code/game/Entity.cpp Normal file
View file

@ -0,0 +1,88 @@
#include "Entity.h"
#include "g_syscalls.h"
namespace game
{
bool Entity::addEvent(int32_t event, int32_t eventParm, AfterEventAction afterEventAction)
{
if(event == 0)
{
return false;
}
auto bits = m_sharedEntity->s.event & EV_EVENT_BITS;
bits = (bits + EV_EVENT_BIT1) & EV_EVENT_BITS;
m_sharedEntity->s.event = event | bits;
m_sharedEntity->s.eventParm = eventParm;
m_afterEventAction = afterEventAction;
m_eventTime = level.time;
return true;
}
void Entity::setOrigin(vec3_t origin)
{
VectorCopy(origin, m_sharedEntity->s.pos.trBase);
m_sharedEntity->s.pos.trType = TR_STATIONARY;
m_sharedEntity->s.pos.trTime = 0;
m_sharedEntity->s.pos.trDuration = 0;
VectorClear(m_sharedEntity->s.pos.trDelta);
VectorCopy(origin, m_sharedEntity->r.currentOrigin);
VectorCopy(origin, m_sharedEntity->s.origin);
}
void Entity::setAngles(vec3_t a)
{
VectorCopy(a, m_sharedEntity->s.apos.trBase);
m_sharedEntity->s.apos.trType = TR_STATIONARY;
m_sharedEntity->s.apos.trTime = 0;
m_sharedEntity->s.apos.trDuration = 0;
VectorClear(m_sharedEntity->s.apos.trDelta);
VectorCopy(a, m_sharedEntity->r.currentAngles);
VectorCopy(a, m_sharedEntity->s.angles);
}
void Entity::free()
{
// TODO: free actual shared entity
trap_UnlinkEntity(m_sharedEntity);
if(m_neverFree)
{
return;
}
// TODO: lua hook
memset(m_sharedEntity, 0, sizeof(GameSharedEntity));
m_sharedEntity->m_inUse = false;
m_sharedEntity->m_freeTime = level.time;
delete this;
}
bool Entity::useTargets()
{
// TODO: implement me
return true;
}
bool Entity::useTargets(const Entity& activator)
{
// TODO: implement me
return true;
}
bool Entity::useTargets(std::string_view target)
{
// TODO: implement me
return true;
}
bool Entity::useTargets(const Entity& activator, std::string_view target)
{
// TODO: implement me
return true;
}
}

98
code/game/Entity.h Normal file
View file

@ -0,0 +1,98 @@
#pragma once
#include "g_local.h"
#include <variant>
#include <optional>
namespace game
{
class Entity
{
public:
Entity(const Entity&) = default;
Entity(Entity&&) = default;
Entity& operator=(const Entity&) = default;
Entity& operator=(Entity&&) = default;
virtual ~Entity() = default;
bool m_neverFree = false;
int32_t m_flags = 0;
enum class AfterEventAction
{
None,
Unlink,
Free
};
int32_t eventTime() const { return m_eventTime; }
virtual bool addEvent(int32_t event, int32_t eventParm, AfterEventAction afterEventAction = AfterEventAction::None);
void setOrigin(vec3_t origin);
void setAngles(vec3_t a);
void enablePhysicsObject(bool enabled = true) { m_physicsObject = enabled; }
void setPhysicsBounce(float value) { m_physicsBounce = value; }
int32_t clipMask() const { return m_clipMask; }
std::string_view className() const { return m_classsName; }
std::string_view targetName() const { return m_targetName; }
std::string_view team() const { return m_team; }
void setTarget(std::string target) { m_target = std::move(target); }
void setPainTarget(std::string painTarget) { m_painTarget = std::move(painTarget); }
void setTargetName(std::string targetName) { m_targetName = std::move(targetName); }
void setTeam(std::string team) { m_team = std::move(team); }
int32_t nextThink() const { return m_nextThink; }
void enableDamage(bool enable = true) { m_takeDamage = enable; }
void setHealth(int32_t health) { m_health = health; }
void free();
virtual void think() = 0;
virtual void touch(const Entity& other, trace_t* trace) = 0;
virtual void use(const Entity& other, const Entity& activator) = 0;
virtual void pain(const Entity& attacker, int32_t damage) = 0;
virtual void die(const Entity& inflictor, const Entity& attacker, int damage, int mod) = 0;
protected:
GameSharedEntity* m_sharedEntity;
int32_t m_health = 0;
int32_t m_oldHealth = 0;
bool m_takeDamage = false;
int32_t m_nextThink = 0;
Entity * m_parent;
int32_t m_clipMask = MASK_SHOT;
bool m_physicsObject = false;
float m_physicsBounce = 0;
AfterEventAction m_afterEventAction = AfterEventAction::None;
int32_t m_eventTime = 0;
EntityType m_type;
std::string m_classsName;
std::string m_target;
std::string m_painTarget;
std::string m_targetName;
std::string m_team;
std::string m_targetShaderName;
std::string m_targetShaderNewName;
Entity(EntityType type, std::string classname, GameSharedEntity* sharedEntity, Entity* parent = nullptr)
: m_sharedEntity{sharedEntity}
, m_parent{ parent }
, m_type{ type }
, m_classsName{ std::move(classname) }
{}
bool useTargets();
bool useTargets(const Entity& activator);
bool useTargets(const Entity& activator, std::string_view target);
bool useTargets(std::string_view target);
};
}

208
code/game/Event.h Normal file
View file

@ -0,0 +1,208 @@
#pragma once
#include <map>
#include <memory>
#include <functional>
#include <cassert>
namespace game
{
namespace Detail
{
class ListenerStorageBase
{
public:
using Handle = size_t;
virtual ~ListenerStorageBase() = default;
virtual bool remove(Handle) = 0;
};
template<typename ListenerType>
class ListenerStorage : public ListenerStorageBase
{
public:
using Handle = ListenerStorageBase::Handle;
using container_type = std::map<Handle, ListenerType>;
using iterator = typename container_type::iterator;
using const_iterator = typename container_type::const_iterator;
iterator begin()
{
return m_listeners.begin();
}
iterator end()
{
return m_listeners.end();
}
const_iterator begin() const
{
return m_listeners.begin();
}
const_iterator end() const
{
return m_listeners.end();
}
const_iterator cbegin() const
{
return m_listeners.cbegin();
}
const_iterator cend() const
{
return m_listeners.cend();
}
size_t size() const
{
return m_listeners.size();
}
void clear()
{
m_listeners.clear();
}
Handle addListener(ListenerType Listener)
{
auto current = m_next++;
m_listeners[current] = Listener;
return current;
}
bool remove(Handle handle) override
{
auto it = m_listeners.find(handle);
if(it == m_listeners.end())
{
return false;
}
m_listeners.erase(handle);
return true;
}
virtual ~ListenerStorage() = default;
private:
Handle m_next = 0;
std::map<Handle, ListenerType> m_listeners;
};
}
class EventConnection
{
public:
using Handle = typename Detail::ListenerStorageBase::Handle;
EventConnection() = default;
EventConnection(const EventConnection&) = delete;
EventConnection(EventConnection&&) = default;
EventConnection& operator=(const EventConnection&) = delete;
EventConnection& operator=(EventConnection&&) = default;
EventConnection(std::weak_ptr<Detail::ListenerStorageBase> ListenerStorage, Handle handle)
: m_handle{ handle }
, m_listenerStorage{ ListenerStorage }
{}
void disconnect()
{
if(auto ptr = m_listenerStorage.lock())
{
ptr->remove(m_handle);
}
}
virtual ~EventConnection() = default;
protected:
Handle m_handle;
std::weak_ptr<Detail::ListenerStorageBase> m_listenerStorage;
};
class ScopedEventConnection : public EventConnection
{
ScopedEventConnection() = default;
ScopedEventConnection(ScopedEventConnection&&) = default;
ScopedEventConnection(EventConnection&& other)
: EventConnection{std::forward<EventConnection>(other)}
{}
ScopedEventConnection& operator=(ScopedEventConnection&&) = default;
ScopedEventConnection& operator=(EventConnection&& other)
{
EventConnection::operator=(std::forward<EventConnection>(other));
return *this;
}
virtual ~ScopedEventConnection()
{
disconnect();
}
};
template<typename>
class Event;
template<typename Ret, typename... Args>
class Event<Ret(Args...)>
{
public:
Event() = default;
Event(const Event&) = delete;
Event(Event&&) = default;
Event& operator=(const Event&) = delete;
Event& operator=(Event&&) = default;
using ListenerType = std::function<Ret(Args...)>;
using result_type = typename ListenerType::result_type;
using Handle = typename Detail::ListenerStorage<ListenerType>::Handle;
void operator()(Args... args)
{
if(m_emitting)
{
assert(false);
return;
}
m_emitting = true;
for(const auto& l : m_listenerStorage)
{
l.second(args...);
}
m_emitting = false;
}
template<typename L>
EventConnection operator+=(L&& listener)
{
return Connect(std::forward<L>(listener));
}
EventConnection connect(ListenerType listener)
{
auto h = m_listenerStorage->addListener(listener);
return EventConnection{m_listenerStorage, h};
}
void disconnect(EventConnection& con)
{
con.disconnect();
}
void disconnectAll()
{
m_listenerStorage->clear();
}
private:
std::shared_ptr<Detail::ListenerStorage<ListenerType> > m_listenerStorage = std::make_shared<Detail::ListenerStorage<ListenerType>>();
bool m_emitting = false;
};
}

View file

@ -0,0 +1,9 @@
#include "InfoCamp.h"
namespace game::entities
{
InfoCamp::InfoCamp(GameSharedEntity* sharedEntity, Entity* parent): Entity{EntityType::ENT_INFO_CAMP, "info_camp", sharedEntity, parent}
{
setOrigin(m_sharedEntity->s.origin);
}
}

View file

@ -0,0 +1,19 @@
#pragma once
#include "../Entity.h"
namespace game::entities
{
class InfoCamp : public Entity
{
public:
InfoCamp(GameSharedEntity* sharedEntity, Entity* parent = nullptr);
void think() override {}
void touch(const Entity&, trace_t*) override {}
void use(const Entity&, const Entity&) override {}
void pain(const Entity&, int32_t) override {}
void die(const Entity&, const Entity&, int, int) override {}
};
}

View file

@ -0,0 +1,9 @@
#include "InfoNotNull.h"
namespace game::entities
{
InfoNotNull::InfoNotNull(GameSharedEntity* sharedEntity, Entity* parent) : Entity{EntityType::ENT_INFO_NOTNULL, "info_notnull", sharedEntity, parent}
{
setOrigin(m_sharedEntity->s.origin);
}
}

View file

@ -0,0 +1,17 @@
#pragma once
#include "../Entity.h"
namespace game::entities
{
class InfoNotNull : public Entity
{
public:
InfoNotNull(GameSharedEntity* sharedEntity, Entity* parent = nullptr);
void think() override {}
void touch(const Entity&, trace_t*) override {}
void use(const Entity&, const Entity&) override {}
void pain(const Entity&, int32_t) override {}
void die(const Entity&, const Entity&, int, int) override {}
};
}

View file

@ -0,0 +1,9 @@
#include "InfoNull.h"
namespace game::entities
{
InfoNull::InfoNull(GameSharedEntity* sharedEntity, Entity* parent) : Entity{EntityType::ENT_INFO_NULL, "info_null", sharedEntity, parent}
{
free();
}
}

View file

@ -0,0 +1,17 @@
#pragma once
#include "../Entity.h"
namespace game::entities
{
class InfoNull : public Entity
{
public:
InfoNull(GameSharedEntity* sharedEntity, Entity* parent);
void think() override {}
void touch(const Entity&, trace_t*) override {}
void use(const Entity&, const Entity&) override {}
void pain(const Entity&, int32_t) override {}
void die(const Entity&, const Entity&, int, int) override {}
};
}

View file

@ -0,0 +1,9 @@
#include "Light.h"
namespace game::entities
{
Light::Light(GameSharedEntity* sharedEntity, Entity* parent) : Entity{EntityType::ENT_LIGHT, "light", sharedEntity, parent}
{
free();
}
}

View file

@ -0,0 +1,17 @@
#pragma once
#include "../Entity.h"
namespace game::entities
{
class Light : public Entity
{
public:
Light(GameSharedEntity* sharedEntity, Entity* parent = nullptr);
void think() override {}
void touch(const Entity&, trace_t*) override {}
void use(const Entity&, const Entity&) override {}
void pain(const Entity&, int32_t) override {}
void die(const Entity&, const Entity&, int, int) override {}
};
}

View file

@ -0,0 +1,9 @@
#include "Model.h"
namespace game::entities
{
Model::Model(GameSharedEntity* sharedEntity, Entity* parent): Entity{EntityType::ENT_MISC_MODEL, "misc_model", sharedEntity, parent}
{
free();
}
}

View file

@ -0,0 +1,19 @@
#pragma once
#include "../Entity.h"
namespace game::entities
{
class Model : public Entity
{
public:
Model(GameSharedEntity* sharedEntity, Entity* parent);
void think() override {}
void touch(const Entity&, trace_t*) override {}
void use(const Entity&, const Entity&) override {}
void pain(const Entity&, int32_t) override {}
void die(const Entity&, const Entity&, int, int) override {}
};
}

View file

@ -60,7 +60,7 @@ static void TryUse(gentity_t* ent)
target = &g_entities[trace.entityNum];
//Check for a use command
if((target != NULL) && (target->use != NULL) && (target->type == ENT_FUNC_USABLE))
if((target != NULL) && (target->use != NULL) && (target->type == EntityType::ENT_FUNC_USABLE))
{//usable brush
if(target->team && atoi(target->team) != 0)
{//usable has a team
@ -78,7 +78,7 @@ static void TryUse(gentity_t* ent)
#endif
return;
}
else if((target != NULL) && (target->use != NULL) && (ent->type == ENT_MISC_AMMOSTATION))
else if((target != NULL) && (target->use != NULL) && (ent->type == EntityType::ENT_MISC_AMMOSTATION))
{//ammo station
if(sess->sessionTeam)
{

View file

@ -43,7 +43,7 @@ void breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker,
eState->solid = 0;
eShared->contents = 0;
self->clipmask = 0;
if(((self->spawnflags & 256) != 0) && (self->type == ENT_FUNC_BREAKABLE)) {
if(((self->spawnflags & 256) != 0) && (self->type == EntityType::ENT_FUNC_BREAKABLE)) {
eShared->svFlags |= SVF_NOCLIENT;
eState->eFlags |= EF_NODRAW;
}
@ -320,7 +320,7 @@ In the unlikely event that we do have an origin brush this is the code:
*/
void SP_func_breakable( gentity_t *self )
{
self->type = ENT_FUNC_BREAKABLE;
self->type = EntityType::ENT_FUNC_BREAKABLE;
if((self->spawnflags & 1) == 0) {
if(self->health == 0) {
@ -432,7 +432,7 @@ void SP_misc_model_breakable( gentity_t *ent )
entityShared_t* eShared = &ent->r;
entityState_t* eState = &ent->s;
ent->type = ENT_MISC_MODEL_BREAKABLE;
ent->type = EntityType::ENT_MISC_MODEL_BREAKABLE;
//Main model
eState->modelindex = ent->sound2to1 = G_ModelIndex( ent->model );
@ -681,7 +681,7 @@ none
*/
void SP_misc_ammo_station( gentity_t *ent )
{
ent->type = ENT_MISC_AMMOSTATION;
ent->type = EntityType::ENT_MISC_AMMOSTATION;
if (ent->health == 0) {
ent->health = 60;
@ -788,7 +788,7 @@ void target_repair_link(gentity_t *ent) {
ent->lastEnemy = target;
if(target->type != ENT_FUNC_BREAKABLE) {
if(target->type != EntityType::ENT_FUNC_BREAKABLE) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_repair at %s with an invalid target entity %s\n", vtos(ent->s.origin), target->classname););
return;
}
@ -800,7 +800,7 @@ void target_repair_link(gentity_t *ent) {
* Spawn function of target_repair entity
*/
void SP_target_repair(gentity_t *ent) {
ent->type = ENT_TARGET_REPAIR;
ent->type = EntityType::ENT_TARGET_REPAIR;
if(ent->target == NULL) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_repair without target at %s\n", vtos(ent->s.origin)););

View file

@ -20,7 +20,7 @@ none
To be written later.
*/
void SP_cinematic_camera(gentity_t *ent) {
ent->type = ENT_CINEMATIC_CAMMERA;
ent->type = EntityType::ENT_CINEMATIC_CAMMERA;
trap_LinkEntity(ent);
InitMover(ent);
}

View file

@ -72,7 +72,7 @@ potential spawning position for deathmatch games.
void SP_info_player_deathmatch(gentity_t *ent) {
int32_t i = 0;
ent->type = ENT_INFO_PLAYER_START;
ent->type = EntityType::ENT_INFO_PLAYER_START;
if (strcmp(ent->classname, "info_player_deathmatch") != 0) {
ent->classname = "info_player_deathmatch";
@ -106,7 +106,7 @@ none
* Spawn function for intermission entity.
*/
void SP_info_player_intermission(gentity_t *ent) {
ent->type = ENT_INFO_PLAYER_INTERMISSION;
ent->type = EntityType::ENT_INFO_PLAYER_INTERMISSION;
}
/**
@ -2820,7 +2820,7 @@ void G_Client_UpdateSoundZones(void) {
memset(&supdate, 0, sizeof(supdate));
for (; i < MAX_GENTITIES; i++) {
if ((g_entities[i].type == ENT_TARGET_ZONE) && (g_entities[i].count == 3)) {
if ((g_entities[i].type == EntityType::ENT_TARGET_ZONE) && (g_entities[i].count == 3)) {
memset(&entlist, 0, sizeof(entlist));
count = trap_EntitiesInBox(g_entities[i].r.mins, g_entities[i].r.maxs, (int32_t*)&entlist, MAX_GENTITIES);

View file

@ -3767,7 +3767,7 @@ static void Cmd_UseEnt_f(gentity_t* ent) {
//Doing it this way can screw up maps bigtime. >.<
//RPG_Chambers may never be the same again.... :S
if (((targetEnt != NULL) && (targetEnt->use != NULL))) {
if (targetEnt->type == ENT_FUNC_USABLE) {
if (targetEnt->type == EntityType::ENT_FUNC_USABLE) {
return;
}
@ -3812,7 +3812,7 @@ static void Cmd_EntList_f(gentity_t* ent) {
i < level.num_entities;
i++, mapEnt++) {
if ((Q_stricmpn(mapEnt->classname, "fx_", 3) == 0) || ((mapEnt->type == ENT_FUNC_USABLE) && (ent->targetname != NULL))) {
if ((Q_stricmpn(mapEnt->classname, "fx_", 3) == 0) || ((mapEnt->type == EntityType::ENT_FUNC_USABLE) && (ent->targetname != NULL))) {
if (mapEnt->use) {
memset(&entBuffer, 0, sizeof(entBuffer));
@ -3944,7 +3944,7 @@ static void Cmd_BeamToLoc_f(gentity_t* ent) {
//Scan for the right entity
for (i = 0, locEnt = g_entities; i < level.num_entities; locEnt++, i++) {
if (locEnt->type == ENT_TARGET_LOCATION) {
if (locEnt->type == EntityType::ENT_TARGET_LOCATION) {
//if we have a health index (which will always be above 0 coz 0 is a default 'unknown' value)
if (locEnt->health == locIndex && locEnt->health >= 1 && locIndex >= 1) {
break;
@ -3958,7 +3958,7 @@ static void Cmd_BeamToLoc_f(gentity_t* ent) {
}
}
if ((locEnt == NULL) || (locEnt->type != ENT_TARGET_LOCATION)) {
if ((locEnt == NULL) || (locEnt->type != EntityType::ENT_TARGET_LOCATION)) {
G_PrintfClient(ent, "Invalid Beam Entity.\n");
return;
}
@ -5258,7 +5258,7 @@ static void Cmd_Turbolift_f(gentity_t* ent) {
}
//found our ent!
if (lift->type == ENT_TARGET_TURBOLIFT) {
if (lift->type == EntityType::ENT_TARGET_TURBOLIFT) {
break;
}
//reset it
@ -5544,9 +5544,9 @@ static void Cmd_lockDoor_f(gentity_t* ent) {
//Doing it this way can screw up maps bigtime. >.<
//RPG_Chambers may never be the same again.... :S
if (targetEnt != NULL) {
if (targetEnt->type != ENT_FUNC_DOOR) {
if (targetEnt->type != EntityType::ENT_FUNC_DOOR) {
//GSIO01 not a func_door?? well then check wheter its a rotating door
if (targetEnt->type != ENT_FUNC_DOOR_ROTATING) {
if (targetEnt->type != EntityType::ENT_FUNC_DOOR_ROTATING) {
trap_SendServerCommand(ent - g_entities, va(" print \"Entity %i isn't a door.\n\" ", index));
return;
}
@ -5683,10 +5683,10 @@ static void Cmd_unlockAll_f(gentity_t* ent) {
#endif
for (i = g_maxclients.integer; i < MAX_GENTITIES; i++) {
if ((g_entities[i].type == ENT_FUNC_DOOR) && ((g_entities[i].flags & FL_LOCKED) != 0)) {
if ((g_entities[i].type == EntityType::ENT_FUNC_DOOR) && ((g_entities[i].flags & FL_LOCKED) != 0)) {
g_entities[i].flags ^= FL_LOCKED;
}
else if ((g_entities[i].type == ENT_FUNC_DOOR_ROTATING) && ((g_entities[i].flags & FL_LOCKED) != 0)) {
else if ((g_entities[i].type == EntityType::ENT_FUNC_DOOR_ROTATING) && ((g_entities[i].flags & FL_LOCKED) != 0)) {
g_entities[i].flags ^= FL_LOCKED;
}
}
@ -5747,10 +5747,10 @@ static void Cmd_lockAll_f(gentity_t* ent) {
#endif
for (i = g_maxclients.integer; i < MAX_GENTITIES; i++) {
if ((g_entities[i].type == ENT_FUNC_DOOR) && ((g_entities[i].flags & FL_LOCKED) == 0)) {
if ((g_entities[i].type == EntityType::ENT_FUNC_DOOR) && ((g_entities[i].flags & FL_LOCKED) == 0)) {
g_entities[i].flags ^= FL_LOCKED;
}
else if ((g_entities[i].type == ENT_FUNC_DOOR_ROTATING) && !(g_entities[i].flags & FL_LOCKED)) {
else if ((g_entities[i].type == EntityType::ENT_FUNC_DOOR_ROTATING) && !(g_entities[i].flags & FL_LOCKED)) {
g_entities[i].flags ^= FL_LOCKED;
}
}
@ -6303,7 +6303,7 @@ static void Cmd_reloadtorpedos_f(gentity_t* ent) {
continue;
}
if (torpedo->type != ENT_FX_TORPEDO) {
if (torpedo->type != EntityType::ENT_FX_TORPEDO) {
continue;
}
@ -6461,7 +6461,7 @@ static void Cmd_listSPs(gentity_t* ent) {
G_Printf("Spawnpoint list: \n");
for (i = 0; i < MAX_GENTITIES; i++) {
if (g_entities[i].type == ENT_INFO_PLAYER_START) {
if (g_entities[i].type == EntityType::ENT_INFO_PLAYER_START) {
G_Printf("Spawnpoint type: info_player_start Origin: %s\n", vtos(ent->s.origin));
}
else if (Q_stricmp(g_entities[i].classname, "info_player_deathmatch") == 0) {
@ -7465,7 +7465,7 @@ static void Cmd_UiTransporterLoc_f(gentity_t* ent) {
delay *= 1000;
for (i = 0; i < MAX_GENTITIES; i++) {
if (g_entities[i].type == ENT_TARGET_LOCATION) {
if (g_entities[i].type == EntityType::ENT_TARGET_LOCATION) {
if (g_entities[i].health == targetLoc && g_entities[i].health >= 1 && targetLoc >= 1) {
locTarget = &g_entities[i];
break;
@ -7880,7 +7880,7 @@ void Cmd_GeneratePrecacheFile(gentity_t* ent) {
for (i = 0; i < MAX_GENTITIES; i++) {
if (!g_entities[i].inuse) continue;
if (g_entities[i].type == ENT_TARGET_TURBOLIFT) {
if (g_entities[i].type == EntityType::ENT_TARGET_TURBOLIFT) {
if (g_entities[i].falsename != NULL && g_entities[i].falsename[0] != 0) {
addShaderToList(shaders, g_entities[i].falsename);
}

View file

@ -298,14 +298,14 @@ void G_Combat_Damage(gentity_t* targ, gentity_t* inflictor, gentity_t* attacker,
}
// shootable doors / buttons don't actually have any health
if (((targ->s.eType == ET_MOVER) && (targ->type != ENT_FUNC_BREAKABLE) && (targ->type != ENT_MISC_MODEL_BREAKABLE)) ||
((targ->s.eType == ET_MOVER_STR) && (targ->type != ENT_FUNC_BREAKABLE) && (targ->type != ENT_MISC_MODEL_BREAKABLE))) //RPG-X | GSIO01 | 13/05/2009
if (((targ->s.eType == ET_MOVER) && (targ->type != EntityType::ENT_FUNC_BREAKABLE) && (targ->type != EntityType::ENT_MISC_MODEL_BREAKABLE)) ||
((targ->s.eType == ET_MOVER_STR) && (targ->type != EntityType::ENT_FUNC_BREAKABLE) && (targ->type != EntityType::ENT_MISC_MODEL_BREAKABLE))) //RPG-X | GSIO01 | 13/05/2009
{
if (targ->type == ENT_FUNC_FORCEFIELD) {
if (targ->type == EntityType::ENT_FUNC_FORCEFIELD) {
if (targ->pain != NULL) {
targ->pain(targ, inflictor, take);
}
} else if ((targ->use != NULL) && ((targ->moverState == MOVER_POS1) || (targ->moverState == ROTATOR_POS1)) && (targ->type != ENT_FUNC_DOOR) && (targ->type != ENT_FUNC_DOOR_ROTATING)) {
} else if ((targ->use != NULL) && ((targ->moverState == MOVER_POS1) || (targ->moverState == ROTATOR_POS1)) && (targ->type != EntityType::ENT_FUNC_DOOR) && (targ->type != EntityType::ENT_FUNC_DOOR_ROTATING)) {
targ->use(targ, inflictor, attacker);
}
return;
@ -472,7 +472,7 @@ void G_Combat_Damage(gentity_t* targ, gentity_t* inflictor, gentity_t* attacker,
targ->health = targ->health - take;
//RPG-X: RedTechie - If medicrevive is on then health only goes down to 1 so we can simulate fake death
if ((rpg_medicsrevive.integer == 1) && (targ->type != ENT_FUNC_BREAKABLE) && (targ->type != ENT_MISC_MODEL_BREAKABLE)) {
if ((rpg_medicsrevive.integer == 1) && (targ->type != EntityType::ENT_FUNC_BREAKABLE) && (targ->type != EntityType::ENT_MISC_MODEL_BREAKABLE)) {
if (targ->health <= 0) {
targ->health = 1;
}
@ -720,7 +720,7 @@ void G_Combat_Repair(gentity_t* ent, gentity_t* tr_ent, double rate) {
if (tr_ent->target) {
G_UseTargets2(tr_ent, tr_ent, tr_ent->target);
}
if (tr_ent->type == ENT_FUNC_BREAKABLE) {
if (tr_ent->type == EntityType::ENT_FUNC_BREAKABLE) {
tr_ent->s.solid = CONTENTS_BODY;
trap_SetBrushModel(tr_ent, tr_ent->model);
tr_ent->r.svFlags &= ~SVF_NOCLIENT;
@ -739,7 +739,7 @@ void G_Combat_Repair(gentity_t* ent, gentity_t* tr_ent, double rate) {
tr_ent->clipmask = 0;
tr_ent->count = 1;
} else if (tr_ent->type == ENT_MISC_MODEL_BREAKABLE) {
} else if (tr_ent->type == EntityType::ENT_MISC_MODEL_BREAKABLE) {
SP_misc_model_breakable(tr_ent);
}
}

View file

@ -100,7 +100,7 @@ static void spark_link(gentity_t *ent)
//------------------------------------------
void SP_fx_spark(gentity_t *ent)
{
ent->type = ENT_FX_SPARK;
ent->type = EntityType::ENT_FX_SPARK;
if (ent->wait <= 0)
{
@ -270,7 +270,7 @@ static void steam_link(gentity_t *ent)
//------------------------------------------
void SP_fx_steam(gentity_t *ent)
{
ent->type = ENT_FX_STEAM;
ent->type = EntityType::ENT_FX_STEAM;
SnapVector(ent->s.origin);
VectorCopy(ent->s.origin, ent->s.pos.trBase);
@ -416,7 +416,7 @@ static void bolt_link(gentity_t *ent)
//------------------------------------------
void SP_fx_bolt(gentity_t *ent)
{
ent->type = ENT_FX_BOLT;
ent->type = EntityType::ENT_FX_BOLT;
G_SpawnInt("damage", "0", &ent->damage);
G_SpawnFloat("random", "0.5", &ent->random);
@ -463,7 +463,7 @@ static void transporter_link(gentity_t *ent)
//------------------------------------------
void SP_fx_transporter(gentity_t *ent)
{
ent->type = ENT_FX_TRANSPORTER;
ent->type = EntityType::ENT_FX_TRANSPORTER;
SnapVector(ent->s.origin);
VectorCopy(ent->s.origin, ent->s.pos.trBase);
@ -503,7 +503,7 @@ static void drip_think(gentity_t *ent)
//------------------------------------------
void SP_fx_drip(gentity_t *ent)
{
ent->type = ENT_FX_DRIP;
ent->type = EntityType::ENT_FX_DRIP;
ent->s.time2 = ent->damage;
ent->s.angles2[0] = ent->random;
@ -565,7 +565,7 @@ static void fountain_use(gentity_t *self, /*@unused@*/ gentity_t *other, /*@unus
void SP_fx_fountain(gentity_t *ent) {
gentity_t *target = NULL;
ent->type = ENT_FX_FOUNTAIN;
ent->type = EntityType::ENT_FX_FOUNTAIN;
if (ent->target != NULL && ent->target[0] != 0) {
target = G_Find(target, FOFS(targetname), ent->target);
@ -670,7 +670,7 @@ static void surface_explosion_link(gentity_t *ent)
//------------------------------------------
void SP_fx_surface_explosion(gentity_t *ent)
{
ent->type = ENT_FX_SURFACE_EXPLOSION;
ent->type = EntityType::ENT_FX_SURFACE_EXPLOSION;
if ((ent->spawnflags & 4) == 0){
G_SpawnInt("damage", "50", &ent->splashDamage);
@ -757,7 +757,7 @@ static void blow_chunks_link(gentity_t *ent)
//------------------------------------------
void SP_fx_blow_chunks(gentity_t *ent)
{
ent->type = ENT_FX_BLOW_CHUNKS;
ent->type = EntityType::ENT_FX_BLOW_CHUNKS;
G_SpawnFloat("radius", "65", &ent->distance);
G_SpawnInt("material", "1", &ent->s.powerups);
@ -874,7 +874,7 @@ static void smoke_link(gentity_t *ent)
//------------------------------------------
void SP_fx_smoke(gentity_t *ent)
{
ent->type = ENT_FX_SMOKE;
ent->type = EntityType::ENT_FX_SMOKE;
G_SpawnFloat("radius", "16.0", &ent->distance); // was: ent->radius
@ -945,7 +945,7 @@ static void electrical_explosion_link(gentity_t *ent)
//------------------------------------------
void SP_fx_electrical_explosion(gentity_t *ent)
{
ent->type = ENT_FX_ELETRICAL_EXPLOSION;
ent->type = EntityType::ENT_FX_ELETRICAL_EXPLOSION;
if ((ent->spawnflags & 4) == 0)
{
@ -1066,7 +1066,7 @@ void SP_fx_phaser(gentity_t *ent) {
G_LocLogger(LL_TRACE, "%s - begin\n", __FUNCTION__);
ent->type = ENT_FX_PHASER;
ent->type = EntityType::ENT_FX_PHASER;
ent->count = PHASER_FX_UNLINKED;
if (ent->target == NULL || ent->target[0] == 0) {
@ -1247,7 +1247,7 @@ void SP_fx_torpedo(gentity_t *ent) {
G_LocLogger(LL_TRACE, "%s - begin\n", __FUNCTION__);
ent->type = ENT_FX_TORPEDO;
ent->type = EntityType::ENT_FX_TORPEDO;
if (ent->target == NULL || ent->target[0] == 0) {
G_Logger(LL_ERROR, "[Entity-Error] fx_torpedo at %s without target\n", vtos(ent->s.origin));
@ -1324,7 +1324,7 @@ static void particleFire_use(gentity_t *self, /*@unused@*/ gentity_t *other, /*@
void SP_fx_particleFire(gentity_t *ent) {
int size;
ent->type = ENT_FX_PARTICLEFIRE;
ent->type = EntityType::ENT_FX_PARTICLEFIRE;
G_SpawnInt("size", "10", &size);
if (size == 0) {
@ -1411,7 +1411,7 @@ static void fire_use(gentity_t *self, /*@unused@*/ gentity_t *other, /*@unused@*
void SP_fx_fire(gentity_t *ent) {
int size;
ent->type = ENT_FX_FIRE;
ent->type = EntityType::ENT_FX_FIRE;
G_SpawnInt("size", "64", &size);
if (size == 0) {
@ -1496,7 +1496,7 @@ static void cooking_steam_use(gentity_t *self, /*@unused@*/ gentity_t *other, /*
//------------------------------------------
void SP_fx_cooking_steam(gentity_t *ent)
{
ent->type = ENT_FX_COOKING_STEAM;
ent->type = EntityType::ENT_FX_COOKING_STEAM;
if (ent->distance <= 0.0f) {
ent->distance = 3.0f;
@ -1570,7 +1570,7 @@ static void electric_fire_use(gentity_t *self, /*@unused@*/ gentity_t *other, /*
//------------------------------------------
void SP_fx_electricfire(gentity_t *ent)
{
ent->type = ENT_FX_ELECTRICFIRE;
ent->type = EntityType::ENT_FX_ELECTRICFIRE;
if (ent->targetname != NULL && ent->targetname[0] != 0) {
ent->use = electric_fire_use;
@ -1738,7 +1738,7 @@ static void forge_bolt_link(gentity_t *ent)
//------------------------------------------
void SP_fx_forge_bolt(gentity_t *ent)
{
ent->type = ENT_FX_FORGE_BOLT;
ent->type = EntityType::ENT_FX_FORGE_BOLT;
G_SpawnInt("damage", "0", &ent->damage);
G_SpawnFloat("random", "0.4", &ent->random);
@ -1875,7 +1875,7 @@ void SP_fx_plasma(gentity_t *ent)
{
int t;
ent->type = ENT_FX_PLASMA;
ent->type = EntityType::ENT_FX_PLASMA;
G_SpawnVector4("startRGBA", "100 180 255 255", ent->startRGBA);
G_SpawnVector4("finalRGBA", "0 0 180 0", ent->finalRGBA);
@ -2005,7 +2005,7 @@ static void stream_link(gentity_t *ent)
//------------------------------------------
void SP_fx_stream(gentity_t *ent)
{
ent->type = ENT_FX_STREAM;
ent->type = EntityType::ENT_FX_STREAM;
G_SpawnInt("damage", "0", &ent->damage);
@ -2112,7 +2112,7 @@ static void transporter_stream_link(gentity_t *ent)
//------------------------------------------
void SP_fx_transporter_stream(gentity_t *ent)
{
ent->type = ENT_FX_TRANSPORTER_STREAM;
ent->type = EntityType::ENT_FX_TRANSPORTER_STREAM;
VectorCopy(ent->s.origin, ent->s.pos.trBase);
@ -2174,7 +2174,7 @@ static void explosion_trail_link(gentity_t *ent)
//------------------------------------------
void SP_fx_explosion_trail(gentity_t *ent)
{
ent->type = ENT_FX_EXPLOSION_TRAIL;
ent->type = EntityType::ENT_FX_EXPLOSION_TRAIL;
G_SpawnInt("damage", "150", &ent->splashDamage);
G_SpawnFloat("radius", "80", &ent->distance);
@ -2285,7 +2285,7 @@ void SP_fx_borg_energy_beam(gentity_t *ent)
{
int t;
ent->type = ENT_FX_BORG_ENERGY_BEAM;
ent->type = EntityType::ENT_FX_BORG_ENERGY_BEAM;
G_SpawnFloat("radius", "30", &ent->distance);
G_SpawnFloat("speed", "100", &ent->speed);
@ -2402,7 +2402,7 @@ static void shimmery_thing_link(gentity_t *ent)
//------------------------------------------
void SP_fx_shimmery_thing(gentity_t *ent)
{
ent->type = ENT_FX_SHIMMERY_THING;
ent->type = EntityType::ENT_FX_SHIMMERY_THING;
G_SpawnFloat("radius", "10", &ent->s.angles[1]);
if (ent->wait <= 0.0f) {
@ -2530,7 +2530,7 @@ static void borg_bolt_link(gentity_t *ent)
//------------------------------------------
void SP_fx_borg_bolt(gentity_t *ent)
{
ent->type = ENT_FX_BORG_BOLT;
ent->type = EntityType::ENT_FX_BORG_BOLT;
ent->think = borg_bolt_link;
ent->nextthink = level.time + 1000;

View file

@ -184,7 +184,7 @@ typedef enum {
//============================================================================
typedef enum {
enum class EntityType {
ENT_FREE = 0,
ENT_UNKNOWN,
ENT_TEMPORAL,
@ -297,7 +297,7 @@ typedef enum {
ENT_UI_HOLODECK,
ENT_UI_MSD,
ENT_CINEMATIC_CAMMERA = 900
} entityTypeNumber_t;
};
/** \typedef gentity_t
*
@ -314,6 +314,12 @@ typedef struct gentity_s gentity_t;
*/
typedef struct gclient_s gclient_t;
struct GameSharedEntity : sharedEntity_t
{
bool m_inUse;
int32_t m_freeTime;
};
/** \struct gentity_s
*
* The game side representation of entities.
@ -331,7 +337,7 @@ struct gentity_s {
qboolean inuse;
entityTypeNumber_t type; //!< Entity type
EntityType type; //!< Entity type
/*@shared@*/ /*@null@*/ char* classname; //!< set in QuakeEd
int spawnflags; //!< set in QuakeEd
@ -350,7 +356,7 @@ struct gentity_s {
qboolean physicsObject; //!< if true, it can be pushed by movers and fall off edges
//!< all game items are physicsObjects,
float physicsBounce; //!< 1.0 = continuous bounce, 0.0 = no bounce
int clipmask; //!< brushes with this content value will be collided again when moving. items and corpses do not collide against players, for instance
int clipmask; //!< brushes with this content value will be collided with when moving. items and corpses do not collide against players, for instance
// movers
moverState_t moverState; //!< current state of the mover

View file

@ -1512,7 +1512,7 @@ static void G_FindTeams(void)
continue;
if((e->flags & FL_TEAMSLAVE) != 0)
continue;
if((e->classname != NULL) && (e->type != ENT_FUNC_DOOR))
if((e->classname != NULL) && (e->type != EntityType::ENT_FUNC_DOOR))
{//not a door
if(Q_stricmp("1", e->team) == 0 || Q_stricmp("2", e->team) == 0)
{//is trying to tell us it belongs to the TEAM_RED or TEAM_BLUE
@ -1638,9 +1638,9 @@ static void Dev_ShowTriggers(gentity_t *ent)
for(i = 0; i < MAX_GENTITIES; i++)
{
if((tar = &g_entities[i]) == NULL) continue;
if(tar->type >= ENT_TRIGGER_ALWAYS && tar->type < ENT_TARGET_REMOVE_POWERUPS)
if(tar->type >= EntityType::ENT_TRIGGER_ALWAYS && tar->type < EntityType::ENT_TARGET_REMOVE_POWERUPS)
{
if(tar->type == ENT_TRIGGER_ALWAYS)
if(tar->type == EntityType::ENT_TRIGGER_ALWAYS)
{
continue;
}
@ -1651,7 +1651,7 @@ static void Dev_ShowTriggers(gentity_t *ent)
}
trap_LinkEntity(ent);
if(tar->type == ENT_TRIGGER_PUSH)
if(tar->type == EntityType::ENT_TRIGGER_PUSH)
{
G_AddEvent(tar, EV_TRIGGER_SHOW, 1);
}

View file

@ -35,7 +35,7 @@ none
*/
// Lol, this is contradictory, should free but instead sets origin... Description sais removed so maybe merge with info_null.
void SP_info_camp( gentity_t *self ) {
self->type = ENT_INFO_CAMP;
self->type = EntityType::ENT_INFO_CAMP;
G_SetOrigin( self, self->s.origin );
}
@ -96,7 +96,7 @@ void SP_info_notnull( gentity_t *self ){
G_FreeEntity(self);
}
self->type = ENT_INFO_NOTNULL;
self->type = EntityType::ENT_INFO_NOTNULL;
if(strcmp(self->classname, "info_notnull")) {
self->classname = "info_notnull";
@ -503,7 +503,7 @@ Autocycle or manual Cycle usually only makes sence for a survaliance-station or
For a viewscreen or a communications channel make the brush having the portal-texture a func_usable and treat is as described on that entity for VFX-Entities.
*/
void SP_misc_portal_surface(gentity_t *ent) {
ent->type = ENT_MISC_PORTAL_SURFACE;
ent->type = EntityType::ENT_MISC_PORTAL_SURFACE;
VectorClear( ent->r.mins );
VectorClear( ent->r.maxs );
@ -545,7 +545,7 @@ You can set either angles or target another entity (NOT an info_null or similar)
void SP_misc_portal_camera(gentity_t *ent) {
float roll;
ent->type = ENT_MISC_PORTAL_CAMERA;
ent->type = EntityType::ENT_MISC_PORTAL_CAMERA;
VectorClear( ent->r.mins );
VectorClear( ent->r.maxs );
@ -651,7 +651,7 @@ none
"random" - the number of degrees of deviance from the taget. (1.0 default)
*/
void SP_shooter_rocket( gentity_t *ent ) {
ent->type = ENT_SHOOTER_ROCKET;
ent->type = EntityType::ENT_SHOOTER_ROCKET;
InitShooter( ent, WP_10 );
}
@ -667,7 +667,7 @@ none
"random" - the number of degrees of deviance from the taget. (1.0 default)
*/
void SP_shooter_plasma( gentity_t *ent ) {
ent->type = ENT_SHOOTER_PLASMA;
ent->type = EntityType::ENT_SHOOTER_PLASMA;
InitShooter( ent, WP_6 ); //TiM : WP_4
}
@ -683,7 +683,7 @@ none
"random" - the number of degrees of deviance from the taget. (1.0 default)
*/
void SP_shooter_grenade( gentity_t *ent ) {
ent->type = ENT_SHOOTER_GRENADE;
ent->type = EntityType::ENT_SHOOTER_GRENADE;
InitShooter( ent, WP_8);
}
@ -699,6 +699,6 @@ none
"random" - the number of degrees of deviance from the taget. (1.0 default)
*/
void SP_shooter_torpedo( gentity_t *ent ) {
ent->type = ENT_SHOOTER_TORPEDO;
ent->type = EntityType::ENT_SHOOTER_TORPEDO;
InitShooter( ent, WP_9 );
}

View file

@ -518,7 +518,7 @@ ReturnToPos1
void ReturnToPos1(gentity_t *ent)
{
//if it's a crushing door, make sure there are no ents in the way
if ((ent->type == ENT_FUNC_DOOR) && (ent->targetname != NULL) && ((ent->spawnflags & 32) == 0) && (ent->wait > 0)) //OVERRIDE
if ((ent->type == EntityType::ENT_FUNC_DOOR) && (ent->targetname != NULL) && ((ent->spawnflags & 32) == 0) && (ent->wait > 0)) //OVERRIDE
{
gentity_t *t;
trace_t tr;
@ -527,7 +527,7 @@ void ReturnToPos1(gentity_t *ent)
//FIX: make sure it isn't a turbolift door either
//A turbolift door should only be targetted by its turbolift parent
t = G_Find(NULL, FOFS(target), ent->targetname);
if ((t != NULL) && (t->type != ENT_TARGET_TURBOLIFT))
if ((t != NULL) && (t->type != EntityType::ENT_TARGET_TURBOLIFT))
{
VectorCopy(ent->r.mins, mins);
VectorCopy(ent->r.maxs, maxs);
@ -569,7 +569,7 @@ TiM: To make toggle doors
void ReturnToPos1_Use(gentity_t* ent, gentity_t* other, gentity_t* activator)
{
//if it's a crushing door, make sure there are no ents in the way
if ((ent->type == ENT_FUNC_DOOR) && (ent->targetname != NULL) && ((ent->spawnflags & 32) == 0) && (ent->wait > 0)) //OVERRIDE
if ((ent->type == EntityType::ENT_FUNC_DOOR) && (ent->targetname != NULL) && ((ent->spawnflags & 32) == 0) && (ent->wait > 0)) //OVERRIDE
{
gentity_t *t;
trace_t tr;
@ -578,7 +578,7 @@ void ReturnToPos1_Use(gentity_t* ent, gentity_t* other, gentity_t* activator)
//FIX: make sure it isn't a turbolift door either
//A turbolift door should only be targetted by its turbolift parent
t = G_Find(NULL, FOFS(target), ent->targetname);
if ((t != NULL) && (t->type != ENT_TARGET_TURBOLIFT))
if ((t != NULL) && (t->type != EntityType::ENT_TARGET_TURBOLIFT))
{
VectorCopy(ent->r.mins, mins);
VectorCopy(ent->r.maxs, maxs);
@ -792,7 +792,7 @@ void G_Mover_UseBinaryMover(gentity_t *ent, gentity_t *other, gentity_t *activat
//GSIO01 -> is this a train and is called by the swapname
if (activator && activator->target && ent->swapname) {
if ((ent->type == ENT_FUNC_TRAIN) && !Q_stricmp(activator->target, ent->swapname)) {
if ((ent->type == EntityType::ENT_FUNC_TRAIN) && !Q_stricmp(activator->target, ent->swapname)) {
if (ent->count == 1) {
ent->s.solid = 0;
ent->r.contents = 0;
@ -824,8 +824,8 @@ void G_Mover_UseBinaryMover(gentity_t *ent, gentity_t *other, gentity_t *activat
}
//GSIO01 | 09/05/2009: do engage if door is admin only and player isn admin
if (((ent->type == ENT_FUNC_DOOR) && ((ent->spawnflags & 128) != 0))
|| ((ent->type == ENT_FUNC_DOOR_ROTATING) && ((ent->spawnflags & 64) != 0))) {
if (((ent->type == EntityType::ENT_FUNC_DOOR) && ((ent->spawnflags & 128) != 0))
|| ((ent->type == EntityType::ENT_FUNC_DOOR_ROTATING) && ((ent->spawnflags & 64) != 0))) {
if ((activator != NULL) && !G_Client_IsAdmin(activator)) {
return;
}
@ -1026,7 +1026,7 @@ void InitMover(gentity_t *ent) {
ent->use = G_Mover_UseBinaryMover;
if (ent->type != ENT_FUNC_MOVER) {
if (ent->type != EntityType::ENT_FUNC_MOVER) {
ent->reached = Reached_BinaryMover;
}
else {
@ -1034,7 +1034,7 @@ void InitMover(gentity_t *ent) {
}
// if this is a func_mover we have to make sure it is a bit away from it's first target
if (ent->type == ENT_FUNC_MOVER) {
if (ent->type == EntityType::ENT_FUNC_MOVER) {
VectorSubtract(ent->pos1, ent->pos2, move);
distance = VectorLength(move);
if (distance < 32) {
@ -1078,7 +1078,7 @@ void InitMover(gentity_t *ent) {
ent->s.apos.trDuration = 1;
}
if (ent->type == ENT_FUNC_ROTATING) {
if (ent->type == EntityType::ENT_FUNC_ROTATING) {
ent->reached = 0;
}
}
@ -1189,7 +1189,7 @@ void Blocked_Door(gentity_t *ent, gentity_t *other) {
if (ent->damage) {
G_Combat_Damage(other, ent, ent, NULL, NULL, ent->damage, 0, MOD_CRUSH);
}
if (((ent->spawnflags & 4) != 0) || ((ent->type == ENT_FUNC_DOOR_ROTATING) && ((ent->spawnflags & 2) != 0))) { // GSIO01: added support for fucn_door_roating
if (((ent->spawnflags & 4) != 0) || ((ent->type == EntityType::ENT_FUNC_DOOR_ROTATING) && ((ent->spawnflags & 2) != 0))) { // GSIO01: added support for fucn_door_roating
return; // crushers don't reverse
}
@ -1331,12 +1331,12 @@ void Think_SpawnNewDoorTrigger(gentity_t *ent) {
}
// should we have a big old trigger volume, or a small one?
if ((((ent->spawnflags & 256) != 0) && (ent->type == ENT_FUNC_DOOR)) ||
(((ent->spawnflags & 128) != 0) && (ent->type == ENT_FUNC_DOOR_ROTATING))) {
if ((((ent->spawnflags & 256) != 0) && (ent->type == EntityType::ENT_FUNC_DOOR)) ||
(((ent->spawnflags & 128) != 0) && (ent->type == EntityType::ENT_FUNC_DOOR_ROTATING))) {
maxs[best] += 12;
mins[best] -= 12;
}
else if (((ent->spawnflags & 8) != 0) && (ent->type == ENT_FUNC_DOOR))
else if (((ent->spawnflags & 8) != 0) && (ent->type == EntityType::ENT_FUNC_DOOR))
{
maxs[best] += 48;
mins[best] -= 48;
@ -1510,7 +1510,7 @@ void SP_func_door(gentity_t *ent) {
float lip;
char *sound;
ent->type = ENT_FUNC_DOOR;
ent->type = EntityType::ENT_FUNC_DOOR;
if (!ent->tmpEntity) { // not modified by spawnfile
G_SpawnString("soundstart", "sound/movers/doors/largedoorstart.wav", &sound);
@ -1727,7 +1727,7 @@ void SP_func_plat(gentity_t *ent) {
float lip, height;
char *sound;
ent->type = ENT_FUNC_PLAT;
ent->type = EntityType::ENT_FUNC_PLAT;
G_SpawnString("soundstart", "sound/movers/plats/largeplatstart.wav", &sound);
ent->sound1to2 = ent->sound2to1 = G_SoundIndex(sound);
@ -1842,7 +1842,7 @@ void SP_func_button(gentity_t *ent) {
float lip;
char *sound;
ent->type = ENT_FUNC_BUTTON;
ent->type = EntityType::ENT_FUNC_BUTTON;
if (!ent->tmpEntity) { // not modified by spawn file
G_SpawnString("sounduse", "sound/movers/switches/forgepos.wav", &sound);
@ -2030,7 +2030,7 @@ void Think_SetupTrainTargets(gentity_t *ent) {
vtos(path->s.origin)););
return;
}
} while (next->type != ENT_PATH_CORNER);
} while (next->type != EntityType::ENT_PATH_CORNER);
path->nextTrain = next;
}
@ -2054,7 +2054,7 @@ none
"wait" - seconds to wait before beginning move to next corner
*/
void SP_path_corner(gentity_t *self) {
self->type = ENT_PATH_CORNER;
self->type = EntityType::ENT_PATH_CORNER;
if (!self->targetname) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] path_corner with no targetname at %s\n", vtos(self->s.origin)););
@ -2096,7 +2096,7 @@ q3map2:
"_receiveShadows" OR "_rs" - sets whether the entity receives shadows
*/
void SP_func_train(gentity_t *self) {
self->type = ENT_FUNC_TRAIN;
self->type = EntityType::ENT_FUNC_TRAIN;
VectorClear(self->s.angles);
@ -2173,7 +2173,7 @@ q3map2:
"_receiveShadows" OR "_rs" - sets whether the entity receives shadows
*/
void SP_func_static(gentity_t *ent) {
ent->type = ENT_FUNC_STATIC;
ent->type = EntityType::ENT_FUNC_STATIC;
trap_SetBrushModel(ent, ent->model);
G_SetOrigin(ent, ent->s.origin);
@ -2430,7 +2430,7 @@ void SP_func_forcefield(gentity_t *ent)
{
char *activate, *damage, *touch, *deactivate, *temp;
ent->type = ENT_FUNC_FORCEFIELD;
ent->type = EntityType::ENT_FUNC_FORCEFIELD;
// timestamp keeps track of whether the field is on or off
ent->timestamp = 1;
@ -2570,7 +2570,7 @@ void func_rotating_use(gentity_t *ent, gentity_t *other, gentity_t *activator)
void SP_func_rotating(gentity_t *ent) {
float speed;
ent->type = ENT_FUNC_ROTATING;
ent->type = EntityType::ENT_FUNC_ROTATING;
if (!ent->speed) {
ent->speed = 100;
@ -2726,7 +2726,7 @@ q3map2:
void SP_func_door_rotating(gentity_t *ent) {
char *sound;
ent->type = ENT_FUNC_DOOR_ROTATING;
ent->type = EntityType::ENT_FUNC_DOOR_ROTATING;
G_SpawnString("soundstart", "sound/movers/doors/largedoorstart.wav", &sound);
ent->sound1to2 = ent->sound2to1 = G_SoundIndex(sound);
@ -2863,7 +2863,7 @@ void SP_func_bobbing(gentity_t *ent) {
float height;
float phase;
ent->type = ENT_FUNC_BOBBING;
ent->type = EntityType::ENT_FUNC_BOBBING;
if (!ent->tmpEntity) { // only do this if this is not done by spawn file
G_SpawnFloat("height", "32", &height);
@ -2938,7 +2938,7 @@ void SP_func_pendulum(gentity_t *ent) {
float phase;
float speed;
ent->type = ENT_FUNC_PENDULUM;
ent->type = EntityType::ENT_FUNC_PENDULUM;
G_SpawnFloat("speed", "30", &speed);
G_SpawnInt("dmg", "2", &ent->damage);
@ -2998,7 +2998,7 @@ q3map2:
"_receiveShadows" OR "_rs" - sets whether the entity receives shadows
*/
void SP_func_brushmodel(gentity_t *ent) {
ent->type = ENT_FUNC_BRUSHMODEL;
ent->type = EntityType::ENT_FUNC_BRUSHMODEL;
trap_SetBrushModel(ent, ent->model);
ent->s.eType = ET_MOVER;
@ -3044,7 +3044,7 @@ void func_lightchange_setup(gentity_t *ent) {
G_FreeEntity(ent);
return;
}
if (ent->type != ENT_FUNC_BRUSHMODEL) {
if (ent->type != EntityType::ENT_FUNC_BRUSHMODEL) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] func_lightchange with invalid target entity of class %s at %s!\n", bmodel->classname, vtos(ent->s.origin)););
G_FreeEntity(ent);
return;
@ -3062,7 +3062,7 @@ void func_lightchange_setup(gentity_t *ent) {
}
void SP_func_lightchange(gentity_t *ent) {
ent->type = ENT_FUNC_LIGHTCHANGE;
ent->type = EntityType::ENT_FUNC_LIGHTCHANGE;
if (!ent->target) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] func_lightchange without target at %s!\n", vtos(ent->s.origin)););
@ -3156,7 +3156,7 @@ void func_targetmover_link(gentity_t *ent) {
void SP_func_targetmover(gentity_t *ent) {
char *sound;
ent->type = ENT_FUNC_TARGETMOVER;
ent->type = EntityType::ENT_FUNC_TARGETMOVER;
if (!ent->target) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] func_targetmover without target at %s!\n", vtos(ent->s.origin)););
@ -3372,7 +3372,7 @@ Target position for the discontinued func_mover
"angles" - to rotate to
*/
void SP_path_point(gentity_t *ent) {
ent->type = ENT_PATH_POINT;
ent->type = EntityType::ENT_PATH_POINT;
// check if angles are set
if (ent->angle) {
@ -3408,7 +3408,7 @@ void SP_func_mover(gentity_t *ent) {
gentity_t *target;
float aspeed;
ent->type = ENT_FUNC_MOVER;
ent->type = EntityType::ENT_FUNC_MOVER;
if (!ent->target) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] func_mover without target at %s!\n", vtos(ent->s.origin)););
@ -3641,7 +3641,7 @@ A bmodel that just sits there and opens when a player gets close to it.
*/
void SP_func_stasis_door(gentity_t *ent)
{
ent->type = ENT_FUNC_STASIS_DOOR;
ent->type = EntityType::ENT_FUNC_STASIS_DOOR;
/* set the brush model */
trap_SetBrushModel(ent, ent->model);

View file

@ -164,6 +164,11 @@ void trap_UnlinkEntity( gentity_t *ent ) {
syscall( G_UNLINKENTITY, ent );
}
void trap_UnlinkEntity(sharedEntity_t* ent)
{
syscall(G_UNLINKENTITY, ent);
}
int trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int32_t* list, int maxcount ) {
return syscall( G_ENTITIES_IN_BOX, mins, maxs, list, maxcount );

View file

@ -254,6 +254,7 @@ void trap_LinkEntity(gentity_t* ent);
* Unlinks an entity.
*/
void trap_UnlinkEntity(gentity_t* ent);
void trap_UnlinkEntity(sharedEntity_t* ent);
/**
* \brief Get a list of all entities in a box.

View file

@ -54,7 +54,7 @@ void SP_target_give( gentity_t *ent )
char* token;
unsigned weapon;
ent->type = ENT_TARGET_GIVE;
ent->type = EntityType::ENT_TARGET_GIVE;
G_SpawnString( "items", "", &items );
@ -130,7 +130,7 @@ static void Use_target_remove_powerups( /*@shared@*/ /*@unused@*/ gentity_t *ent
}
void SP_target_remove_powerups( gentity_t *ent ) {
ent->type = ENT_TARGET_REMOVE_POWERUPS;
ent->type = EntityType::ENT_TARGET_REMOVE_POWERUPS;
ent->use = Use_target_remove_powerups;
}
@ -175,7 +175,7 @@ static void Use_Target_Delay( /*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unus
}
void SP_target_delay( gentity_t *ent ) {
ent->type = ENT_TARGET_DELAY;
ent->type = EntityType::ENT_TARGET_DELAY;
if ( ent->wait <= 0.0f ) {
G_SpawnFloat("delay", "0", &ent->wait);
@ -230,7 +230,7 @@ static void Use_Target_Print (/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unuse
}
void SP_target_print( gentity_t *ent ) {
ent->type = ENT_TARGET_PRINT;
ent->type = EntityType::ENT_TARGET_PRINT;
ent->use = Use_Target_Print;
}
@ -283,7 +283,7 @@ void SP_target_speaker( gentity_t *ent ) {
char buffer[MAX_QPATH];
char *s;
ent->type = ENT_TARGET_SPEAKER;
ent->type = EntityType::ENT_TARGET_SPEAKER;
G_SpawnFloat( "wait", "0", &ent->wait );
G_SpawnFloat( "random", "0", &ent->random );
@ -451,7 +451,7 @@ static void target_laser_start (/*@shared@*/ gentity_t *self)
void SP_target_laser (gentity_t *self)
{
self->type = ENT_TARGET_LASER;
self->type = EntityType::ENT_TARGET_LASER;
// let everything else get spawned before we start firing
self->think = target_laser_start;
@ -538,7 +538,7 @@ The activator will be instantly teleported away.
"swapname" - Activate/Deactivate (Using entity needs SELF/NOACTIVATOR)
*/
void SP_target_teleporter( gentity_t *self ) {
self->type = ENT_TARGET_TELEPORTER;
self->type = EntityType::ENT_TARGET_TELEPORTER;
if (self->targetname == NULL) {
if(self->classname != NULL) {
@ -621,7 +621,7 @@ static void target_relay_use (/*@shared@*/ gentity_t *self, /*@shared@*/ /*@unus
}
void SP_target_relay (gentity_t *self) {
self->type = ENT_TARGET_RELAY;
self->type = EntityType::ENT_TARGET_RELAY;
self->use = target_relay_use;
}
@ -645,7 +645,7 @@ static void target_kill_use( /*@shared@*/ /*@unused@*/ gentity_t *self, /*@share
}
void SP_target_kill( gentity_t *self ) {
self->type = ENT_TARGET_KILL;
self->type = EntityType::ENT_TARGET_KILL;
self->use = target_kill_use;
@ -673,7 +673,7 @@ static void target_location_linkup(/*@shared@*/ gentity_t *ent)
for (i = 0, ent = g_entities, n = 1;
i < level.num_entities;
i++, ent++) {
if ((ent->classname != NULL) && (ent->type == ENT_TARGET_LOCATION)) {
if ((ent->classname != NULL) && (ent->type == EntityType::ENT_TARGET_LOCATION)) {
// lets overload some variables!
ent->health = n; // use for location marking
trap_SetConfigstring( CS_LOCATIONS + n, ent->message );
@ -721,7 +721,7 @@ For Type = 1: /locedit add <protected> "<location-name>"
this will close the file.
*/
void SP_target_location( gentity_t *self ){
self->type = ENT_TARGET_LOCATION;
self->type = EntityType::ENT_TARGET_LOCATION;
self->think = target_location_linkup;
self->nextthink = level.time + 200; // Let them all spawn first
@ -766,7 +766,7 @@ static void target_counter_use( /*@shared@*/ gentity_t *self, /*@shared@*/ /*@un
void SP_target_counter (gentity_t *self)
{
self->type = ENT_TARGET_COUNTER;
self->type = EntityType::ENT_TARGET_COUNTER;
self->wait = -1.0f;
if (self->count == 0) {
@ -812,7 +812,7 @@ static void target_objective_use( /*@shared@*/ gentity_t *self, /*@shared@*/ /*@
void SP_target_objective (gentity_t *self)
{
self->type = ENT_TARGET_OBJECTIVE;
self->type = EntityType::ENT_TARGET_OBJECTIVE;
if ( self->count <= 0 ) {
//FIXME: error msg
@ -915,7 +915,7 @@ static void target_boolean_use (/*@shared@*/ gentity_t *self, /*@shared@*/ genti
}
void SP_target_boolean (gentity_t *self) {
self->type = ENT_TARGET_BOOLEAN;
self->type = EntityType::ENT_TARGET_BOOLEAN;
if (!self->booleanstate && (self->spawnflags & 1) != 0) {
self->booleanstate = qtrue;
@ -974,7 +974,7 @@ void target_gravity_use (/*@shared@*/ gentity_t *self, /*@shared@*/ /*@unused@*/
void SP_target_gravity (gentity_t *self) {
char *temp;
self->type = ENT_TARGET_GRAVITY;
self->type = EntityType::ENT_TARGET_GRAVITY;
if(!self->tmpEntity) { // check for spawnTEnt
G_SpawnString("gravity", "800", &temp);
@ -1012,7 +1012,7 @@ void target_shake_use (/*@shared@*/ gentity_t *self, /*@shared@*/ /*@unused@*/ g
}
void SP_target_shake (gentity_t *self) {
self->type = ENT_TARGET_SHAKE;
self->type = EntityType::ENT_TARGET_SHAKE;
//TiM: Phenix, you're a n00b. You should always put default values in. ;P
G_SpawnFloat( "intensity", "5", &self->distance /*was &self->intensity*/ );
@ -1053,7 +1053,7 @@ void target_evosuit_use (/*@shared@*/ /*@unused@*/ gentity_t *self, /*@shared@*/
}
void SP_target_evosuit (gentity_t *self) {
self->type = ENT_TARGET_EVOSUIT;
self->type = EntityType::ENT_TARGET_EVOSUIT;
self->use = target_evosuit_use;
@ -1083,7 +1083,7 @@ static void target_turbolift_unlock ( /*@shared@*/ gentity_t *ent )
if(ent->target != NULL) {
while ( ( door = G_Find( door, FOFS( targetname ), ent->target )) != NULL )
{
if ( door->type == ENT_FUNC_DOOR )
if ( door->type == EntityType::ENT_FUNC_DOOR )
{
door->flags &= ~FL_CLAMPED;
}
@ -1095,7 +1095,7 @@ static void target_turbolift_unlock ( /*@shared@*/ gentity_t *ent )
{
while ( ( door = G_Find( door, FOFS( targetname ), otherLift->target )) != NULL )
{
if ( door->type == ENT_FUNC_DOOR )
if ( door->type == EntityType::ENT_FUNC_DOOR )
{
door->flags &= ~FL_CLAMPED;
}
@ -1146,7 +1146,7 @@ static void target_turbolift_endMove ( /*@shared@*/ gentity_t *ent )
if(ent->target != NULL) {
while ( ( lights = G_Find( lights, FOFS( targetname ), ent->target ) ) != NULL )
{
if ( lights->type == ENT_FUNC_USABLE )
if ( lights->type == EntityType::ENT_FUNC_USABLE )
{
if(rpg_calcLiftTravelDuration.integer == 0) {
lights->use( lights, lights, ent );
@ -1192,7 +1192,7 @@ static void target_turbolift_endMove ( /*@shared@*/ gentity_t *ent )
if(otherLift != NULL && otherLift->target != NULL) {
while ( ( lights = G_Find( lights, FOFS( targetname ), otherLift->target ) ) != NULL )
{
if ( lights->type == ENT_FUNC_USABLE )
if ( lights->type == EntityType::ENT_FUNC_USABLE )
{
if(rpg_calcLiftTravelDuration.integer == 0) {
lights->use( lights, lights, ent );
@ -1440,7 +1440,7 @@ static void target_turbolift_startMove (/*@shared@*/ gentity_t *ent )
if(ent->target != NULL) {
while ( ( lights = G_Find( lights, FOFS( targetname ), ent->target ) ) != NULL )
{
if ( lights->type == ENT_FUNC_USABLE )
if ( lights->type == EntityType::ENT_FUNC_USABLE )
{
if(rpg_calcLiftTravelDuration.integer == 0) {
lights->use( lights, lights, ent );
@ -1486,7 +1486,7 @@ static void target_turbolift_startMove (/*@shared@*/ gentity_t *ent )
if(otherLift->target != NULL) {
while ( ( lights = G_Find( lights, FOFS( targetname ), otherLift->target ) ) != NULL )
{
if ( lights->type == ENT_FUNC_USABLE )
if ( lights->type == EntityType::ENT_FUNC_USABLE )
{
if(rpg_calcLiftTravelDuration.integer == 0) {
lights->use( lights, lights, ent );
@ -1577,7 +1577,7 @@ static void target_turbolift_shutDoors (/*@shared@*/ gentity_t *ent )
if(ent->target != NULL) {
while ( ( door = G_Find( door, FOFS( targetname ), ent->target )) != NULL )
{
if ( door->type == ENT_FUNC_DOOR )
if ( door->type == EntityType::ENT_FUNC_DOOR )
{
if ( door->moverState != MOVER_POS1 ) {
ent->nextthink = level.time + 500;
@ -1591,7 +1591,7 @@ static void target_turbolift_shutDoors (/*@shared@*/ gentity_t *ent )
if(otherLift->target != NULL) {
while ( ( door = G_Find( door, FOFS( targetname ), otherLift->target )) != NULL )
{
if ( door->type == ENT_FUNC_DOOR )
if ( door->type == EntityType::ENT_FUNC_DOOR )
{
if ( door->moverState != MOVER_POS1 ) {
ent->nextthink = level.time + 500;
@ -1627,7 +1627,7 @@ void target_turbolift_start ( gentity_t *self )
if(self->target != NULL) {
while ( ( door = G_Find( door, FOFS( targetname ), self->target )) != NULL )
{
if ( door->type == ENT_FUNC_DOOR )
if ( door->type == EntityType::ENT_FUNC_DOOR )
{
door->flags |= FL_CLAMPED;
if ( door->moverState != MOVER_POS1 )
@ -1642,7 +1642,7 @@ void target_turbolift_start ( gentity_t *self )
if(otherLift->target != NULL) {
while ( ( door = G_Find( door, FOFS( targetname ), otherLift->target )) != NULL )
{
if ( door->type == ENT_FUNC_DOOR )
if ( door->type == EntityType::ENT_FUNC_DOOR )
{
door->flags |= FL_CLAMPED;
if ( door->moverState != MOVER_POS1 )
@ -1783,7 +1783,7 @@ void SP_target_turbolift ( gentity_t *self )
return;
}
self->type = ENT_TARGET_TURBOLIFT;
self->type = EntityType::ENT_TARGET_TURBOLIFT;
//cache the moving sounds
G_SpawnString( "soundLoop", "sound/movers/plats/turbomove.wav", &loopSound );
@ -1956,7 +1956,7 @@ void target_doorLock_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused@*/
}
}
if((target->type == ENT_FUNC_DOOR) || (target->type == ENT_FUNC_DOOR_ROTATING)) {
if((target->type == EntityType::ENT_FUNC_DOOR) || (target->type == EntityType::ENT_FUNC_DOOR_ROTATING)) {
target->flags ^= FL_LOCKED;
} else {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] Target %s of target_doorlock at %s is not a door!\n", ent->target, vtos(ent->s.origin)););
@ -1967,7 +1967,7 @@ void target_doorLock_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused@*/
void SP_target_doorLock(gentity_t *ent) {
char *temp;
ent->type = ENT_TARGET_DOORLOCK;
ent->type = EntityType::ENT_TARGET_DOORLOCK;
if(ent->target == NULL) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_doorlock at %s without target!\n", vtos(ent->s.origin)););
@ -2448,7 +2448,7 @@ void target_alert_parseShaders(/*@shared@*/ gentity_t *ent) {
void SP_target_alert(gentity_t *ent) {
char *temp;
ent->type = ENT_TARGET_ALERT;
ent->type = EntityType::ENT_TARGET_ALERT;
G_SpawnString("greenname", "", &temp);
ent->swapname = G_NewString(temp);
@ -2561,7 +2561,7 @@ void target_warp_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused@*/ gent
continue;
}
if((g_entities[i].type != ENT_FUNC_TRAIN) && Q_stricmp(g_entities[i].swapname, ent->bluename) == 0) {
if((g_entities[i].type != EntityType::ENT_FUNC_TRAIN) && Q_stricmp(g_entities[i].swapname, ent->bluename) == 0) {
target = &g_entities[i];
if(target == NULL) {
continue;
@ -2582,7 +2582,7 @@ void target_warp_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused@*/ gent
}
#endif
}
} else if((g_entities[i].type == ENT_FUNC_TRAIN) && Q_stricmp(g_entities[i].swapname, ent->bluename) == 0) {
} else if((g_entities[i].type == EntityType::ENT_FUNC_TRAIN) && Q_stricmp(g_entities[i].swapname, ent->bluename) == 0) {
target = &g_entities[i];
if(target == NULL) {
continue;
@ -2676,7 +2676,7 @@ void target_warp_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused@*/ gent
void SP_target_warp(gentity_t *ent) {
char *temp;
ent->type = ENT_TARGET_WARP;
ent->type = EntityType::ENT_TARGET_WARP;
G_SpawnString("swapWarp", "", &temp);
ent->swapname = G_NewString(temp);
@ -2728,14 +2728,14 @@ void target_deactivate_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused@*
}
while((target = G_Find(target, FOFS(targetname2), ent->target)) != NULL) {
if(target->type == ENT_FUNC_USABLE) {
if(target->type == EntityType::ENT_FUNC_USABLE) {
target->flags ^= FL_LOCKED;
}
}
}
void SP_target_deactivate(/*@shared@*/ gentity_t *ent) {
ent->type = ENT_TARGET_DEACTIVATE;
ent->type = EntityType::ENT_TARGET_DEACTIVATE;
if(ent->target == NULL) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_deactivate at %s without target!\n", vtos(ent->r.currentOrigin)););
@ -2799,7 +2799,7 @@ void target_serverchange_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused
void SP_target_serverchange(/*@shared@*/ gentity_t *ent) {
int serverNum = 0;
ent->type = ENT_TARGET_SERVERCHANGE;
ent->type = EntityType::ENT_TARGET_SERVERCHANGE;
G_SpawnInt("serverNum", "1", &serverNum);
ent->count = serverNum;
@ -2855,7 +2855,7 @@ void target_levelchange_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused@
}
void SP_target_levelchange(gentity_t *ent) {
ent->type = ENT_TARGET_LEVELCHANGE;
ent->type = EntityType::ENT_TARGET_LEVELCHANGE;
if(ent->target == NULL) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_levelchange without target at %s!\n", vtos(ent->s.origin)););
@ -2944,7 +2944,7 @@ void target_shaderremap_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused@
void SP_target_shaderremap(gentity_t *ent) {
ent->type = ENT_TARGET_SHADERREMAP;
ent->type = EntityType::ENT_TARGET_SHADERREMAP;
if(ent->falsename == NULL) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_shaderremap without falsename-shader at %s!\n", vtos(ent->s.origin)););
@ -3064,7 +3064,7 @@ void SP_target_selfdestruct(gentity_t *ent) {
double ETAmin, ETAsec;
float temp;
ent->type = ENT_TARGET_SELFDESTRUCT;
ent->type = EntityType::ENT_TARGET_SELFDESTRUCT;
if(level.time < 1000.0f){ //failsafe in case someone spawned this in the radiant
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_selfdestruct spawned by level. Removing entity."););
@ -3193,7 +3193,7 @@ void target_safezone_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused@*/
void SP_target_zone(gentity_t *ent) {
ent->type = ENT_TARGET_ZONE;
ent->type = EntityType::ENT_TARGET_ZONE;
if(ent->targetname == NULL || ent->targetname[0] == 0) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_zone without targetname at %s, removing entity.\n", vtos(ent->s.origin)););
@ -3571,14 +3571,14 @@ void target_shiphealth_think(/*@shared@*/ gentity_t *ent) {
//shield reenstatement
if(ent->splashDamage == -1) { //else we don't need to run this
if((ent->count * pow(ent->health, -1)) > 0.5) {
if(alertEnt != NULL && alertEnt->damage == 0 && (alertEnt->type == ENT_TARGET_ALERT)) {
if(alertEnt != NULL && alertEnt->damage == 0 && (alertEnt->type == EntityType::ENT_TARGET_ALERT)) {
ent->splashDamage = 0;
} else {
ent->splashDamage = 1;
}
} else {
if((ent->count * pow(ent->health, -1) * flrandom(0, 1)) > 0.75){
if(alertEnt != NULL && alertEnt->damage == 0 && (alertEnt->type == ENT_TARGET_ALERT)) {
if(alertEnt != NULL && alertEnt->damage == 0 && (alertEnt->type == EntityType::ENT_TARGET_ALERT)) {
ent->splashDamage = 0;
} else {
ent->splashDamage = 1;
@ -3620,7 +3620,7 @@ void target_shiphealth_think(/*@shared@*/ gentity_t *ent) {
void SP_target_shiphealth(gentity_t *ent) {
ent->type = ENT_TARGET_SHIPHEALTH;
ent->type = EntityType::ENT_TARGET_SHIPHEALTH;
if(ent->targetname == NULL || ent->health == 0 || ent->splashRadius == 0 || !ent->angle || !ent->speed){
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_shiphealth at %s is missing one or more parameters, removing entity.\n", vtos(ent->s.origin)););
@ -3941,7 +3941,7 @@ void target_sequence_use(/*@shared@*/ gentity_t *ent, /*@shared@*/ /*@unused@*/
}
void SP_target_sequence(gentity_t *ent) {
ent->type = ENT_TARGET_SEQUENCE;
ent->type = EntityType::ENT_TARGET_SEQUENCE;
if(ent->targetname == NULL){
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_sequence at %s without targetname, removing entity.\n", vtos(ent->s.origin)););

View file

@ -176,7 +176,7 @@ so, the basic time between firing is a random time between
void SP_trigger_multiple(gentity_t *ent) {
G_LogFuncBegin();
ent->type = ENT_TRIGGER_MULTIPLE;
ent->type = EntityType::ENT_TRIGGER_MULTIPLE;
G_SpawnFloat("wait", "0.5", &ent->wait);
G_SpawnFloat("random", "0", &ent->random);
@ -251,7 +251,7 @@ none
void SP_trigger_always(gentity_t* ent) {
G_LogFuncBegin();
ent->type = ENT_TRIGGER_ALWAYS;
ent->type = EntityType::ENT_TRIGGER_ALWAYS;
/* we must have some delay to make sure our use targets are present */
ent->nextthink = level.time + 300;
@ -363,7 +363,7 @@ None
void SP_trigger_push(gentity_t* self) {
G_LogFuncBegin();
self->type = ENT_TRIGGER_PUSH;
self->type = EntityType::ENT_TRIGGER_PUSH;
G_Trigger_Init(self);
@ -439,7 +439,7 @@ This is predicted on the serverside and is triggered by use-function.
void SP_target_push(gentity_t* self) {
G_LogFuncBegin();
self->type = ENT_TARGET_PUSH;
self->type = EntityType::ENT_TARGET_PUSH;
if (self->speed <= 0) {
self->speed = 1000;
@ -700,7 +700,7 @@ void SP_trigger_teleport(gentity_t* self)
G_LogFuncBegin();
self->type = ENT_TRIGGER_TELEPORT;
self->type = EntityType::ENT_TRIGGER_TELEPORT;
G_Trigger_Init(self);
@ -871,7 +871,7 @@ static void hurt_touch(gentity_t* self, gentity_t* other, trace_t* trace) {
void SP_trigger_hurt(gentity_t* self) {
G_LogFuncBegin();
self->type = ENT_TRIGGER_HURT;
self->type = EntityType::ENT_TRIGGER_HURT;
G_Trigger_Init(self);
@ -972,7 +972,7 @@ static void func_timer_use(gentity_t* self, gentity_t* other, gentity_t* activat
void SP_func_timer(gentity_t* self) {
G_LogFuncBegin();
self->type = ENT_FUNC_TIMER;
self->type = EntityType::ENT_FUNC_TIMER;
G_SpawnFloat("random", "1", &self->random);
G_SpawnFloat("wait", "1", &self->wait);
@ -1155,7 +1155,7 @@ void SP_trigger_transporter(gentity_t* ent) {
G_LogFuncBegin();
ent->type = ENT_TRIGGER_TRANSPORTER;
ent->type = EntityType::ENT_TRIGGER_TRANSPORTER;
G_Trigger_Init(ent);
@ -1278,7 +1278,7 @@ static void trigger_radiation_use(gentity_t* ent, gentity_t* other, gentity_t* a
void SP_trigger_radiation(gentity_t* ent) {
G_LogFuncBegin();
ent->type = ENT_TRIGGGER_RADIATION;
ent->type = EntityType::ENT_TRIGGGER_RADIATION;
if (ent->damage == 0) {
ent->damage = 1;

View file

@ -822,7 +822,7 @@ void SP_misc_turret(gentity_t* base)
G_LogFuncBegin();
base->type = ENT_MISC_TURRET;
base->type = EntityType::ENT_MISC_TURRET;
if(arm == NULL)
{
@ -1378,7 +1378,7 @@ void SP_laser_arm(gentity_t *base)
{
G_LogFuncBegin();
base->type = ENT_LASER_ARM;
base->type = EntityType::ENT_LASER_ARM;
base->think = laser_arm_start;
base->nextthink = level.time + FRAMETIME;

View file

@ -112,7 +112,7 @@ static void ui_transporter_setup(gentity_t* ent) {
}
void SP_ui_transporter(gentity_t* ent) {
ent->type = ENT_UI_TRANSPORTER;
ent->type = EntityType::ENT_UI_TRANSPORTER;
G_LogFuncBegin();
@ -197,7 +197,7 @@ static void ui_msd_use(gentity_t* ent, gentity_t* other, gentity_t* activator) {
if(target->falsetarget != NULL){
while((temp = G_Find(temp, FOFS(truename), target->falsetarget)) != NULL){
if(temp->type == ENT_TARGET_WARP) {
if(temp->type == EntityType::ENT_TARGET_WARP) {
G_LogFuncEnd();
break;
}
@ -223,7 +223,7 @@ static void ui_msd_use(gentity_t* ent, gentity_t* other, gentity_t* activator) {
if(target->bluename != NULL){
while((temp = G_Find(temp, FOFS(swapname), target->bluename)) != NULL){
if(temp->type == ENT_TARGET_TURBOLIFT) {
if(temp->type == EntityType::ENT_TARGET_TURBOLIFT) {
break;
}
}
@ -239,7 +239,7 @@ static void ui_msd_use(gentity_t* ent, gentity_t* other, gentity_t* activator) {
if(target->bluesound != NULL){
while((temp = G_Find(temp, FOFS(swapname), target->bluesound)) != NULL){
if(temp->type == ENT_UI_TRANSPORTER) {
if(temp->type == EntityType::ENT_UI_TRANSPORTER) {
break;
}
}
@ -255,7 +255,7 @@ static void ui_msd_use(gentity_t* ent, gentity_t* other, gentity_t* activator) {
if(target->falsename != NULL){
while((temp = G_Find(temp, FOFS(falsename), target->falsename)) != NULL){
if(temp->type == ENT_TARGET_ALERT) break;
if(temp->type == EntityType::ENT_TARGET_ALERT) break;
}
if(temp != NULL) {
alertstate = temp->damage;
@ -283,7 +283,7 @@ static void ui_msd_setup(gentity_t* ent) {
G_Assert(ent, (void)0);
while((target = G_Find(target, FOFS(targetname), ent->target)) != NULL){
if(target->type == ENT_TARGET_SHIPHEALTH) {
if(target->type == EntityType::ENT_TARGET_SHIPHEALTH) {
break;
}
}
@ -309,7 +309,7 @@ void SP_ui_msd(gentity_t* ent) {
G_Assert(ent, (void)0);
ent->type = ENT_UI_MSD;
ent->type = EntityType::ENT_UI_MSD;
if(ent->target == NULL) {
G_LocLogger(LL_ERROR, "ui_msd without target at %s! Removing Entity.\n", vtos(ent->s.origin));
@ -416,7 +416,7 @@ void SP_ui_holodeck(gentity_t* ent) {
G_Assert(ent, (void)0);
ent->type = ENT_UI_HOLODECK;
ent->type = EntityType::ENT_UI_HOLODECK;
if(ent->target == NULL) {
G_LocLogger(LL_ERROR, "ui_holodeck without target at %s!\n", vtos(ent->s.origin));

View file

@ -357,7 +357,7 @@ void SP_func_usable(gentity_t* self)
return;
}
self->type = ENT_FUNC_USABLE;
self->type = EntityType::ENT_FUNC_USABLE;
trap_SetBrushModel(self, self->model);
InitMover(self);

View file

@ -878,7 +878,7 @@ void G_FreeEntity(gentity_t* ed)
ed->classname = "freed";
ed->freetime = level.time;
ed->inuse = qfalse;
ed->type = ENT_FREE;
ed->type = EntityType::ENT_FREE;
G_LogFuncEnd();
}

View file

@ -206,6 +206,12 @@
<ClCompile Include="bg_lex.flex.cpp">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="entities\InfoCamp.cpp" />
<ClCompile Include="entities\InfoNotNull.cpp" />
<ClCompile Include="entities\InfoNull.cpp" />
<ClCompile Include="entities\Light.cpp" />
<ClCompile Include="entities\Model.cpp" />
<ClCompile Include="Entity.cpp" />
<ClCompile Include="g_cinematic.cpp">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
</ClCompile>
@ -500,6 +506,13 @@
<ClInclude Include="bg_lex.h" />
<ClInclude Include="botlib.h" />
<ClInclude Include="chars.h" />
<ClInclude Include="entities\InfoCamp.h" />
<ClInclude Include="entities\InfoNotNull.h" />
<ClInclude Include="entities\InfoNull.h" />
<ClInclude Include="entities\Light.h" />
<ClInclude Include="entities\Model.h" />
<ClInclude Include="Entity.h" />
<ClInclude Include="Event.h" />
<ClInclude Include="g_active.h" />
<ClInclude Include="g_breakable.h" />
<ClInclude Include="g_cinematic.h" />

View file

@ -16,6 +16,12 @@
<Filter Include="Source Files\lua">
<UniqueIdentifier>{f63112ba-83f3-4b08-92ac-a2679cccbe87}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\entities">
<UniqueIdentifier>{daf11fef-c22e-4aba-9665-0762fe1c3e05}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\entities">
<UniqueIdentifier>{d53c00f3-be42-4568-8125-95a07013bb15}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="lua_entity.c">
@ -171,6 +177,24 @@
<ClCompile Include="md5.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Entity.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="entities\InfoCamp.cpp">
<Filter>Source Files\entities</Filter>
</ClCompile>
<ClCompile Include="entities\InfoNull.cpp">
<Filter>Source Files\entities</Filter>
</ClCompile>
<ClCompile Include="entities\InfoNotNull.cpp">
<Filter>Source Files\entities</Filter>
</ClCompile>
<ClCompile Include="entities\Light.cpp">
<Filter>Source Files\entities</Filter>
</ClCompile>
<ClCompile Include="entities\Model.cpp">
<Filter>Source Files\entities</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ai_chat.h">
@ -317,6 +341,27 @@
<ClInclude Include="ai_common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Event.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Entity.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="entities\InfoCamp.h">
<Filter>Header Files\entities</Filter>
</ClInclude>
<ClInclude Include="entities\InfoNull.h">
<Filter>Header Files\entities</Filter>
</ClInclude>
<ClInclude Include="entities\InfoNotNull.h">
<Filter>Header Files\entities</Filter>
</ClInclude>
<ClInclude Include="entities\Light.h">
<Filter>Header Files\entities</Filter>
</ClInclude>
<ClInclude Include="entities\Model.h">
<Filter>Header Files\entities</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="game.def">

View file

@ -754,7 +754,7 @@ static int Entity_DelayedCallSpawn(lua_State *L) {
return 1;
}
if(lent->e->type == ENT_TARGET_SELFDESTRUCT) {
if(lent->e->type == EntityType::ENT_TARGET_SELFDESTRUCT) {
LUA_DEBUG("ERROR - entity.DelayedCallSpawn - entity is target_selfdestruct");
lua_pushboolean(L, qfalse);
return 1; //we will not selfdestruct this way
@ -795,7 +795,7 @@ static int Entity_CallSpawn(lua_State *L) {
}
e = lent->e;
if(lent->e->type == ENT_TARGET_SELFDESTRUCT) {
if(lent->e->type == EntityType::ENT_TARGET_SELFDESTRUCT) {
LUA_DEBUG("ERROR - entity.CallSpawn - entity is target_selfdestruct");
lua_pushboolean(L, qfalse);
return 1; //we will not selfdestruct this way
@ -1048,15 +1048,15 @@ static int Entity_Lock(lua_State *L) {
ent = lent->e;
if((ent->type == ENT_FUNC_DOOR) ||
(ent->type == ENT_FUNC_DOOR_ROTATING) ||
(ent->type == ENT_TARGET_TELEPORTER) ||
(ent->type == ENT_TARGET_TURBOLIFT) ||
(ent->type == ENT_FUNC_USABLE) ||
(ent->type == ENT_TARGET_SERVERCHANGE) ||
(ent->type == ENT_TRIGGER_TELEPORT) ||
(ent->type == ENT_UI_TRANSPORTER) ||
(ent->type == ENT_UI_HOLODECK)
if((ent->type == EntityType::ENT_FUNC_DOOR) ||
(ent->type == EntityType::ENT_FUNC_DOOR_ROTATING) ||
(ent->type == EntityType::ENT_TARGET_TELEPORTER) ||
(ent->type == EntityType::ENT_TARGET_TURBOLIFT) ||
(ent->type == EntityType::ENT_FUNC_USABLE) ||
(ent->type == EntityType::ENT_TARGET_SERVERCHANGE) ||
(ent->type == EntityType::ENT_TRIGGER_TELEPORT) ||
(ent->type == EntityType::ENT_UI_TRANSPORTER) ||
(ent->type == EntityType::ENT_UI_HOLODECK)
) {
if(ent->flags & FL_LOCKED) {
LUA_DEBUG("INFO - entity.Lock - already locked");
@ -1096,15 +1096,15 @@ static int Entity_Unlock(lua_State *L) {
}
ent = lent->e;
if((ent->type == ENT_FUNC_DOOR) ||
(ent->type == ENT_FUNC_DOOR_ROTATING) ||
(ent->type == ENT_TARGET_TELEPORTER) ||
(ent->type == ENT_TARGET_TURBOLIFT) ||
(ent->type == ENT_FUNC_USABLE) ||
(ent->type == ENT_TARGET_SERVERCHANGE) ||
(ent->type == ENT_TRIGGER_TELEPORT) ||
(ent->type == ENT_UI_TRANSPORTER) ||
(ent->type == ENT_UI_HOLODECK)
if((ent->type == EntityType::ENT_FUNC_DOOR) ||
(ent->type == EntityType::ENT_FUNC_DOOR_ROTATING) ||
(ent->type == EntityType::ENT_TARGET_TELEPORTER) ||
(ent->type == EntityType::ENT_TARGET_TURBOLIFT) ||
(ent->type == EntityType::ENT_FUNC_USABLE) ||
(ent->type == EntityType::ENT_TARGET_SERVERCHANGE) ||
(ent->type == EntityType::ENT_TRIGGER_TELEPORT) ||
(ent->type == EntityType::ENT_UI_TRANSPORTER) ||
(ent->type == EntityType::ENT_UI_HOLODECK)
) {
if(ent->flags & FL_LOCKED) {
ent->flags ^= FL_LOCKED;