}
#define MAX_MUTATORS 8
-var mutatorfunc_t mutators[MAX_MUTATORS];
-float Mutator_Add(mutatorfunc_t func)
+string loaded_mutators[MAX_MUTATORS];
+float Mutator_Add(mutatorfunc_t func, string name)
{
float i, j;
j = -1;
for(i = 0; i < MAX_MUTATORS; ++i)
{
- if(func == mutators[i])
+ if(name == loaded_mutators[i])
return 1; // already added
- if(func == func_null)
+ if(!loaded_mutators[i])
j = i;
}
if(j < 0)
backtrace("WARNING: too many mutators, cannot add any more\n");
return 0;
}
- mutators[j] = func;
+ loaded_mutators[j] = name;
if(func(MUTATOR_ADDING) == 0)
{
return 1;
}
backtrace("WARNING: when adding mutator: adding failed\n");
- Mutator_Remove(func);
+ Mutator_Remove(func, name);
return 0;
}
-void Mutator_Remove(float(float) func)
+void Mutator_Remove(float(float) func, string name)
{
float i;
for(i = 0; i < MAX_MUTATORS; ++i)
- if(func == mutators[i])
+ if(name == loaded_mutators[i])
break;
if(i >= MAX_MUTATORS)
{
backtrace("WARNING: removing not-added mutator\n");
return;
}
- mutators[i] = func_null;
+ loaded_mutators[i] = string_null;
if(func(MUTATOR_REMOVING) != 0)
{
#define MUTATOR_REMOVING 0
#define MUTATOR_ADDING 1
typedef float(float) mutatorfunc_t;
-float Mutator_Add(mutatorfunc_t func);
-void Mutator_Remove(mutatorfunc_t func); // calls error() on fail
+float Mutator_Add(mutatorfunc_t func, string name);
+void Mutator_Remove(mutatorfunc_t func, string name); // calls error() on fail
-#define MUTATOR_ADD(name) Mutator_Add(MUTATOR_##name)
-#define MUTATOR_REMOVE(name) Mutator_Remove(MUTATOR_##name)
+#define MUTATOR_ADD(name) Mutator_Add(MUTATOR_##name, #name)
+#define MUTATOR_REMOVE(name) Mutator_Remove(MUTATOR_##name, #name)
#define MUTATOR_DEFINITION(name) float MUTATOR_##name(float mode)
#define MUTATOR_DECLARATION(name) float MUTATOR_##name(float mode)
#define MUTATOR_HOOKFUNCTION(name) float HOOKFUNCTION_##name()