Skip to content

Commit

Permalink
Fix non-hotspot object connect and disconnect not working in editor
Browse files Browse the repository at this point in the history
- Also fix some broken overrides after a parameter was added, add compiler warning for hidden overloads, and fix all known cases of them (except in third-party libraries)
  • Loading branch information
kavika13 committed Jul 30, 2024
1 parent 15c319a commit 0256b3f
Show file tree
Hide file tree
Showing 25 changed files with 132 additions and 55 deletions.
4 changes: 2 additions & 2 deletions Projects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1310,9 +1310,9 @@ IF(BUILD_OVERGROWTH)
ENDIF()

# Disabling strict-aliasing, which is default on gcc because angelscript interface has an api function that requires a return of *void.
SET_TARGET_PROPERTIES(Overgrowth PROPERTIES COMPILE_FLAGS "-Wall -Wno-long-long -Wno-variadic-macros -Wno-trigraphs -Wno-unknown-pragmas -Wno-deprecated-declarations -Wno-unused-variable -Wno-unused-function -Wno-reorder -Werror=return-type ${SSE_FLAGS} ${BREAKPAD_FLAGS} ${NON_BREAKPAD_FLAGS}")
SET_TARGET_PROPERTIES(Overgrowth PROPERTIES COMPILE_FLAGS "-Wall -Wno-long-long -Wno-variadic-macros -Wno-trigraphs -Wno-unknown-pragmas -Wno-deprecated-declarations -Wno-unused-variable -Wno-unused-function -Wno-reorder -Werror=return-type -Woverloaded-virtual ${SSE_FLAGS} ${BREAKPAD_FLAGS} ${NON_BREAKPAD_FLAGS}")
ENDIF()

# Supress all compile warnings because we shouldn't have to care about external code cleanlyness
SET(EXTERNAL_LIB_COMPILE_FLAGS "${COMPILE_FLAGS} -w")

Expand Down
12 changes: 6 additions & 6 deletions Source/Editors/map_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1778,15 +1778,15 @@ void MapEditor::HandleShortcuts(const LineSegment& mouseray) {
for (auto& i : selected) {
if (active_tool_ == EditorTypes::CONNECT) {
Object* obj = i;
// if(obj->ConnectTo(*hit_obj)){
// something_happened = true;
// }
if (obj->ConnectTo(*hit_obj)) {
something_happened = true;
}
} else if (active_tool_ == EditorTypes::DISCONNECT) {
Object* obj = i;
Object* hit_obj = c.hit_what;
// if(obj->Disconnect(*hit_obj)){
// something_happened = true;
// }
if (obj->Disconnect(*hit_obj)) {
something_happened = true;
}
}
}
if (something_happened) {
Expand Down
9 changes: 9 additions & 0 deletions Source/Graphics/skeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,17 @@
#include <Logging/logdata.h>
#include <Main/engine.h>

#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
#endif

#include <btBulletDynamicsCommon.h>

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

#include <cmath>
#include <set>

Expand Down
6 changes: 3 additions & 3 deletions Source/Objects/envobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void EnvObject::UpdateParentHierarchy() {
}
}

void EnvObject::HandleMaterialEvent(const std::string& the_event, const vec3& event_pos) {
void EnvObject::HandleMaterialEvent(const std::string& the_event, const vec3& event_pos, int* tri) {
MaterialRef material = ofr_material;
material->HandleEvent(the_event, event_pos);
}
Expand Down Expand Up @@ -1421,12 +1421,12 @@ const Model* EnvObject::GetModel() const {
return &Models::Instance()->GetModel(model_id_);
}

const MaterialDecal& EnvObject::GetMaterialDecal(const std::string& type, const vec3& pos) {
const MaterialDecal& EnvObject::GetMaterialDecal(const std::string& type, const vec3& pos, int* tri) {
MaterialRef material = ofr_material;
return material->GetDecal(type);
}

const MaterialParticle& EnvObject::GetMaterialParticle(const std::string& type, const vec3& pos) {
const MaterialParticle& EnvObject::GetMaterialParticle(const std::string& type, const vec3& pos, int* tri) {
MaterialRef material = ofr_material;
return material->GetParticle(type);
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Objects/envobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ class EnvObject : public Object {
void RemovePhysicsShape();
const Model *GetModel() const;
vec3 GetBoundingBoxSize();
void HandleMaterialEvent(const std::string &the_event, const vec3 &event_pos);
void HandleMaterialEvent(const std::string &the_event, const vec3 &event_pos, int *tri) override;
const MaterialEvent &GetMaterialEvent(const std::string &the_event, const vec3 &event_pos, int *tri) override;
const MaterialEvent &GetMaterialEvent(const std::string &the_event, const vec3 &event_pos, const std::string &mod, int *tri) override;
const MaterialDecal &GetMaterialDecal(const std::string &type, const vec3 &pos);
const MaterialParticle &GetMaterialParticle(const std::string &type, const vec3 &pos);
const MaterialDecal &GetMaterialDecal(const std::string &type, const vec3 &pos, int* tri = NULL) override;
const MaterialParticle &GetMaterialParticle(const std::string &type, const vec3 &pos, int* tri = NULL) override;
MaterialRef GetMaterial(const vec3 &pos, int *tri = NULL) override;
void UpdateDetailScale();
bool Load(const std::string &type_file);
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/hotspot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ bool Hotspot::ConnectTo(Object& other, bool checking_other /*= false*/) {
return return_value;
}

bool Hotspot::Disconnect(Object& other, bool checking_other /* = false*/) {
bool Hotspot::Disconnect(Object& other, bool from_socket /* = false*/, bool checking_other /* = false*/) {
if (std::find(connected_to.begin(), connected_to.end(), other.GetID()) == connected_to.end())
return false;

Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/hotspot.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Hotspot : public Object {
bool AcceptConnectionsFrom(ConnectionType type, Object& object) override;
virtual bool AcceptConnectionsTo(Object& object);
bool ConnectTo(Object& other, bool checking_other = false) override;
virtual bool Disconnect(Object& other, bool checking_other = false);
virtual bool Disconnect(Object& other, bool from_socket = false, bool checking_other = false) override;

void ConnectedFrom(Object& other) override;
void DisconnectedFrom(Object& other) override;
Expand Down
24 changes: 17 additions & 7 deletions Source/Objects/itemobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@
#include <Threading/sdl_wrapper.h>
#include <Online/online.h>

#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
#endif

#include <btBulletDynamicsCommon.h>

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -160,7 +170,7 @@ void ItemObject::SetAngularVelocity(vec3 vel) {
bullet_object_->SetAngularVelocity(vel);
}

void ItemObject::HandleMaterialEvent(const std::string& the_event, const vec3& normal, const vec3& event_pos, float gain, float pitch_shift) {
void ItemObject::HandleItemObjectMaterialEvent(const std::string& the_event, const vec3& normal, const vec3& event_pos, float gain, float pitch_shift) {
const MaterialEvent* me = scenegraph_->GetMaterialEvent(the_event, event_pos, item_ref_->GetSoundModifier(), this);
if (me && !me->soundgroup.empty()) {
float dist = distance(event_pos, ActiveCameras::Get()->GetPos());
Expand Down Expand Up @@ -917,13 +927,13 @@ void ItemObject::PlayImpactSound(const vec3& pos, const vec3& normal, float impu

switch (weight_class) {
case kLightWeight:
HandleMaterialEvent("weapon_drop_light", normal, pos, impulse);
HandleItemObjectMaterialEvent("weapon_drop_light", normal, pos, impulse);
break;
case kMediumWeight:
HandleMaterialEvent("weapon_drop_medium", normal, pos, impulse);
HandleItemObjectMaterialEvent("weapon_drop_medium", normal, pos, impulse);
break;
case kHeavyWeight:
HandleMaterialEvent("weapon_drop_heavy", normal, pos, impulse);
HandleItemObjectMaterialEvent("weapon_drop_heavy", normal, pos, impulse);
break;
}
{ // Notify nearby characters
Expand Down Expand Up @@ -1047,11 +1057,11 @@ bool ItemObject::ConnectTo(Object& other, bool checking_other /*= false*/) {
}
}

bool ItemObject::Disconnect(Object& other, bool checking_other /*= false*/) {
bool ItemObject::Disconnect(Object& other, bool from_socket /*= false*/, bool checking_other /*= false*/) {
if (other.GetType() == _movement_object) {
return other.Disconnect(*this, true);
return other.Disconnect(*this, from_socket, true);
} else {
return Object::Disconnect(other, checking_other);
return Object::Disconnect(other, from_socket, checking_other);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Objects/itemobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ItemObject : public Object {
void Draw() override;
void PreDrawFrame(float curr_game_time) override;
bool ConnectTo(Object& other, bool checking_other = false) override;
virtual bool Disconnect(Object& other, bool checking_other = false);
virtual bool Disconnect(Object& other, bool from_socket = false, bool checking_other = false) override;
void Moved(Object::MoveType type) override;

int model_id() const;
Expand Down Expand Up @@ -218,7 +218,7 @@ class ItemObject : public Object {
TimeInterpolator network_time_interpolator;

void DrawDepthMap(const mat4& proj_view_matrix, const vec4* cull_planes, int num_cull_planes, Object::DrawType draw_type) override;
virtual void HandleMaterialEvent(const std::string& the_event, const vec3& normal, const vec3& event_pos, float gain = 1.0f, float pitch_shift = 1.0f);
void HandleItemObjectMaterialEvent(const std::string& the_event, const vec3& normal, const vec3& event_pos, float gain = 1.0f, float pitch_shift = 1.0f);

void MakeBulletObject();
void StickingCollisionOccured(const vec3& pos, int vert, const CollideInfo& collide_info);
Expand Down
16 changes: 8 additions & 8 deletions Source/Objects/movementobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ void MovementObject::DrawDepthMap(const mat4& proj_view_matrix, const vec4* cull
}

if (!occluded) {
rigged_object_->Draw(proj_view_matrix, RiggedObject::kDrawDepthOnly);
rigged_object_->DrawRiggedObject(proj_view_matrix, RiggedObject::kDrawDepthOnly);
}
}
}
Expand Down Expand Up @@ -538,7 +538,7 @@ void MovementObject::Draw() {
}

if (!occluded) {
rigged_object_->Draw(cam->GetProjMatrix() * cam->GetViewMatrix(), RiggedObject::kFullDraw);
rigged_object_->DrawRiggedObject(cam->GetProjMatrix() * cam->GetViewMatrix(), RiggedObject::kFullDraw);
}
}
}
Expand Down Expand Up @@ -1025,7 +1025,7 @@ void MovementObject::Update(float timestep) {

if (incoming_material_sound_events.size() > 0) {
MaterialSoundEvent* mse = static_cast<MaterialSoundEvent*>(incoming_material_sound_events.begin()->GetData());
HandleMaterialEvent(mse->event_name, mse->pos, mse->gain);
HandleMovementObjectMaterialEvent(mse->event_name, mse->pos, mse->gain);
incoming_material_sound_events.pop_front();
}

Expand Down Expand Up @@ -1281,7 +1281,7 @@ int MovementObject::QueryIntFunction(std::string func) {
return val;
}

void MovementObject::HandleMaterialEvent(std::string the_event, vec3 event_pos, float gain) {
void MovementObject::HandleMovementObjectMaterialEvent(std::string the_event, vec3 event_pos, float gain) {
Online* online = Online::Instance();

if (event_pos != event_pos) {
Expand Down Expand Up @@ -1343,8 +1343,8 @@ void MovementObject::HandleMaterialEvent(std::string the_event, vec3 event_pos,
}
}

void MovementObject::HandleMaterialEventDefault(std::string the_event, vec3 event_pos) {
HandleMaterialEvent(the_event, event_pos);
void MovementObject::HandleMovementObjectMaterialEventDefault(std::string the_event, vec3 event_pos) {
HandleMovementObjectMaterialEvent(the_event, event_pos);
}

void MovementObject::MaterialParticleAtBone(std::string type, std::string bone_name) {
Expand Down Expand Up @@ -3984,8 +3984,8 @@ bool MovementObject::Initialize() {
as_context->RegisterObjectMethod("MovementObject", "void SetCharAnimation(string char_anim, float transition_speed, int8 flags)", asMETHODPR(MovementObject, ASSetCharAnimation, (std::string, float, char), void), asCALL_THISCALL);
as_context->RegisterObjectMethod("MovementObject", "void SetCharAnimation(string char_anim, float transition_speed)", asMETHODPR(MovementObject, ASSetCharAnimation, (std::string, float), void), asCALL_THISCALL);
as_context->RegisterObjectMethod("MovementObject", "void SetCharAnimation(string char_anim)", asMETHODPR(MovementObject, ASSetCharAnimation, (std::string), void), asCALL_THISCALL);
as_context->RegisterObjectMethod("MovementObject", "void MaterialEvent(string event, vec3 position)", asMETHOD(MovementObject, HandleMaterialEventDefault), asCALL_THISCALL);
as_context->RegisterObjectMethod("MovementObject", "void MaterialEvent(string event, vec3 position, float audio_gain)", asMETHOD(MovementObject, HandleMaterialEvent), asCALL_THISCALL);
as_context->RegisterObjectMethod("MovementObject", "void MaterialEvent(string event, vec3 position)", asMETHOD(MovementObject, HandleMovementObjectMaterialEventDefault), asCALL_THISCALL);
as_context->RegisterObjectMethod("MovementObject", "void MaterialEvent(string event, vec3 position, float audio_gain)", asMETHOD(MovementObject, HandleMovementObjectMaterialEvent), asCALL_THISCALL);
as_context->RegisterObjectMethod("MovementObject", "void PlaySoundGroupAttached(string path, vec3 position)", asMETHOD(MovementObject, ASPlaySoundGroupAttached), asCALL_THISCALL);
as_context->RegisterObjectMethod("MovementObject", "void PlaySoundAttached(string path, vec3 position)", asMETHOD(MovementObject, ASPlaySoundAttached), asCALL_THISCALL);
as_context->RegisterObjectMethod("MovementObject", "void PlaySoundGroupVoice(string voice_key, float delay)", asMETHOD(MovementObject, PlaySoundGroupVoice), asCALL_THISCALL);
Expand Down
6 changes: 3 additions & 3 deletions Source/Objects/movementobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class MovementObject : public Object {
bool HasFunction(const std::string& function_definition);
int QueryIntFunction(std::string func);
void SetScriptParams(const ScriptParamMap& spm) override;
void ApplyPalette(const OGPalette& palette, bool from_socket = false);
void ApplyPalette(const OGPalette& palette, bool from_socket = false) override;
OGPalette* GetPalette() override;
void HitByItem(int id, const vec3& point, const std::string& material, int type);
void Execute(std::string);
Expand Down Expand Up @@ -313,7 +313,7 @@ class MovementObject : public Object {
void SetAnimation(std::string path);
void SetAnimation(std::string path, float fade_speed, char flags);
void SwapAnimation(std::string path);
void HandleMaterialEvent(std::string the_event, vec3 event_pos, float gain = 1.0f);
void HandleMovementObjectMaterialEvent(std::string the_event, vec3 event_pos, float gain = 1.0f);

vec4 GetAvgRotationVec4();
int ASWasHit(std::string type, std::string attack_path, vec3 dir, vec3 pos, int attacker_id, float attack_damage_mult, float attack_knockback_mult);
Expand All @@ -323,7 +323,7 @@ class MovementObject : public Object {
void CreateRiggedObject();
void RecreateRiggedObject(std::string _char_path);
void ASDetachItem(int which);
void HandleMaterialEventDefault(std::string the_event, vec3 event_pos);
void HandleMovementObjectMaterialEventDefault(std::string the_event, vec3 event_pos);
void ForceSoundGroupVoice(std::string path, float delay);
int GetWaypointTarget();
void Reset() override;
Expand Down
6 changes: 3 additions & 3 deletions Source/Objects/navmeshconnectionobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ bool NavmeshConnectionObject::AcceptConnectionsFrom(Object::ConnectionType type,
return type == kCTNavmeshConnections;
}

bool NavmeshConnectionObject::Disconnect(Object& other, bool checking_other) {
bool NavmeshConnectionObject::Disconnect(Object& other, bool from_socket, bool checking_other) {
if (other.GetType() == _movement_object) {
return Object::Disconnect(other, checking_other);
return Object::Disconnect(other, from_socket, checking_other);
} else if (other.GetType() != this->GetType()) {
return false;
} else {
Expand All @@ -101,7 +101,7 @@ bool NavmeshConnectionObject::Disconnect(Object& other, bool checking_other) {
}

if (!checking_other) {
ppo->Disconnect(*this, true);
ppo->Disconnect(*this, from_socket, true);
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/navmeshconnectionobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NavmeshConnectionObject : public Object {

bool ConnectTo(Object& other, bool checking_other = false) override;
bool AcceptConnectionsFrom(ConnectionType type, Object& object) override;
virtual bool Disconnect(Object& other, bool checking_other = false);
virtual bool Disconnect(Object& other, bool from_socket = false, bool checking_other = false) override;
void GetConnectionIDs(std::vector<int>* cons) override;

void ResetConnectionOffMeshReference();
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class Object {
ScriptParams* GetScriptParams() { return &sp; }
const ScriptParamMap& GetScriptParamMap();
virtual void SetScriptParams(const ScriptParamMap& spm);
virtual void ApplyPalette(const OGPalette& palette) {}
virtual void ApplyPalette(const OGPalette& palette, bool from_socket = false) {}
virtual OGPalette* GetPalette();
virtual void ReceiveASVec3Message(int type, const vec3& vec_a, const vec3& vec_b) {}
virtual void SaveHistoryState(std::list<SavedChunk>& chunk_list, int state_id);
Expand Down
8 changes: 4 additions & 4 deletions Source/Objects/pathpointobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ bool PathPointObject::AcceptConnectionsFrom(Object::ConnectionType type, Object&
return type == kCTMovementObjects || type == kCTPathPoints;
}

bool PathPointObject::Disconnect(Object& other, bool checking_other) {
bool PathPointObject::Disconnect(Object& other, bool from_socket, bool checking_other) {
if (other.GetType() == _movement_object) {
return other.Disconnect(*this, true);
return other.Disconnect(*this, from_socket, true);
} else if (other.GetType() == _hotspot_object) {
return Object::Disconnect(other, checking_other);
return Object::Disconnect(other, from_socket, checking_other);
} else if (other.GetType() != _path_point_object) {
return false;
} else {
Expand All @@ -95,7 +95,7 @@ bool PathPointObject::Disconnect(Object& other, bool checking_other) {
connection_ids.erase(iter);
}
if (!checking_other) {
ppo->Disconnect(*this, true);
ppo->Disconnect(*this, from_socket, true);
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/pathpointobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PathPointObject : public Object {

bool ConnectTo(Object& other, bool checking_other = false) override;
bool AcceptConnectionsFrom(ConnectionType type, Object& object) override;
virtual bool Disconnect(Object& other, bool checking_other = false);
virtual bool Disconnect(Object& other, bool from_socket = false, bool checking_other = false) override;
void GetConnectionIDs(std::vector<int>* cons) override;

int GetModelID();
Expand Down
4 changes: 2 additions & 2 deletions Source/Objects/placeholderobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ bool PlaceholderObject::AcceptConnectionsFrom(Object::ConnectionType type, Objec
return connectable() && type == kCTMovementObjects; // Not sure this is correct because I have no clue how placeholders work yet
}

bool PlaceholderObject::Disconnect(Object& other, bool checking_other) {
bool PlaceholderObject::Disconnect(Object& other, bool from_socket, bool checking_other) {
if (other.GetType() == _hotspot_object) {
return Object::Disconnect(other, checking_other);
return Object::Disconnect(other, from_socket, checking_other);
}
if (!connectable()) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/placeholderobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PlaceholderObject : public Object {
uint64_t GetConnectToTypeFilterFlags();
void SetConnectToTypeFilterFlags(uint64_t entity_type_flags);
bool ConnectTo(Object& other, bool checking_other = false) override;
virtual bool Disconnect(Object& other, bool checking_other = false);
virtual bool Disconnect(Object& other, bool from_socket = false, bool checking_other = false) override;
void GetConnectionIDs(std::vector<int>* cons) override;

int GetConnectID();
Expand Down
Loading

0 comments on commit 0256b3f

Please sign in to comment.