mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Removed "proto_exists" function in previous commit
Added macro for checking pid.
This commit is contained in:
@@ -264,6 +264,8 @@
|
||||
// clears the keyboard input buffer, use it in the HOOK_KEYPRESS hook to clear keyboard events before calling functions that are waiting for keyboard input
|
||||
#define clear_keyboard_buffer metarule3(201, 0, 0, 0)
|
||||
|
||||
// checks if the specified PID number exists in the list of registered protos
|
||||
#define check_pid(pid) (get_proto_data(pid, 0) != -1)
|
||||
|
||||
/* sfall_funcX macros */
|
||||
#define add_extra_msg_file(name) sfall_func1("add_extra_msg_file", name)
|
||||
@@ -332,7 +334,6 @@
|
||||
#define overlay_clear(winType) sfall_func2("interface_overlay", winType, 2)
|
||||
#define overlay_clear_rectangle(winType, x, y, w, h) sfall_func6("interface_overlay", winType, 2, x, y, w, h)
|
||||
#define overlay_destroy(winType) sfall_func2("interface_overlay", winType, 0)
|
||||
#define proto_exists(pid) sfall_func1("proto_exists", pid)
|
||||
#define real_dude_obj sfall_func0("real_dude_obj")
|
||||
#define remove_all_timer_events sfall_func0("remove_timer_event")
|
||||
#define remove_timer_event(fixedParam) sfall_func1("remove_timer_event", fixedParam)
|
||||
|
||||
@@ -742,9 +742,6 @@ optional arguments:
|
||||
- gvarNumber: the number of the global variable controlling the quest
|
||||
- thresholdValue: the value of the global variable at which the quest is counted as a failure
|
||||
|
||||
> bool sfall_func1("proto_exists", int pid)
|
||||
- returns True if the specified PID number exists in the list of registered protos
|
||||
|
||||
------------------------
|
||||
------ MORE INFO -------
|
||||
------------------------
|
||||
|
||||
@@ -580,7 +580,6 @@ bool CheckProtoID(DWORD pid) {
|
||||
if (pid == 0) return false;
|
||||
long type = pid >> 24;
|
||||
if (type > OBJ_TYPE_MISC) return false;
|
||||
|
||||
return (static_cast<long>(pid & 0xFFFF) < ptr_protoLists[type].totalCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,6 @@ static const SfallMetarule metaruleArray[] = {
|
||||
{"obj_under_cursor", mf_obj_under_cursor, 2, 2},
|
||||
{"objects_in_radius", mf_objects_in_radius, 3, 4},
|
||||
{"outlined_object", mf_outlined_object, 0, 0},
|
||||
{"proto_exists", mf_proto_exists, 1, 1},
|
||||
{"real_dude_obj", mf_real_dude_obj, 0, 0},
|
||||
{"remove_timer_event", mf_remove_timer_event, 0, 1},
|
||||
{"set_car_intface_art", mf_set_car_intface_art, 1, 1},
|
||||
|
||||
@@ -596,17 +596,6 @@ static void mf_get_loot_object() {
|
||||
opHandler.setReturn((GetLoopFlags() & INTFACELOOT) ? ptr_target_stack[*ptr_target_curr_stack] : 0);
|
||||
}
|
||||
|
||||
static void mf_proto_exists() {
|
||||
const ScriptValue &pidArg = opHandler.arg(0);
|
||||
|
||||
if (pidArg.isInt()) {
|
||||
opHandler.setReturn(CheckProtoID(pidArg.rawValue()));
|
||||
} else {
|
||||
OpcodeInvalidArgs("proto_exists");
|
||||
opHandler.setReturn(0);
|
||||
}
|
||||
}
|
||||
|
||||
static bool protoMaxLimitPatch = false;
|
||||
|
||||
static void __stdcall op_get_proto_data2() {
|
||||
@@ -614,10 +603,10 @@ static void __stdcall op_get_proto_data2() {
|
||||
&offsetArg = opHandler.arg(1);
|
||||
|
||||
if (pidArg.isInt() && offsetArg.isInt()) {
|
||||
long result = -1;
|
||||
sProto* protoPtr;
|
||||
int pid = pidArg.rawValue();
|
||||
int result = fo_proto_ptr(pid, &protoPtr);
|
||||
if (result != -1) {
|
||||
if (CheckProtoID(pid) && fo_proto_ptr(pid, &protoPtr) != result) {
|
||||
result = *(long*)((BYTE*)protoPtr + offsetArg.rawValue());
|
||||
} else {
|
||||
opHandler.printOpcodeError(protoFailedLoad, "get_proto_data", pid);
|
||||
@@ -641,7 +630,7 @@ static void __stdcall op_set_proto_data2() {
|
||||
if (pidArg.isInt() && offsetArg.isInt() && valueArg.isInt()) {
|
||||
sProto* protoPtr;
|
||||
int pid = pidArg.rawValue();
|
||||
if (fo_proto_ptr(pid, &protoPtr) != -1) {
|
||||
if (CheckProtoID(pid) && fo_proto_ptr(pid, &protoPtr) != -1) {
|
||||
*(long*)((BYTE*)protoPtr + offsetArg.rawValue()) = valueArg.rawValue();
|
||||
if (!protoMaxLimitPatch) {
|
||||
Objects_LoadProtoAutoMaxLimit();
|
||||
|
||||
Reference in New Issue
Block a user