I have the following snippet of code:
PHP Code:
enum struct Survivor1 {
char name[MAX_NAME_LENGTH];
char model[PLATFORM_MAX_PATH];
int prop;
char adminflags[16];
}
enum struct Survivor2 {
char name[MAX_NAME_LENGTH];
char model[PLATFORM_MAX_PATH];
int prop[1];
char adminflags[16];
}
public void OnPluginStart()
{
Survivor1 e = { "Ellis", "models/survivors/survivor_mechanic.mdl", 3, "bcd" }; // line 17
Survivor2 z = { "Zoey", "models/survivors/survivor_teenangst.mdl", 5, "z" };
PrintToServer("%s %s %i %s", e.name, e.model, e.prop, e.adminflags);
PrintToServer("%s %s %i %s", z.name, z.model, z.prop, z.adminflags); // line 21
}
Compiling this code produces the following warning:
test.sp(17) : warning 228: length of initializer exceeds size of the enum field
but otherwise compiles perfectly fine.
I am confused by this, especially since activating the plugin doesn't throw any errors:
Code:
sm plugins load custom/optional/test
Ellis models/survivors/survivor_mechanic.mdl 3 bcd
Zoey models/survivors/survivor_teenangst.mdl 5 z
[SM] Loaded plugin custom/optional/test.smx successfully.
If I change the PrintToServer lines to the following:
PHP Code:
PrintToServer("%s %s %i %s", e.name, e.model, e.prop + 4, e.adminflags);
PrintToServer("%s %s %i %s", z.name, z.model, z.prop + 4, z.adminflags);
and attempt to recompile, I get this error:
test.sp(21) : error 033: array must be indexed (variable "prop")
Why do I need to declare
prop as an array to make the warning go away?
IntToString (which is used in my plugin to apply the prop's value to a player) doesn't accept integer arrays, and I can't perform operations on
z.prop without referencing index 0 constantly.
I have a feeling that my code (Survivor1 specifically) is fine, and the compiler is throwing a false warning. Can someone with more SourcePawn experience confirm or deny my suspicions?