mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 22:56:30 -10:00
* Automatically generate the isValid() Lua API function for handle types If an ADE object's stored type has an isValid() member, ade_obj now registers an isValid function for it automatically. An explicit ADE_FUNC(isValid, ...) declared after the ADE_OBJ replaces the generated one, so types with special semantics (e.g. sound) keep their own. The 67 hand-written functions that merely delegated to the member are removed, and 26 types that previously exposed no isValid() gain one. Co-Authored-By: Claude Fable 5.1 <[email protected]> * Add ADE_OBJ_VALIDATOR for index-based Lua handles Int-index handles (shipclass, weaponclass, team, etc.) can now declare their validity predicate with a single ADE_OBJ_VALIDATOR or ADE_OBJ_VALIDATOR_RANGE line after the ADE_OBJ. The registered validator drives the generated isValid() function and is also honored by ade_set_args when the mod table asks for nil instead of invalid objects, which previously never applied to these handles. The 19 hand-written range-check functions are replaced, and loadout_ship, default_primary, default_secondary, and support_rearm_pool_team gain isValid(). Add a validator to HudGauge while we're at it. Also fully qualify the scripting namespace in LuaConvert.h so its templates can be instantiated from the unit tests. Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
64 lines
994 B
C++
64 lines
994 B
C++
#pragma once
|
|
|
|
#include <sound/ds.h>
|
|
#include "scripting/ade_api.h"
|
|
#include "gamesnd/gamesnd.h"
|
|
#include "sound/sound.h"
|
|
|
|
namespace scripting {
|
|
namespace api {
|
|
|
|
|
|
struct sound_entry_h
|
|
{
|
|
gamesnd_id idx;
|
|
|
|
sound_entry_h();
|
|
|
|
explicit sound_entry_h(gamesnd_id n_idx);
|
|
|
|
game_snd *Get() const;
|
|
|
|
bool isValid() const;
|
|
};
|
|
|
|
//**********HANDLE: SoundEntry
|
|
DECLARE_ADE_OBJ(l_SoundEntry, sound_entry_h);
|
|
|
|
struct sound_h
|
|
{
|
|
sound_entry_h entryh;
|
|
sound_handle sig;
|
|
|
|
sound_h();
|
|
|
|
sound_h(gamesnd_id n_gs_idx, sound_handle n_sig);
|
|
|
|
sound_handle getSignature() const;
|
|
|
|
bool isValid() const; // This is the function that is checked by ade_set_args
|
|
bool isValidWithEntry() const;
|
|
};
|
|
|
|
//**********HANDLE: Sound
|
|
DECLARE_ADE_OBJ(l_Sound, sound_h);
|
|
|
|
|
|
DECLARE_ADE_OBJ(l_Sound3D, sound_h);
|
|
|
|
|
|
//**********HANDLE: Soundfile
|
|
|
|
struct soundfile_h {
|
|
sound_load_id idx;
|
|
|
|
explicit soundfile_h(sound_load_id id = sound_load_id::invalid());
|
|
|
|
bool isValid() const;
|
|
};
|
|
|
|
DECLARE_ADE_OBJ(l_Soundfile, soundfile_h);
|
|
}
|
|
}
|
|
|