Skip to content

Commit 2a512fe

Browse files
authored
Bunch of fixes of mismatches & improved symbols database (#41)
1 parent eecd273 commit 2a512fe

11 files changed

Lines changed: 190 additions & 158 deletions

File tree

data/mcswitch_functions.csv

Lines changed: 77 additions & 77 deletions
Large diffs are not rendered by default.

src/Minecraft.Client/ui/scene/control/UIControl_List.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22

33
UIControl_List::UIControl_List() : UIControl_Base() {}
44

5+
// NON_MATCHING: idk, the for loop is constructed weirdly
6+
UIControl_List::~UIControl_List() {
7+
for (GenericPendingUpdate* update : mGenericPendingUpdates) {
8+
delete update;
9+
}
10+
}
11+
512
void UIControl_List::addElement(eUIControlType type, int id) {
613
if (id < 0)
714
id = this->mListSize;
815

916
this->mListSize += 1;
1017

11-
this->mUIControlsTypes[int(id)] = type;
12-
this->mUIControlsStates[int(id)] = true;
18+
this->mUIControlsTypes[id] = type;
19+
this->mUIControlsStates[id] = true;
1320

1421
this->mUIControlIDs.push_back(id);
1522
}

src/Minecraft.Client/ui/scene/control/UIControl_List.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ class UIControl_List : public UIControl_Base {
77
public:
88
class GenericPendingUpdate {
99
public:
10+
virtual void nullsub_795();
11+
virtual ~GenericPendingUpdate();
12+
virtual void virtual_void_0() = 0;
1013
};
1114

1215
UIControl_List();
16+
~UIControl_List();
1317

1418
void addElement(eUIControlType, int);
1519
void init(int);
@@ -19,6 +23,6 @@ class UIControl_List : public UIControl_Base {
1923
std::vector<int> mUIControlIDs;
2024
int dword98 = 0;
2125
int mListSize = 0;
22-
std::unordered_map<int, eUIControlType> mUIControlsTypes;
23-
std::unordered_map<int, bool> mUIControlsStates;
26+
std::unordered_map<unsigned int, eUIControlType> mUIControlsTypes;
27+
std::unordered_map<unsigned int, bool> mUIControlsStates;
2428
};

src/Minecraft.Nbt/ListTag.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ ListTag::ListTag() {}
99

1010
ListTag::ListTag(int id) : mTagId(id) {}
1111

12-
// NON_MATCHING: Missing block of assembly in the mData loop
1312
void ListTag::write(DataOutput* outputStream) {
14-
if (mData.size() < 1) {
15-
mTagId = mData[0]->getId();
16-
} else {
13+
if (mData.empty()) {
1714
mTagId = TAG_End;
15+
} else {
16+
mTagId = mData[0]->getId();
1817
}
1918

2019
outputStream->writeByte(mTagId);
20+
outputStream->writeInt(this->mData.size());
2121

22-
for (auto& tag : mData) {
22+
for (auto tag : mData) {
2323
tag->write(outputStream);
2424
}
2525
}
@@ -78,13 +78,14 @@ bool ListTag::equals(Tag* other) {
7878
return true;
7979
}
8080

81-
// NON_MATCHING: b.eq vs b.hs in std for loop
8281
Tag* ListTag::copy() {
8382
ListTag* copy = new ListTag(0);
8483
copy->mTagId = mTagId;
8584

86-
for (auto& tag : mData) {
87-
copy->mData.push_back(tag->copy());
85+
for (auto&& tag : mData) {
86+
Tag* copied = tag->copy(); // you either do this or modify vector code, because for whatever
87+
// reason push_back(value_type&& __x) has different comparision
88+
copy->mData.push_back(copied);
8889
}
8990

9091
return copy;

src/Minecraft.Network/protocol/game/GetInfoPacket.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
#include "Minecraft.Network/PacketListener.h"
44

5-
// NON_MATCHING: Needs to set mCreatedTime and mShouldDelay to 0
65
std::shared_ptr<Packet> GetInfoPacket::create() {
76
return std::shared_ptr<Packet>(new GetInfoPacket());
87
}
98

10-
GetInfoPacket::GetInfoPacket() {}
11-
129
EPacketType GetInfoPacket::getPacketId() {
1310
return EPacketType::_GetInfoPacket;
1411
}

src/Minecraft.Network/protocol/game/GetInfoPacket.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ class GetInfoPacket : public Packet, public std::enable_shared_from_this<GetInfo
66
public:
77
static std::shared_ptr<Packet> create();
88

9-
GetInfoPacket();
109
virtual EPacketType getPacketId() override;
1110
virtual void read(DataInputStream* input) override;
1211
virtual void write(DataOutputStream* output) override;

src/Minecraft.World/level/Level.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "Minecraft.Client/platform/NX/Platform.h"
22
#include "Minecraft.World/entity/Entity.h"
3+
#include "Minecraft.World/entity/player/Player.h"
34
#include "Minecraft.World/level/Level.h"
45
#include "Minecraft.World/level/LevelListener.h"
56
#include "Minecraft.World/level/LevelType.h"
@@ -15,6 +16,7 @@
1516
#include "Minecraft.World/level/storage/LevelData.h"
1617
#include "Minecraft.World/level/storage/LevelStorage.h"
1718
#include "Minecraft.Core/System.h"
19+
#include <memory>
1820

1921
Level::Level(std::shared_ptr<LevelStorage> levelStorage, LevelData* levelData, Dimension* dimension,
2022
bool isLocal) {
@@ -189,22 +191,20 @@ void Level::levelEvent(int eventType, const BlockPos& pos, int data) {
189191
levelEvent(nullptr, eventType, pos, data);
190192
}
191193

192-
// NON_MATCHING
193194
void Level::levelEvent(std::shared_ptr<Player> player, int eventType, const BlockPos& pos, int data) {
194-
for (auto it = mLevelListeners.begin(); it != mLevelListeners.end(); ++it) {
195-
(*it)->levelEvent(player, eventType, pos, data);
195+
for (LevelListener* listener : this->mLevelListeners) {
196+
listener->levelEvent(player, eventType, pos, data);
196197
}
197198
}
198199

199200
void Level::setBlockAndUpdate(const BlockPos& pos, const BlockState* state) {
200201
setBlock(pos, state, 3, false);
201202
}
202203

203-
// NON_MATCHING
204204
void Level::sendBlockUpdated(const BlockPos& pos, const BlockState* state, const BlockState* state2, int id,
205205
bool unk) {
206-
for (auto it = mLevelListeners.begin(); it != mLevelListeners.end(); it++) {
207-
(*it)->blockChanged(this, pos, state, state2, id, unk);
206+
for (LevelListener* listener : this->mLevelListeners) {
207+
listener->blockChanged(this, pos, state, state2, id, unk);
208208
}
209209
}
210210

@@ -241,7 +241,6 @@ void Level::lightColumnChanged(int x, int z, int y0, int y1) {
241241
PIXEndNamedEvent();
242242
}
243243

244-
// NON_MATCHING: This should call a thunk
245244
void Level::neighborChanged(const BlockPos& pos, Block* block, const BlockPos& neighborPos) {
246245
if (!mIsLocal) {
247246
getBlockState(pos)->neighborChanged(this, pos, block, neighborPos);
@@ -427,36 +426,34 @@ bool Level::addGlobalEntity(std::shared_ptr<Entity> entity) {
427426
return true;
428427
}
429428

430-
// NON_MATCHING
431429
void Level::entityAdded(std::shared_ptr<Entity> entity) {
432-
for (auto it = mLevelListeners.begin(); it != mLevelListeners.end(); ++it) {
433-
(*it)->entityAdded(entity);
430+
for (LevelListener* listener : this->mLevelListeners) {
431+
listener->entityAdded(entity);
434432
}
435433
}
436434

437-
// NON_MATCHING
438435
void Level::entityRemoved(std::shared_ptr<Entity> entity) {
439-
for (auto it = mLevelListeners.begin(); it != mLevelListeners.end(); ++it) {
440-
(*it)->entityRemoved(entity);
436+
for (LevelListener* listener : this->mLevelListeners) {
437+
listener->entityRemoved(entity);
441438
}
442439
}
443440

444-
// NON_MATCHING
445441
void Level::playerRemoved(std::shared_ptr<Entity> entity) {
446-
for (auto it = mLevelListeners.begin(); it != mLevelListeners.end(); ++it) {
447-
(*it)->playerRemoved(entity);
442+
for (LevelListener* listener : this->mLevelListeners) {
443+
listener->playerRemoved(entity);
448444
}
449445
}
450446

451447
void Level::addListener(LevelListener* listener) {
452448
mLevelListeners.push_back(listener);
453449
}
454450

455-
// NON_MATCHING
456451
void Level::removeListener(LevelListener* listener) {
457-
auto it = mLevelListeners.begin();
458-
if (it != mLevelListeners.end()) {
459-
mLevelListeners.erase(it, mLevelListeners.end());
452+
for (auto it = this->mLevelListeners.begin(); it != this->mLevelListeners.end(); it++) {
453+
if (listener == *it) {
454+
this->mLevelListeners.erase(it);
455+
return;
456+
}
460457
}
461458
}
462459

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
#pragma once
22

3-
class BlockBehaviours {};
3+
#include "Minecraft.Core/BlockPos.h"
4+
class Level;
5+
class Block;
6+
7+
class BlockBehaviours {
8+
public:
9+
virtual void triggerEvent(Level*, const BlockPos&, int, int) const = 0;
10+
virtual void neighborChanged(Level*, const BlockPos&, Block*, const BlockPos&) const = 0;
11+
};
Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,65 @@
11
#pragma once
22

3-
class BlockProperties {};
3+
#include "Minecraft.World/level/block/RenderShape.h"
4+
#include "Minecraft.World/level/block/boxed/TypedBoxed.h"
5+
#include "Minecraft.World/level/block/state/BlockBehaviours.h"
6+
7+
class Entity;
8+
class BlockPos;
9+
class LevelSource;
10+
class Rotation;
11+
class Mirror;
12+
class Level;
13+
class Direction;
14+
class Property;
15+
class Vec3;
16+
class Boxed;
17+
class Block;
18+
class Player;
19+
class AABB;
20+
class Material;
21+
class MaterialColor;
22+
class BlockState;
23+
24+
class BlockProperties {
25+
public:
26+
virtual Material* getMaterial() const = 0;
27+
virtual bool isSolid() const = 0;
28+
virtual bool isValidSpawn(std::shared_ptr<Entity>) const = 0;
29+
virtual int getLightBlock() const = 0;
30+
virtual void getLightEmission() const = 0;
31+
virtual bool isTranslucent() const = 0;
32+
virtual bool doesPropagate() const = 0;
33+
virtual MaterialColor* getMapColor(LevelSource*, const BlockPos&) = 0;
34+
virtual void rotate(Rotation*) const = 0;
35+
virtual void mirror(Mirror*) const = 0;
36+
virtual bool isCubeShaped() const = 0;
37+
virtual void hasCustomBreakingProgress() const = 0;
38+
virtual RenderShape getRenderShape() const = 0;
39+
virtual void getLightColor(LevelSource*, const BlockPos&) const = 0;
40+
virtual float getShadeBrightness() const = 0;
41+
virtual bool isSolidBlockingCube() const = 0;
42+
virtual bool isSolidBlockingCubeAndNotSignalSource() const = 0;
43+
virtual bool isSignalSource() const = 0;
44+
virtual void getSignal(LevelSource*, const BlockPos&, const Direction*) const = 0;
45+
virtual void hasAnalogOutputSignal() const = 0;
46+
virtual void getAnalogOutputSignal(Level*, const BlockPos&) const = 0;
47+
virtual float getDestroySpeed(Level*, const BlockPos&) const = 0;
48+
virtual void getDestroyProgress(std::shared_ptr<Player>, Level*, const BlockPos&) const = 0;
49+
virtual int getDirectSignal(LevelSource*, const BlockPos&, const Direction*) const = 0;
50+
virtual void getPistonPushReaction() const = 0;
51+
virtual const BlockState* fillVirtualBlockStateProperties(LevelSource*, const BlockPos&) const = 0;
52+
virtual void getOutlineAABB(Level*, const BlockPos&) const = 0;
53+
virtual bool shouldRenderFace(LevelSource*, const BlockPos&, const Direction*) const = 0;
54+
virtual bool isSolidRender() const = 0;
55+
virtual AABB* getClipAABB(LevelSource*, const BlockPos&) const = 0;
56+
virtual void addCollissionAABBs(Level*, const BlockPos&, AABB const*, std::vector<AABB*>*,
57+
std::shared_ptr<Entity>, bool) const
58+
= 0;
59+
virtual AABB* getShape(LevelSource*, const BlockPos&) const = 0;
60+
virtual void clip(Level*, const BlockPos&, Vec3*, Vec3*) const = 0;
61+
virtual bool isTopSolidBlocking() const = 0;
62+
virtual void getOffset(LevelSource*, const BlockPos&) const = 0;
63+
virtual bool isViewBlocking() const = 0;
64+
virtual int getBlockFaceShape(LevelSource*, const BlockPos&, const Direction*) const = 0;
65+
};

src/Minecraft.World/level/block/state/BlockState.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <memory>
44

5-
#include "Minecraft.World/level/block/RenderShape.h"
65
#include "Minecraft.World/level/block/boxed/TypedBoxed.h"
76
#include "Minecraft.World/level/block/state/BlockBehaviours.h"
87
#include "Minecraft.World/level/block/state/BlockProperties.h"
@@ -25,45 +24,6 @@ class MaterialColor;
2524

2625
class BlockState : public BlockProperties, public BlockBehaviours {
2726
public:
28-
virtual Material* getMaterial() const = 0;
29-
virtual bool isSolid() const = 0;
30-
virtual bool isValidSpawn(std::shared_ptr<Entity>) const = 0;
31-
virtual int getLightBlock() const = 0;
32-
virtual void getLightEmission() const = 0;
33-
virtual bool isTranslucent() const = 0;
34-
virtual bool doesPropagate() const = 0;
35-
virtual MaterialColor* getMapColor(LevelSource*, const BlockPos&) = 0;
36-
virtual void rotate(Rotation*) const = 0;
37-
virtual void mirror(Mirror*) const = 0;
38-
virtual bool isCubeShaped() const = 0;
39-
virtual void hasCustomBreakingProgress() const = 0;
40-
virtual RenderShape getRenderShape() const = 0;
41-
virtual void getLightColor(LevelSource*, const BlockPos&) const = 0;
42-
virtual float getShadeBrightness() const = 0;
43-
virtual bool isSolidBlockingCube() const = 0;
44-
virtual bool isSolidBlockingCubeAndNotSignalSource() const = 0;
45-
virtual bool isSignalSource() const = 0;
46-
virtual void getSignal(LevelSource*, const BlockPos&, const Direction*) const = 0;
47-
virtual void hasAnalogOutputSignal() const = 0;
48-
virtual void getAnalogOutputSignal(Level*, const BlockPos&) const = 0;
49-
virtual float getDestroySpeed(Level*, const BlockPos&) const = 0;
50-
virtual void getDestroyProgress(std::shared_ptr<Player>, Level*, const BlockPos&) const = 0;
51-
virtual int getDirectSignal(LevelSource*, const BlockPos&, const Direction*) const = 0;
52-
virtual void getPistonPushReaction() const = 0;
53-
virtual const BlockState* fillVirtualBlockStateProperties(LevelSource*, const BlockPos&) const = 0;
54-
virtual void getOutlineAABB(Level*, const BlockPos&) const = 0;
55-
virtual bool shouldRenderFace(LevelSource*, const BlockPos&, const Direction*) const = 0;
56-
virtual bool isSolidRender() const = 0;
57-
virtual AABB* getClipAABB(LevelSource*, const BlockPos&) const = 0;
58-
virtual void addCollissionAABBs(Level*, const BlockPos&, AABB const*, std::vector<AABB*>*,
59-
std::shared_ptr<Entity>, bool) const
60-
= 0;
61-
virtual AABB* getShape(LevelSource*, const BlockPos&) const = 0;
62-
virtual void clip(Level*, const BlockPos&, Vec3*, Vec3*) const = 0;
63-
virtual bool isTopSolidBlocking() const = 0;
64-
virtual void getOffset(LevelSource*, const BlockPos&) const = 0;
65-
virtual bool isViewBlocking() const = 0;
66-
virtual int getBlockFaceShape(LevelSource*, const BlockPos&, const Direction*) const = 0;
6727
virtual void getProperties() const = 0;
6828
virtual void hasProperty(const Property*) const = 0;
6929
virtual Boxed* getBoxedValue(const Property*) const = 0;
@@ -74,8 +34,6 @@ class BlockState : public BlockProperties, public BlockBehaviours {
7434
virtual void toString() const = 0;
7535
virtual void equals(const BlockState*) = 0;
7636
virtual void hashCode() const = 0;
77-
virtual void triggerEvent(Level*, const BlockPos&, int, int) const = 0;
78-
virtual void neighborChanged(Level*, const BlockPos&, Block*, const BlockPos&) const = 0;
7937

8038
// NON_MATCHING: Decomp is using add sp, 0x8 instead of mov sp
8139
template <typename T>

0 commit comments

Comments
 (0)