summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-04-01 22:47:57 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2020-04-01 22:47:57 +0200
commitbd0cd13be1abab2b3001859c4af2f896c131a9c5 (patch)
tree7a1a30db196e34163a84400d30ac853028d7e605
parentMerge branch 'garages_dev' (diff)
parentAudioScriptObject finished (diff)
downloadre3-bd0cd13be1abab2b3001859c4af2f896c131a9c5.tar
re3-bd0cd13be1abab2b3001859c4af2f896c131a9c5.tar.gz
re3-bd0cd13be1abab2b3001859c4af2f896c131a9c5.tar.bz2
re3-bd0cd13be1abab2b3001859c4af2f896c131a9c5.tar.lz
re3-bd0cd13be1abab2b3001859c4af2f896c131a9c5.tar.xz
re3-bd0cd13be1abab2b3001859c4af2f896c131a9c5.tar.zst
re3-bd0cd13be1abab2b3001859c4af2f896c131a9c5.zip
-rw-r--r--src/audio/AudioScriptObject.cpp50
-rw-r--r--src/audio/AudioScriptObject.h251
2 files changed, 174 insertions, 127 deletions
diff --git a/src/audio/AudioScriptObject.cpp b/src/audio/AudioScriptObject.cpp
index b5093c52..0ae3834a 100644
--- a/src/audio/AudioScriptObject.cpp
+++ b/src/audio/AudioScriptObject.cpp
@@ -4,12 +4,10 @@
#include "Pools.h"
#include "DMAudio.h"
-WRAPPER void cAudioScriptObject::SaveAllAudioScriptObjects(uint8 *buf, uint32 *size) { EAXJMP(0x57c460); }
-
void
cAudioScriptObject::Reset()
{
- AudioId = 125;
+ AudioId = SCRSOUND_INVALID;
Posn = CVector(0.0f, 0.0f, 0.0f);
AudioEntity = AEHANDLE_NONE;
}
@@ -19,16 +17,19 @@ cAudioScriptObject::operator new(size_t sz)
{
return CPools::GetAudioScriptObjectPool()->New();
}
+
void *
cAudioScriptObject::operator new(size_t sz, int handle)
{
return CPools::GetAudioScriptObjectPool()->New(handle);
}
+
void
cAudioScriptObject::operator delete(void *p, size_t sz)
{
CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p);
}
+
void
cAudioScriptObject::operator delete(void *p, int handle)
{
@@ -36,6 +37,47 @@ cAudioScriptObject::operator delete(void *p, int handle)
}
void
+cAudioScriptObject::LoadAllAudioScriptObjects(uint8 *buf, uint32 size)
+{
+ INITSAVEBUF
+
+ CheckSaveHeader(buf, 'A', 'U', 'D', '\0', size - SAVE_HEADER_SIZE);
+
+ int32 pool_size = ReadSaveBuf<int32>(buf);
+ for (int32 i = 0; i < pool_size; i++) {
+ int handle = ReadSaveBuf<int32>(buf);
+ cAudioScriptObject *p = new(handle) cAudioScriptObject;
+ assert(p != nil);
+ *p = ReadSaveBuf<cAudioScriptObject>(buf);
+ p->AudioEntity = DMAudio.CreateLoopingScriptObject(p);
+ }
+
+ VALIDATESAVEBUF(size);
+}
+
+void
+cAudioScriptObject::SaveAllAudioScriptObjects(uint8 *buf, uint32 *size)
+{
+ INITSAVEBUF
+
+ int32 pool_size = CPools::GetAudioScriptObjectPool()->GetNoOfUsedSpaces();
+ *size = SAVE_HEADER_SIZE + pool_size * (sizeof(cAudioScriptObject) + sizeof(int32));
+ WriteSaveHeader(buf, 'A', 'U', 'D', '\0', *size - SAVE_HEADER_SIZE);
+ WriteSaveBuf(buf, pool_size);
+
+ int32 i = CPools::GetAudioScriptObjectPool()->GetSize();
+ while (i--) {
+ cAudioScriptObject *p = CPools::GetAudioScriptObjectPool()->GetSlot(i);
+ if (p != nil) {
+ WriteSaveBuf(buf, CPools::GetAudioScriptObjectPool()->GetIndex(p));
+ WriteSaveBuf(buf, *p);
+ }
+ }
+
+ VALIDATESAVEBUF(*size);
+}
+
+void
PlayOneShotScriptObject(uint8 id, CVector const &pos)
{
cAudioScriptObject *audioScriptObject = new cAudioScriptObject();
@@ -48,4 +90,6 @@ PlayOneShotScriptObject(uint8 id, CVector const &pos)
STARTPATCHES
InjectHook(0x57C430, &cAudioScriptObject::Reset, PATCH_JUMP);
InjectHook(0x57C5F0, &PlayOneShotScriptObject, PATCH_JUMP);
+InjectHook(0x57C560, &cAudioScriptObject::LoadAllAudioScriptObjects, PATCH_JUMP);
+InjectHook(0x57c460, &cAudioScriptObject::SaveAllAudioScriptObjects, PATCH_JUMP);
ENDPATCHES \ No newline at end of file
diff --git a/src/audio/AudioScriptObject.h b/src/audio/AudioScriptObject.h
index 1db19865..4308faee 100644
--- a/src/audio/AudioScriptObject.h
+++ b/src/audio/AudioScriptObject.h
@@ -2,130 +2,132 @@
enum
{
- SCRSOUND_TEST_1 = 0,
- _SCRSOUND_UNK_1 = 1,
- _SCRSOUND_UNK_2 = 2,
- _SCRSOUND_UNK_3 = 3,
- _SCRSOUND_CLUB_1_S = 4,
- _SCRSOUND_CLUB_1_L = 5,
- _SCRSOUND_CLUB_2_S = 6,
- _SCRSOUND_CLUB_2_L = 7,
- _SCRSOUND_CLUB_3_S = 8,
- _SCRSOUND_CLUB_3_L = 9,
- _SCRSOUND_CLUB_4_S = 10,
- _SCRSOUND_CLUB_4_L = 11,
- _SCRSOUND_CLUB_5_S = 12,
- _SCRSOUND_CLUB_5_L = 13,
- _SCRSOUND_CLUB_6_S = 14,
- _SCRSOUND_CLUB_6_L = 15,
- _SCRSOUND_CLUB_7_S = 16,
- _SCRSOUND_CLUB_7_L = 17,
- _SCRSOUND_CLUB_8_S = 18,
- _SCRSOUND_CLUB_8_L = 19,
- _SCRSOUND_CLUB_9_S = 20,
- _SCRSOUND_CLUB_9_L = 21,
- _SCRSOUND_CLUB_10_S = 22,
- _SCRSOUND_CLUB_10_L = 23,
- _SCRSOUND_CLUB_11_S = 24,
- _SCRSOUND_CLUB_11_L = 25,
- _SCRSOUND_CLUB_12_S = 26,
- _SCRSOUND_CLUB_12_L = 27,
- _SCRSOUND_CLUB_RAGGA_S = 28,
- _SCRSOUND_CLUB_RAGGA_L = 29,
- SCRSOUND_STRIP_CLUB_LOOP_1_S = 30,
- _SCRSOUND_STRIP_CLUB_LOOP_1_L = 31,
- SCRSOUND_STRIP_CLUB_LOOP_2_S = 32,
- _SCRSOUND_STRIP_CLUB_LOOP_2_L = 33,
- _SCRSOUND_SFX_WORKSHOP_1 = 34,
- _SCRSOUND_SFX_WORKSHOP_2 = 35,
- _SCRSOUND_SAWMILL_LOOP_S = 36,
- SCRSOUND_SAWMILL_LOOP_L = 37,
- _SCRSOUND_DOG_FOOD_FACTORY_S = 38,
- _SCRSOUND_DOG_FOOD_FACTORY_L = 39,
- _SCRSOUND_LAUNDERETTE_1 = 40,
- _SCRSOUND_LAUNDERETTE_2 = 41,
- _SCRSOUND_RESTAURANT_CHINATOWN_S = 42,
- _SCRSOUND_RESTAURANT_CHINATOWN_L = 43,
- _SCRSOUND_RESTAURANT_ITALY_S = 44,
- _SCRSOUND_RESTAURANT_ITALY_L = 45,
- _SCRSOUND_RESTAURANT_GENERIC_1_S = 46,
- _SCRSOUND_RESTAURANT_GENERIC_1_L = 47,
- _SCRSOUND_RESTAURANT_GENERIC_2_S = 48,
- _SCRSOUND_RESTAURANT_GENERIC_2_L = 49,
- _SCRSOUND_AIRPORT_ANNOUNCEMENT_S = 50,
- _SCRSOUND_AIRPORT_ANNOUNCEMENT_L = 51,
- _SCRSOUND_SHOP_LOOP_1 = 52,
- _SCRSOUND_SHOP_LOOP_2 = 53,
- _SCRSOUND_CINEMA_S = 54,
- _SCRSOUND_CINEMA_L = 55,
- _SCRSOUND_DOCKS_FOGHORN_S = 56,
- _SCRSOUND_DOCKS_FOGHORN_L = 57,
- _SCRSOUND_HOME_S = 58,
- _SCRSOUND_HOME_L = 59,
- _SCRSOUND_PIANO_BAR = 60,
- _SCRSOUND_CLUB = 61,
- SCRSOUND_PORN_CINEMA_1_S = 62,
- _SCRSOUND_PORN_CINEMA_1_L = 63,
- SCRSOUND_PORN_CINEMA_2_S = 64,
- _SCRSOUND_PORN_CINEMA_2_L = 65,
- SCRSOUND_PORN_CINEMA_3_S = 66,
- _SCRSOUND_PORN_CINEMA_3_L = 67,
- _SCRSOUND_BANK_ALARM_LOOP_S = 68,
- SCRSOUND_BANK_ALARM_LOOP_L = 69,
- _SCRSOUND_POLICE_BALL_LOOP_S = 70,
- SCRSOUND_POLICE_BALL_LOOP_L = 71,
- _SCRSOUND_RAVE_LOOP_INDUSTRIAL_S = 72,
- SCRSOUND_RAVE_LOOP_INDUSTRIAL_L = 73,
- _SCRSOUND_UNK_74 = 74,
- _SCRSOUND_UNK_75 = 75,
- _SCRSOUND_POLICE_CELL_BEATING_LOOP_S = 76,
- SCRSOUND_POLICE_CELL_BEATING_LOOP_L = 77,
- SCRSOUND_INJURED_PED_MALE_OUCH_S = 78,
- SCRSOUND_INJURED_PED_MALE_OUCH_L = 79,
- SCRSOUND_INJURED_PED_FEMALE_OUCH_S = 80,
- SCRSOUND_INJURED_PED_FEMALE_OUCH_L = 81,
- SCRSOUND_EVIDENCE_PICKUP = 82,
- SCRSOUND_UNLOAD_GOLD = 83,
- _SCRSOUND_RAVE_INDUSTRIAL_S = 84,
- _SCRSOUND_RAVE_INDUSTRIAL_L = 85,
- _SCRSOUND_RAVE_COMMERCIAL_S = 86,
- _SCRSOUND_RAVE_COMMERCIAL_L = 87,
- _SCRSOUND_RAVE_SUBURBAN_S = 88,
- _SCRSOUND_RAVE_SUBURBAN_L = 89,
- _SCRSOUND_GROAN_S = 90,
- _SCRSOUND_GROAN_L = 91,
- SCRSOUND_GATE_START_CLUNK = 92,
- SCRSOUND_GATE_STOP_CLUNK = 93,
- SCRSOUND_PART_MISSION_COMPLETE = 94,
- SCRSOUND_CHUNKY_RUN_SHOUT = 95,
- SCRSOUND_SECURITY_GUARD_RUN_AWAY_SHOUT = 96,
- SCRSOUND_RACE_START_1 = 97,
- SCRSOUND_RACE_START_2 = 98,
- SCRSOUND_RACE_START_3 = 99,
- SCRSOUND_RACE_START_GO = 100,
- SCRSOUND_SWAT_PED_SHOUT = 101,
- SCRSOUND_PRETEND_FIRE_LOOP = 102,
- SCRSOUND_AMMUNATION_CHAT_1 = 103,
- SCRSOUND_AMMUNATION_CHAT_2 = 104,
- SCRSOUND_AMMUNATION_CHAT_3 = 105,
- _SCRSOUND_BULLET_WALL_1 = 106,
- _SCRSOUND_BULLET_WALL_2 = 107,
- _SCRSOUND_BULLET_WALL_3 = 108,
- _SCRSOUND_UNK_109 = 109,
- _SCRSOUND_GLASSFX2_1 = 110,
- _SCRSOUND_GLASSFX2_2 = 111,
- _SCRSOUND_PHONE_RING = 112,
- _SCRSOUND_UNK_113 = 113,
- _SCRSOUND_GLASS_SMASH_1 = 114,
- _SCRSOUND_GLASS_SMASH_2 = 115,
- _SCRSOUND_GLASS_CRACK = 116,
- _SCRSOUND_GLASS_SHARD = 117,
- _SCRSOUND_WOODEN_BOX_SMASH = 118,
- _SCRSOUND_CARDBOARD_BOX_SMASH = 119,
- _SCRSOUND_COL_CAR = 120,
- _SCRSOUND_TYRE_BUMP = 121,
- _SCRSOUND_BULLET_SHELL_HIT_GROUND_1 = 122,
- _SCRSOUND_BULLET_SHELL_HIT_GROUND_2 = 123,
+ SCRSOUND_TEST_1,
+ _SCRSOUND_UNK_1,
+ _SCRSOUND_UNK_2,
+ _SCRSOUND_UNK_3,
+ _SCRSOUND_CLUB_1_S,
+ _SCRSOUND_CLUB_1_L,
+ _SCRSOUND_CLUB_2_S,
+ _SCRSOUND_CLUB_2_L,
+ _SCRSOUND_CLUB_3_S,
+ _SCRSOUND_CLUB_3_L,
+ _SCRSOUND_CLUB_4_S,
+ _SCRSOUND_CLUB_4_L,
+ _SCRSOUND_CLUB_5_S,
+ _SCRSOUND_CLUB_5_L,
+ _SCRSOUND_CLUB_6_S,
+ _SCRSOUND_CLUB_6_L,
+ _SCRSOUND_CLUB_7_S,
+ _SCRSOUND_CLUB_7_L,
+ _SCRSOUND_CLUB_8_S,
+ _SCRSOUND_CLUB_8_L,
+ _SCRSOUND_CLUB_9_S,
+ _SCRSOUND_CLUB_9_L,
+ _SCRSOUND_CLUB_10_S,
+ _SCRSOUND_CLUB_10_L,
+ _SCRSOUND_CLUB_11_S,
+ _SCRSOUND_CLUB_11_L,
+ _SCRSOUND_CLUB_12_S,
+ _SCRSOUND_CLUB_12_L,
+ _SCRSOUND_CLUB_RAGGA_S,
+ _SCRSOUND_CLUB_RAGGA_L,
+ SCRSOUND_STRIP_CLUB_LOOP_1_S,
+ _SCRSOUND_STRIP_CLUB_LOOP_1_L,
+ SCRSOUND_STRIP_CLUB_LOOP_2_S,
+ _SCRSOUND_STRIP_CLUB_LOOP_2_L,
+ _SCRSOUND_SFX_WORKSHOP_1,
+ _SCRSOUND_SFX_WORKSHOP_2,
+ _SCRSOUND_SAWMILL_LOOP_S,
+ SCRSOUND_SAWMILL_LOOP_L,
+ _SCRSOUND_DOG_FOOD_FACTORY_S,
+ _SCRSOUND_DOG_FOOD_FACTORY_L,
+ _SCRSOUND_LAUNDERETTE_1,
+ _SCRSOUND_LAUNDERETTE_2,
+ _SCRSOUND_RESTAURANT_CHINATOWN_S,
+ _SCRSOUND_RESTAURANT_CHINATOWN_L,
+ _SCRSOUND_RESTAURANT_ITALY_S,
+ _SCRSOUND_RESTAURANT_ITALY_L,
+ _SCRSOUND_RESTAURANT_GENERIC_1_S,
+ _SCRSOUND_RESTAURANT_GENERIC_1_L,
+ _SCRSOUND_RESTAURANT_GENERIC_2_S,
+ _SCRSOUND_RESTAURANT_GENERIC_2_L,
+ _SCRSOUND_AIRPORT_ANNOUNCEMENT_S,
+ _SCRSOUND_AIRPORT_ANNOUNCEMENT_L,
+ _SCRSOUND_SHOP_LOOP_1,
+ _SCRSOUND_SHOP_LOOP_2,
+ _SCRSOUND_CINEMA_S,
+ _SCRSOUND_CINEMA_L,
+ _SCRSOUND_DOCKS_FOGHORN_S,
+ _SCRSOUND_DOCKS_FOGHORN_L,
+ _SCRSOUND_HOME_S,
+ _SCRSOUND_HOME_L,
+ _SCRSOUND_PIANO_BAR,
+ _SCRSOUND_CLUB,
+ SCRSOUND_PORN_CINEMA_1_S,
+ _SCRSOUND_PORN_CINEMA_1_L,
+ SCRSOUND_PORN_CINEMA_2_S,
+ _SCRSOUND_PORN_CINEMA_2_L,
+ SCRSOUND_PORN_CINEMA_3_S,
+ _SCRSOUND_PORN_CINEMA_3_L,
+ _SCRSOUND_BANK_ALARM_LOOP_S,
+ SCRSOUND_BANK_ALARM_LOOP_L,
+ _SCRSOUND_POLICE_BALL_LOOP_S,
+ SCRSOUND_POLICE_BALL_LOOP_L,
+ _SCRSOUND_RAVE_LOOP_INDUSTRIAL_S,
+ SCRSOUND_RAVE_LOOP_INDUSTRIAL_L,
+ _SCRSOUND_UNK_74,
+ _SCRSOUND_UNK_75,
+ _SCRSOUND_POLICE_CELL_BEATING_LOOP_S,
+ SCRSOUND_POLICE_CELL_BEATING_LOOP_L,
+ SCRSOUND_INJURED_PED_MALE_OUCH_S,
+ SCRSOUND_INJURED_PED_MALE_OUCH_L,
+ SCRSOUND_INJURED_PED_FEMALE_OUCH_S,
+ SCRSOUND_INJURED_PED_FEMALE_OUCH_L,
+ SCRSOUND_EVIDENCE_PICKUP,
+ SCRSOUND_UNLOAD_GOLD,
+ _SCRSOUND_RAVE_INDUSTRIAL_S,
+ _SCRSOUND_RAVE_INDUSTRIAL_L,
+ _SCRSOUND_RAVE_COMMERCIAL_S,
+ _SCRSOUND_RAVE_COMMERCIAL_L,
+ _SCRSOUND_RAVE_SUBURBAN_S,
+ _SCRSOUND_RAVE_SUBURBAN_L,
+ _SCRSOUND_GROAN_S,
+ _SCRSOUND_GROAN_L,
+ SCRSOUND_GATE_START_CLUNK,
+ SCRSOUND_GATE_STOP_CLUNK,
+ SCRSOUND_PART_MISSION_COMPLETE,
+ SCRSOUND_CHUNKY_RUN_SHOUT,
+ SCRSOUND_SECURITY_GUARD_RUN_AWAY_SHOUT,
+ SCRSOUND_RACE_START_1,
+ SCRSOUND_RACE_START_2,
+ SCRSOUND_RACE_START_3,
+ SCRSOUND_RACE_START_GO,
+ SCRSOUND_SWAT_PED_SHOUT,
+ SCRSOUND_PRETEND_FIRE_LOOP,
+ SCRSOUND_AMMUNATION_CHAT_1,
+ SCRSOUND_AMMUNATION_CHAT_2,
+ SCRSOUND_AMMUNATION_CHAT_3,
+ _SCRSOUND_BULLET_WALL_1,
+ _SCRSOUND_BULLET_WALL_2,
+ _SCRSOUND_BULLET_WALL_3,
+ _SCRSOUND_UNK_109,
+ _SCRSOUND_GLASSFX2_1,
+ _SCRSOUND_GLASSFX2_2,
+ _SCRSOUND_PHONE_RING,
+ _SCRSOUND_UNK_113,
+ _SCRSOUND_GLASS_SMASH_1,
+ _SCRSOUND_GLASS_SMASH_2,
+ _SCRSOUND_GLASS_CRACK,
+ _SCRSOUND_GLASS_SHARD,
+ _SCRSOUND_WOODEN_BOX_SMASH,
+ _SCRSOUND_CARDBOARD_BOX_SMASH,
+ _SCRSOUND_COL_CAR,
+ _SCRSOUND_TYRE_BUMP,
+ _SCRSOUND_BULLET_SHELL_HIT_GROUND_1,
+ _SCRSOUND_BULLET_SHELL_HIT_GROUND_2,
+ TOTAL_SCRSOUNDS,
+ SCRSOUND_INVALID
};
class cAudioScriptObject
@@ -142,6 +144,7 @@ public:
static void operator delete(void*, size_t);
static void operator delete(void*, int);
+ static void LoadAllAudioScriptObjects(uint8 *buf, uint32 size);
static void SaveAllAudioScriptObjects(uint8 *buf, uint32 *size);
};