void sv_e_spell(var sender, STRING* data, var size)
{
if (size != sizeof(s_sendspell)) {svdiag("\nERROR in sv_e_spell: received invalid data length"); return;}
s_sendspell* sp_data = (s_sendspell*)data->chars; // get a new pointer with correct type, because the data is passed as a STRING*
// own code for handling spells, replace it with yours
// I included it to show cheating tests and how to send ok back to player
ENTITY* ent_caster = enet_ent_locpointer(pl_globpointers[sender]);
ENTITY* ent_targ = enet_ent_locpointer(sp_data->ent_targ);
int sp_level = spellbook_get_level((s_spell_book*)ent_caster->spellbook, sp_data->id);
if (sp_level == 0) {svdiag("\nCHEATING ATTEMPT in sv_e_spell: player doesn't have send spell"); return;}
// do spell action
if (sv_spell_act(ent_caster, sp_data->id, sp_level, ent_targ))
{
// send ok back to player, just the id, not the whole struct
// will start cooldown timer at the player
enet_svsend_event(EVENT_SPELL, sp_data->id, sizeof(unsigned short), sender);
// TODO: send effect to all players nearby.
}
}