mirror of
https://github.com/SMGCommunity/Petari.git
synced 2024-11-30 08:50:43 +00:00
Some JMap, and so a little connectToScene decomp
This commit is contained in:
parent
5c77de0dd7
commit
00b48a8f17
@ -5,6 +5,7 @@ class NameObj;
|
||||
|
||||
namespace MR
|
||||
{
|
||||
void registerNameObjToExecuteHolder(NameObj *, s32, s32, s32, s32);
|
||||
void connectToSceneTemporarily(NameObj *);
|
||||
void disconnectToSceneTemporarily(NameObj *);
|
||||
void connectToDrawTemporarily(NameObj *);
|
||||
|
@ -1,12 +0,0 @@
|
||||
#ifndef HASH_H
|
||||
#define HASH_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
class JGadget
|
||||
{
|
||||
public:
|
||||
u16 getHashCode(const char *);
|
||||
};
|
||||
|
||||
#endif // HASH_H
|
11
include/JGadget/hashcode.h
Normal file
11
include/JGadget/hashcode.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef HASHCODE_H
|
||||
#define HASHCODE_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
namespace JGadget
|
||||
{
|
||||
u16 getHashCode(const char *);
|
||||
};
|
||||
|
||||
#endif // HASHCODE_H
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "bcsv.h"
|
||||
#include "types.h"
|
||||
|
||||
class JMapInfo
|
||||
@ -14,6 +15,6 @@ public:
|
||||
s32 searchItemInfo(const char *) const;
|
||||
char getValueType(const char *) const;
|
||||
|
||||
const void* mMap;
|
||||
const BCSVHeader* mMap;
|
||||
const char* mName;
|
||||
};
|
@ -1,12 +1,26 @@
|
||||
#ifndef OBJUTIL_H
|
||||
#define OBJUTIL_H
|
||||
|
||||
#include "Actor/LiveActor/LiveActor.h"
|
||||
#include "Actor/NameObj/NameObj.h"
|
||||
#include "System/Resource/ResourceHolder.h"
|
||||
|
||||
namespace MR
|
||||
{
|
||||
void connectToScene(LiveActor *, s32, s32, s32, s32);
|
||||
void connectToScene(NameObj *, s32, s32, s32, s32);
|
||||
void connectToSceneCollisionMapObj(LiveActor *);
|
||||
void connectToSceneCollisionMapObjMovementCalcAnim(LiveActor *);
|
||||
void connectToSceneCollisionMapObjWeakLight(LiveActor *);
|
||||
void connectToSceneCollisionMapObjStrongLight(LiveActor *);
|
||||
void connectToSceneCollisionEnemy(LiveActor *);
|
||||
void connectToSceneCollisionEnemyMovement(NameObj *);
|
||||
void connectToSceneCollisionEnemyStrongLight(LiveActor *);
|
||||
void connectToSceneCollisionEnemyNoShadowedMapObjStrongLight(LiveActor *actor);
|
||||
void connectToSceneNpc(LiveActor *);
|
||||
void connectToSceneNpcMovement(LiveActor *);
|
||||
void connectToSceneRide(LiveActor *);
|
||||
void connectToSceneEnemy(LiveActor *);
|
||||
|
||||
void requestMovementOn(NameObj *);
|
||||
void requestMovementOff(NameObj *);
|
||||
|
24
include/bcsv.h
Normal file
24
include/bcsv.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef BCSV_H
|
||||
#define BCSV_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
struct BCSVEntry
|
||||
{
|
||||
u32 mNameHash;
|
||||
u32 mMask;
|
||||
u16 mDataOffs;
|
||||
u8 mShift;
|
||||
u8 mField;
|
||||
};
|
||||
|
||||
struct BCSVHeader
|
||||
{
|
||||
u32 mEntryCount;
|
||||
u32 mFieldCount;
|
||||
u32 mDataOffs;
|
||||
u32 mEntrySize;
|
||||
BCSVEntry** mEntries;
|
||||
};
|
||||
|
||||
#endif // BCSV_H
|
@ -1,6 +1,5 @@
|
||||
#include "JMap/JMapInfo.h"
|
||||
|
||||
#include "JGadget/hash.h"
|
||||
#include "JGadget/hashcode.h"
|
||||
|
||||
JMapInfo::JMapInfo()
|
||||
{
|
||||
@ -18,7 +17,7 @@ bool JMapInfo::attach(const void *src)
|
||||
if (src == 0)
|
||||
return 0;
|
||||
|
||||
this->mMap = src;
|
||||
this->mMap = (BCSVHeader*)src;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -30,4 +29,52 @@ void JMapInfo::setName(const char *name)
|
||||
const char* JMapInfo::getName() const
|
||||
{
|
||||
return this->mName;
|
||||
}
|
||||
|
||||
// this will yield the same results, but does not match
|
||||
// TODO -- change this
|
||||
s32 JMapInfo::searchItemInfo(const char *name) const
|
||||
{
|
||||
u32 fieldCount;
|
||||
|
||||
const BCSVHeader* header = this->mMap;
|
||||
|
||||
if (header == 0x0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (header != 0)
|
||||
{
|
||||
fieldCount = header->mFieldCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldCount = 0;
|
||||
}
|
||||
|
||||
u16 argHashCode = (u32)JGadget::getHashCode(name);
|
||||
s32 curIdx = 0;
|
||||
|
||||
// we loop until we find our index based on the given string
|
||||
// if not, we return -1
|
||||
if (0 < fieldCount)
|
||||
{
|
||||
while(fieldCount != 0)
|
||||
{
|
||||
BCSVEntry* entry = this->mMap->mEntries[curIdx];
|
||||
|
||||
if (entry->mNameHash == argHashCode)
|
||||
{
|
||||
return curIdx;
|
||||
}
|
||||
|
||||
curIdx++;
|
||||
fieldCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
79
source/MR/ObjUtil.cpp
Normal file
79
source/MR/ObjUtil.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
#include "MR/ObjUtil.h"
|
||||
#include "Actor/NameObj/NameObjExecuteHolder.h"
|
||||
|
||||
namespace MR
|
||||
{
|
||||
void connectToScene(LiveActor *actor, s32 movementType, s32 calcAnimType, s32 drawBufType, s32 drawType)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, movementType, calcAnimType, drawBufType, drawType);
|
||||
}
|
||||
|
||||
void connectToScene(NameObj *actor, s32 movementType, s32 calcAnimType, s32 drawBufType, s32 drawType)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, movementType, calcAnimType, drawBufType, drawType);
|
||||
MR::connectToSceneTemporarily(actor);
|
||||
MR::connectToDrawTemporarily(actor);
|
||||
}
|
||||
|
||||
void connectToSceneCollisionMapObj(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x1E, 2, 8, -1);
|
||||
}
|
||||
|
||||
void connectToSceneCollisionMapObjMovementCalcAnim(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x1E, 2, -1, -1);
|
||||
}
|
||||
|
||||
void connectToSceneCollisionMapObjWeakLight(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x1E, 2, 9, -1);
|
||||
}
|
||||
|
||||
void connectToSceneCollisionMapObjStrongLight(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x1E, 2, 0xA, -1);
|
||||
}
|
||||
|
||||
void connectToSceneCollisionEnemy(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x1F, 3, 0x12, -1);
|
||||
}
|
||||
|
||||
void connectToSceneCollisionEnemyMovement(NameObj *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x1F, -1, -1, -1);
|
||||
MR::connectToSceneTemporarily(actor);
|
||||
MR::connectToDrawTemporarily(actor);
|
||||
}
|
||||
|
||||
void connectToSceneCollisionEnemyStrongLight(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x1F, 3, 0xA, -1);
|
||||
}
|
||||
|
||||
void connectToSceneCollisionEnemyNoShadowedMapObjStrongLight(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x1F, 3, 0xC, -1);
|
||||
}
|
||||
|
||||
void connectToSceneNpc(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x28, 6, 0x10, -1);
|
||||
}
|
||||
|
||||
void connectToSceneNpcMovement(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x28, -1, -1, -1);
|
||||
}
|
||||
|
||||
void connectToSceneRide(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x29, 7, 0x11, -1);
|
||||
}
|
||||
|
||||
void connectToSceneEnemy(LiveActor *actor)
|
||||
{
|
||||
MR::registerNameObjToExecuteHolder(actor, 0x2A, 8, 0x12, -1);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user