mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-09 04:49:39 -10:00
* Add automatic lua obj serialization function dispatch * Implement fundamental and object de/serialization * Proper default case for package deserialization * Add No Multi func * Add Serialization part * Fix max encoding size for userdata * Implement exception handling * Start Implementing lua RPC * Prepare waitAsync for RPC * Add packet order enforcing and forwarding * Add RPC registry * Make RPCs callable * Add waitRPC * Add serializers * Fix GCC error * Explicitly specify lua_net_exception * Fix Warnings * Replace Seriliaze fundamental with cross-platform data types * Appease Clang * Prevent serialization CTD on invalid objects * Actually use the temporaries assigned * Fix OSWPT shadow * Fix table deserialize order * Incorporate Feedback * Fix Warnigs * ix WArnings 2 * Add sanity checks for OSWPT wing serialization * Multi Bump * Forgot we have american-style dates there
74 lines
1.7 KiB
C++
74 lines
1.7 KiB
C++
|
|
#include "gameevent.h"
|
|
|
|
#include "network/multi.h"
|
|
#include "network/multimsgs.h"
|
|
#include "network/multiutil.h"
|
|
|
|
namespace scripting {
|
|
namespace api {
|
|
gameevent_h::gameevent_h() {
|
|
edx = -1;
|
|
}
|
|
|
|
gameevent_h::gameevent_h(int n_event) {
|
|
edx = n_event;
|
|
}
|
|
|
|
bool gameevent_h::IsValid() {
|
|
return (edx > -1 && edx < Num_gs_event_text);
|
|
}
|
|
|
|
int gameevent_h::Get() {
|
|
return edx;
|
|
}
|
|
|
|
void gameevent_h::serialize(lua_State* /*L*/, const scripting::ade_table_entry& /*tableEntry*/, const luacpp::LuaValue& value, ubyte* data, int& packet_size) {
|
|
gameevent_h event;
|
|
value.getValue(l_GameEvent.Get(&event));
|
|
ADD_INT(event.edx);
|
|
}
|
|
|
|
void gameevent_h::deserialize(lua_State* /*L*/, const scripting::ade_table_entry& /*tableEntry*/, char* data_ptr, ubyte* data, int& offset) {
|
|
int index;
|
|
GET_INT(index);
|
|
new(data_ptr) gameevent_h(index);
|
|
}
|
|
|
|
ADE_OBJ(l_GameEvent, gameevent_h, "gameevent", "Game event");
|
|
|
|
ADE_FUNC(__tostring, l_GameEvent, NULL, "Game event name", "string", "Game event name, or empty string if handle is invalid")
|
|
{
|
|
gameevent_h *gh = NULL;
|
|
if (!ade_get_args(L, "o", l_GameEvent.GetPtr(&gh)))
|
|
return ade_set_error(L, "s", "");
|
|
|
|
if (!gh->IsValid())
|
|
return ade_set_error(L, "s", "");
|
|
|
|
return ade_set_args(L, "s", GS_event_text[gh->Get()]);
|
|
}
|
|
|
|
ADE_VIRTVAR(Name, l_GameEvent, "string", "Game event name", "string", "Game event name, or empty string if handle is invalid")
|
|
{
|
|
gameevent_h *gh = NULL;
|
|
const char* n_name = nullptr;
|
|
if (!ade_get_args(L, "o|s", l_GameEvent.GetPtr(&gh), &n_name))
|
|
return ade_set_error(L, "s", "");
|
|
|
|
if (!gh->IsValid())
|
|
return ade_set_error(L, "s", "");
|
|
|
|
int edx = gh->Get();
|
|
|
|
if (ADE_SETTING_VAR)
|
|
{
|
|
Error(LOCATION, "Can't set game event names at this time");
|
|
}
|
|
|
|
return ade_set_args(L, "s", GS_event_text[edx]);
|
|
}
|
|
|
|
}
|
|
}
|