Skip to content

Instantly share code, notes, and snippets.

@tomprince
Created March 4, 2011 21:44
Show Gist options
  • Save tomprince/855751 to your computer and use it in GitHub Desktop.
Save tomprince/855751 to your computer and use it in GitHub Desktop.
diff --git a/gemrb/core/EffectQueue.cpp b/gemrb/core/EffectQueue.cpp
index 38d9780..582b54c 100644
--- a/gemrb/core/EffectQueue.cpp
+++ b/gemrb/core/EffectQueue.cpp
@@ -172,7 +172,7 @@ int find_effect(const void *a, const void *b)
return stricmp((const char *) a,((const EffectRef *) b)->Name);
}
-static EffectRef* FindEffect(const char* effectname)
+static EffectRef2* FindEffect(const char* effectname)
{
if( !effectname || !effectnames) {
return NULL;
@@ -182,7 +182,7 @@ static EffectRef* FindEffect(const char* effectname)
printMessage( "EffectQueue", "", YELLOW);
printf("Couldn't assign effect: %s\n", effectname );
}
- return (EffectRef *) tmp;
+ return (EffectRef2 *) tmp;
}
static EffectRef fx_protection_from_display_string_ref={"Protection:String",NULL,-1};
@@ -215,7 +215,7 @@ static EffectRef diced_effects2[] = {
inline static void ResolveEffectRef(EffectRef &effect_reference)
{
if( effect_reference.opcode==-1) {
- EffectRef* ref = FindEffect(effect_reference.Name);
+ EffectRef2* ref = FindEffect(effect_reference.Name);
if( ref && ref->opcode>=0) {
effect_reference.opcode = ref->opcode;
return;
@@ -266,7 +266,7 @@ bool Init_EffectQueue()
}
}
- EffectRef* poi = FindEffect( effectname );
+ EffectRef2* poi = FindEffect( effectname );
if( poi != NULL) {
Opcodes[i].Function = poi->Function;
Opcodes[i].Name = poi->Name;
@@ -302,7 +302,7 @@ void EffectQueue_ReleaseMemory()
effectnames = NULL;
}
-void EffectQueue_RegisterOpcodes(int count, const EffectRef* opcodes)
+void EffectQueue_RegisterOpcodes(int count, const EffectRef2* opcodes)
{
if( ! effectnames) {
effectnames = (EffectRef*) malloc( (count+1) * sizeof( EffectRef ) );
diff --git a/gemrb/core/EffectQueue.h b/gemrb/core/EffectQueue.h
index b865d74..ad70b9c 100644
--- a/gemrb/core/EffectQueue.h
+++ b/gemrb/core/EffectQueue.h
@@ -141,6 +141,12 @@ typedef int (* EffectFunction)(Scriptable*, Actor*, Effect*);
/** Links Effect name to a function implementing the effect */
struct EffectRef {
const char* Name;
+ const int EffectRef::* garbage;
+ int opcode;
+};
+
+struct EffectRef2 {
+ const char* Name;
EffectFunction Function;
int opcode;
};
@@ -150,7 +156,7 @@ struct EffectRef {
bool Init_EffectQueue();
/** Registers opcodes implemented by an effect plugin */
-void EffectQueue_RegisterOpcodes(int count, const EffectRef *opcodes);
+void EffectQueue_RegisterOpcodes(int count, const EffectRef2 *opcodes);
/** release effect list when Interface is destroyed */
void EffectQueue_ReleaseMemory();
diff --git a/gemrb/core/Interface.cpp b/gemrb/core/Interface.cpp
index 4c479ce..64db6cd 100644
--- a/gemrb/core/Interface.cpp
+++ b/gemrb/core/Interface.cpp
@@ -5338,7 +5338,7 @@ int Interface::Autopause(ieDword flag)
return 0;
}
-void Interface::RegisterOpcodes(int count, const EffectRef *opcodes)
+void Interface::RegisterOpcodes(int count, const EffectRef2 *opcodes)
{
EffectQueue_RegisterOpcodes(count, opcodes);
}
diff --git a/gemrb/core/Interface.h b/gemrb/core/Interface.h
index 3d98f3e..6518776 100644
--- a/gemrb/core/Interface.h
+++ b/gemrb/core/Interface.h
@@ -61,7 +61,7 @@ class Control;
class DataFileMgr;
struct Effect;
class EffectQueue;
-struct EffectRef;
+struct EffectRef2;
class EventMgr;
class Factory;
class Font;
@@ -656,7 +656,7 @@ public:
/** receives an autopause reason, returns 1 if pause was triggered by this call, -1 if it was already triggered */
int Autopause(ieDword reason);
/** registers engine opcodes */
- void RegisterOpcodes(int count, const EffectRef *opcodes);
+ void RegisterOpcodes(int count, const EffectRef2 *opcodes);
/** reads a list of resrefs into an array, returns array size */
int ReadResRefTable(const ieResRef tablename, ieResRef *&data);
/** frees the data */
diff --git a/gemrb/plugins/FXOpcodes/FXOpcodes.cpp b/gemrb/plugins/FXOpcodes/FXOpcodes.cpp
index c081f8b..8164a7a 100644
--- a/gemrb/plugins/FXOpcodes/FXOpcodes.cpp
+++ b/gemrb/plugins/FXOpcodes/FXOpcodes.cpp
@@ -418,7 +418,7 @@ int fx_change_weather (Scriptable* Owner, Actor* target, Effect* fx);//13e Cha
int fx_unknown (Scriptable* Owner, Actor* target, Effect* fx);//???
// FIXME: Make this an ordered list, so we could use bsearch!
-static EffectRef effectnames[] = {
+static EffectRef2 effectnames[] = {
{ "*Crash*", fx_crash, -1 },
{ "AcidResistanceModifier", fx_acid_resistance_modifier, -1 },
{ "ACVsCreatureType", fx_generic_effect, -1 }, //0xdb
diff --git a/gemrb/plugins/IWDOpcodes/IWDOpcodes.cpp b/gemrb/plugins/IWDOpcodes/IWDOpcodes.cpp
index 2b1ee60..252157f 100644
--- a/gemrb/plugins/IWDOpcodes/IWDOpcodes.cpp
+++ b/gemrb/plugins/IWDOpcodes/IWDOpcodes.cpp
@@ -222,7 +222,7 @@ static int fx_hamstring (Scriptable* Owner, Actor* target, Effect* fx); //456
static int fx_rapid_shot (Scriptable* Owner, Actor* target, Effect* fx); //457
//No need to make these ordered, they will be ordered by EffectQueue
-static EffectRef effectnames[] = {
+static EffectRef2 effectnames[] = {
{ "ACVsDamageTypeModifierIWD2", fx_ac_vs_damage_type_modifier_iwd2, -1}, //0
{ "DamageBonusModifier", fx_damage_bonus_modifier, -1 }, //49
{ "DrawUponHolyMight", fx_draw_upon_holy_might, -1},//84 (iwd2)
diff --git a/gemrb/plugins/PSTOpcodes/PSTOpcodes.cpp b/gemrb/plugins/PSTOpcodes/PSTOpcodes.cpp
index ef66651..a95abec 100644
--- a/gemrb/plugins/PSTOpcodes/PSTOpcodes.cpp
+++ b/gemrb/plugins/PSTOpcodes/PSTOpcodes.cpp
@@ -55,7 +55,7 @@ int fx_jumble_curse (Scriptable* Owner, Actor* target, Effect* fx);//d3
//int fx_unknown (Scriptable* Owner, Actor* target, Effect* fx);//d4
//the engine sorts these, feel free to use any order
-static EffectRef effectnames[] = {
+static EffectRef2 effectnames[] = {
{ "Bless", fx_bless, -1},//82
{ "Curse", fx_curse, -1},//cb
{ "DetectEvil", fx_detect_evil, -1}, //d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment