From ca99fc0ad25c62d56bb061b268b26e67bccf4aea Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sun, 19 Jun 2022 14:32:00 +0300 Subject: [PATCH] Cleanup proto_instance.h See #42 --- src/proto_instance.cc | 61 +++++++++++++++++++++++++++++-------------- src/proto_instance.h | 22 ---------------- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/proto_instance.cc b/src/proto_instance.cc index 44cf7df..23bcde3 100644 --- a/src/proto_instance.cc +++ b/src/proto_instance.cc @@ -13,6 +13,7 @@ #include "interface.h" #include "item.h" #include "map.h" +#include "message.h" #include "object.h" #include "palette.h" #include "perk.h" @@ -30,8 +31,28 @@ #include #include +static int _obj_remove_from_inven(Object* critter, Object* item); +static int _obj_use_book(Object* item_obj); +static int _obj_use_flare(Object* critter_obj, Object* item_obj); +static int _obj_use_radio(Object* item_obj); +static int _obj_use_explosive(Object* explosive); +static int _obj_use_power_on_car(Object* ammo); +static int _obj_use_misc_item(Object* item_obj); +static int _protinstTestDroppedExplosive(Object* a1); +static int _protinst_default_use_item(Object* a1, Object* a2, Object* item); +static int useLadderDown(Object* a1, Object* ladder, int a3); +static int useLadderUp(Object* a1, Object* ladder, int a3); +static int useStairs(Object* a1, Object* stairs, int a3); +static int _set_door_state_open(Object* a1, Object* a2); +static int _set_door_state_closed(Object* a1, Object* a2); +static int _check_door_state(Object* a1, Object* a2); +static bool _obj_is_lockable(Object* obj); +static bool _obj_is_openable(Object* obj); +static int objectOpenClose(Object* obj); +static bool objectIsJammed(Object* obj); + // 0x49A990 -MessageListItem stru_49A990; +static MessageListItem stru_49A990; // 0x49A9A0 int _obj_sid(Object* object, int* sidPtr) @@ -569,7 +590,7 @@ int _obj_pickup(Object* critter, Object* item) } // 0x49B73C -int _obj_remove_from_inven(Object* critter, Object* item) +static int _obj_remove_from_inven(Object* critter, Object* item) { Rect updatedRect; int fid; @@ -702,7 +723,7 @@ int _obj_destroy(Object* obj) // Read a book. // // 0x49B9F0 -int _obj_use_book(Object* book) +static int _obj_use_book(Object* book) { MessageListItem messageListItem; @@ -790,7 +811,7 @@ int _obj_use_book(Object* book) // Light a flare. // // 0x49BBA8 -int _obj_use_flare(Object* critter_obj, Object* flare) +static int _obj_use_flare(Object* critter_obj, Object* flare) { MessageListItem messageListItem; @@ -825,7 +846,7 @@ int _obj_use_flare(Object* critter_obj, Object* flare) } // 0x49BC60 -int _obj_use_radio(Object* item) +static int _obj_use_radio(Object* item) { Script* scr; @@ -844,7 +865,7 @@ int _obj_use_radio(Object* item) } // 0x49BCB4 -int _obj_use_explosive(Object* explosive) +static int _obj_use_explosive(Object* explosive) { MessageListItem messageListItem; @@ -913,7 +934,7 @@ int _obj_use_explosive(Object* explosive) // Returns 1 when car is recharged. // // 0x49BDE8 -int _obj_use_power_on_car(Object* item) +static int _obj_use_power_on_car(Object* item) { MessageListItem messageListItem; int messageNum; @@ -961,7 +982,7 @@ int _obj_use_power_on_car(Object* item) } // 0x49BE88 -int _obj_use_misc_item(Object* item) +static int _obj_use_misc_item(Object* item) { if (item == NULL) { @@ -1052,7 +1073,7 @@ int _protinst_use_item(Object* critter, Object* item) } // 0x49BFE8 -int _protinstTestDroppedExplosive(Object* a1) +static int _protinstTestDroppedExplosive(Object* a1) { if (a1->pid == PROTO_ID_DYNAMITE_II || a1->pid == PROTO_ID_PLASTIC_EXPLOSIVES_II) { Attack attack; @@ -1136,7 +1157,7 @@ int _obj_use_item(Object* a1, Object* a2) } // 0x49C240 -int _protinst_default_use_item(Object* a1, Object* a2, Object* item) +static int _protinst_default_use_item(Object* a1, Object* a2, Object* item) { char formattedText[90]; MessageListItem messageListItem; @@ -1475,7 +1496,7 @@ int _obj_use(Object* a1, Object* a2) } // 0x49C900 -int useLadderDown(Object* a1, Object* ladder, int a3) +static int useLadderDown(Object* a1, Object* ladder, int a3) { int builtTile = ladder->data.scenery.ladder.field_4; if (builtTile == -1) { @@ -1509,7 +1530,7 @@ int useLadderDown(Object* a1, Object* ladder, int a3) } // 0x49C9A4 -int useLadderUp(Object* a1, Object* ladder, int a3) +static int useLadderUp(Object* a1, Object* ladder, int a3) { int builtTile = ladder->data.scenery.ladder.field_4; if (builtTile == -1) { @@ -1543,7 +1564,7 @@ int useLadderUp(Object* a1, Object* ladder, int a3) } // 0x49CA48 -int useStairs(Object* a1, Object* stairs, int a3) +static int useStairs(Object* a1, Object* stairs, int a3) { int builtTile = stairs->data.scenery.stairs.field_4; if (builtTile == -1) { @@ -1577,21 +1598,21 @@ int useStairs(Object* a1, Object* stairs, int a3) } // 0x49CAF4 -int _set_door_state_open(Object* a1, Object* a2) +static int _set_door_state_open(Object* a1, Object* a2) { a1->data.scenery.door.openFlags |= 0x01; return 0; } // 0x49CB04 -int _set_door_state_closed(Object* a1, Object* a2) +static int _set_door_state_closed(Object* a1, Object* a2) { a1->data.scenery.door.openFlags &= ~0x01; return 0; } // 0x49CB14 -int _check_door_state(Object* a1, Object* a2) +static int _check_door_state(Object* a1, Object* a2) { if ((a1->data.scenery.door.openFlags & 0x01) == 0) { a1->flags &= ~OBJECT_OPEN_DOOR; @@ -1869,7 +1890,7 @@ int _obj_use_skill_on(Object* source, Object* target, int skill) } // 0x49D178 -bool _obj_is_lockable(Object* obj) +static bool _obj_is_lockable(Object* obj) { Proto* proto; @@ -1956,7 +1977,7 @@ int objectUnlock(Object* object) } // 0x49D294 -bool _obj_is_openable(Object* obj) +static bool _obj_is_openable(Object* obj) { Proto* proto; @@ -1991,7 +2012,7 @@ int objectIsOpen(Object* object) } // 0x49D2F4 -int objectOpenClose(Object* obj) +static int objectOpenClose(Object* obj) { if (obj == NULL) { return -1; @@ -2052,7 +2073,7 @@ int objectClose(Object* obj) } // 0x49D410 -bool objectIsJammed(Object* obj) +static bool objectIsJammed(Object* obj) { if (!_obj_is_lockable(obj)) { return false; diff --git a/src/proto_instance.h b/src/proto_instance.h index a7af363..b1c40ac 100644 --- a/src/proto_instance.h +++ b/src/proto_instance.h @@ -1,11 +1,8 @@ #ifndef PROTOTYPE_INSTANCES_H #define PROTOTYPE_INSTANCES_H -#include "message.h" #include "obj_types.h" -extern MessageListItem stru_49A990; - int _obj_sid(Object* object, int* sidPtr); int _obj_new_sid(Object* object, int* sidPtr); int _obj_new_sid_inst(Object* obj, int a2, int a3); @@ -14,42 +11,23 @@ int _obj_look_at_func(Object* a1, Object* a2, void (*a3)(char* string)); int _obj_examine(Object* a1, Object* a2); int _obj_examine_func(Object* critter, Object* target, void (*fn)(char* string)); int _obj_pickup(Object* critter, Object* item); -int _obj_remove_from_inven(Object* critter, Object* item); int _obj_drop(Object* a1, Object* a2); int _obj_destroy(Object* obj); -int _obj_use_book(Object* item_obj); -int _obj_use_flare(Object* critter_obj, Object* item_obj); -int _obj_use_radio(Object* item_obj); -int _obj_use_explosive(Object* explosive); -int _obj_use_power_on_car(Object* ammo); -int _obj_use_misc_item(Object* item_obj); int _protinst_use_item(Object* a1, Object* a2); -int _protinstTestDroppedExplosive(Object* a1); int _obj_use_item(Object* a1, Object* a2); -int _protinst_default_use_item(Object* a1, Object* a2, Object* item); int _protinst_use_item_on(Object* a1, Object* a2, Object* item); int _obj_use_item_on(Object* a1, Object* a2, Object* a3); int _check_scenery_ap_cost(Object* obj, Object* a2); int _obj_use(Object* a1, Object* a2); -int useLadderDown(Object* a1, Object* ladder, int a3); -int useLadderUp(Object* a1, Object* ladder, int a3); -int useStairs(Object* a1, Object* stairs, int a3); -int _set_door_state_open(Object* a1, Object* a2); -int _set_door_state_closed(Object* a1, Object* a2); -int _check_door_state(Object* a1, Object* a2); int _obj_use_door(Object* a1, Object* a2, int a3); int _obj_use_container(Object* critter, Object* item); int _obj_use_skill_on(Object* a1, Object* a2, int skill); -bool _obj_is_lockable(Object* obj); bool objectIsLocked(Object* obj); int objectLock(Object* obj); int objectUnlock(Object* obj); -bool _obj_is_openable(Object* obj); int objectIsOpen(Object* obj); -int objectOpenClose(Object* obj); int objectOpen(Object* obj); int objectClose(Object* obj); -bool objectIsJammed(Object* obj); int objectJamLock(Object* obj); int objectUnjamLock(Object* obj); int objectUnjamAll();