Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: remove sim player auto-join #27

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@ extern "C" int64_t __pfnDliFailureHook2 = 0;
#pragma comment(lib, "../SDK/Lib/SymDBHelper.lib")
#pragma comment(lib, "../SDK/Lib/LiteLoader.lib")

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call,
LPVOID lpReserved) {
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
LL::registerPlugin(
PLUGIN_NAME, PLUGIN_INTRODUCTION,
LL::Version(PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR,
PLUGIN_VERSION_REVISION, PLUGIN_LLVERSION_STATUS),
std::map<std::string, std::string>{
LL::registerPlugin(PLUGIN_NAME, PLUGIN_INTRODUCTION,
LL::Version(PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR,
PLUGIN_VERSION_REVISION, PLUGIN_LLVERSION_STATUS),
std::map<std::string, std::string>{
#ifdef PLUGIN_AUTHOR
{"Author", PLUGIN_AUTHOR},
{"Author", PLUGIN_AUTHOR},
#endif // PLUGIN_AUTHOR
//{ "Key", "Value" }
});
});
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
Expand Down
2 changes: 1 addition & 1 deletion src/functions/Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ namespace trapdoor {

void subscribeServerStartEvent() {
Event::ServerStartedEvent::subscribe([&](const Event::ServerStartedEvent& ev) {
trapdoor::mod().getSimPlayerManager().addPlayersInCache();
// trapdoor::mod().getSimPlayerManager().addPlayersInCache();
return true;
});

Expand Down
6 changes: 3 additions & 3 deletions src/functions/HopperCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace trapdoor {
}
}

ActionResult HopperChannelManager::quickModifyChannel(Player * player, const BlockPos &pos,
ActionResult HopperChannelManager::quickModifyChannel(Player *player, const BlockPos &pos,
int opt) {
if (!player) return ErrorPlayerNeed();
auto &bs = player->getRegion();
Expand Down Expand Up @@ -125,9 +125,9 @@ THook(void, "?setItem@HopperBlockActor@@UEAAXHAEBVItemStack@@@Z", void *self, un
return;
}

// get PointPOsition
// get Point Position
auto &pos = ba.getPosition();
// try get player
// try to get player
Player *nearest = nullptr;

try {
Expand Down
2 changes: 1 addition & 1 deletion src/functions/InfoDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace trapdoor {
.sTextF(trapdoor::TextBuilder::GREEN, "%d / %d\n", b.getId(), b.getRuntimeId())
.text(" - Variant: ")
.sTextF(trapdoor::TextBuilder::GREEN, "%d\n", b.getVariant())
.text(" - CanInstatick: ")
.text(" - CanInstanceTick: ")
.sTextF(trapdoor::TextBuilder::GREEN, "%d\n", b.canInstatick())
.text(" - BlockEntity: ")
.sTextF(trapdoor::TextBuilder::GREEN, "%d\n", b.hasBlockEntity())
Expand Down
8 changes: 4 additions & 4 deletions src/functions/MCTick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace trapdoor {
namespace {

// In-file varilable;
// In-file variablle;

TickingInfo &getTickingInfo() {
static TickingInfo info;
Expand All @@ -36,7 +36,7 @@ namespace trapdoor {

} // namespace

// Command Aciton
// Command Action

ActionResult queryWorld() {
auto &info = getTickingInfo();
Expand Down Expand Up @@ -147,7 +147,7 @@ namespace trapdoor {
return {"Profiling can only be performed in normal tick state", false};
}
if (normalProfiler().profiling) {
return {"Another profileing is running", false};
return {"Another profiling is running", false};
} else {
normalProfiler().start(rounds, type);
return {"Profile Start", true};
Expand Down Expand Up @@ -381,7 +381,7 @@ THook(void, "?processPendingAdds@CircuitSceneGraph@@AEAAXXZ", void *c) {
}
}

// pemding remove
// pending remove
THook(void, "?removeComponent@CircuitSceneGraph@@AEAAXAEBVBlockPos@@@Z", void *c, void *pos) {
auto &prof = trapdoor::normalProfiler();
if (prof.profiling) {
Expand Down
2 changes: 1 addition & 1 deletion src/functions/SimPlayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ namespace trapdoor {
auto y = value["y"].get<float>();
auto z = value["z"].get<float>();
this->addPlayer(name, {x, y, z}, dim, nullptr);
trapdoor::logger().info("Spawn sim player [{}] at {},{},{} in dim {}", name, x, y,
trapdoor::logger().warn("Spawn sim player [{}] at {},{},{} in dim {}", name, x, y,
z, dim);
// tempConfig.enable = value["enable"].get<bool>();
}
Expand Down
8 changes: 4 additions & 4 deletions src/functions/SimpleProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ namespace trapdoor {
/*
ServerLevel::tick
- Redstone
- Dimension::tickRedstone(shouldUpdate,cacueValue,evaluate)
- Dimension::tickRedstone(shouldUpdate,cacheValue,evaluate)
- pendingUpdate
- pendinnRemove
- pendingRemove
- pendingAdd
- Dimension::tick(chunk load/village)
- entitySystem
- Lvevl::tick
- Level::tick
- LevelChunk::Tick
- blockEnties
- blockEntities
- randomChunk
- Actor::tick(non global)
*/
Expand Down
16 changes: 16 additions & 0 deletions src/functions/Tweakers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,19 @@ THook(void, "?updateNeighborsAt@BlockSource@@QEAAXAEBVBlockPos@@@Z", void *self,
original(self, pos);
}
}

// #include <MC/Player.hpp>
// THook(void,
// "?_tickLevelChunksAroundActor@LevelChunkTickingSystem@@CAXAEAVActor@@AEAVBlockSource@@"
// "AEAVLoadedChunksComponent@@@Z",
// Actor *actor, BlockSource *bs, void *comp) {
// if (actor) {
// trapdoor::logger().debug("Actor name is {} {} {}",
// reinterpret_cast<Player *>(actor)->getRealName(), (void *)bs,
// comp);
// } else {
// trapdoor::logger().debug("Actor is null");
// }
//
// original(actor, bs, comp);
// }
6 changes: 3 additions & 3 deletions src/include/CommandHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Created by xhy on 2022/5/17.
//

#ifndef TRAPDOOR_COMMANDHELPER_H
#define TRAPDOOR_COMMANDHELPER_H
#ifndef TRAPDOOR_COMMAND_HELPER_H
#define TRAPDOOR_COMMAND_HELPER_H

//clang-format off

Expand Down Expand Up @@ -72,4 +72,4 @@ namespace trapdoor {

} // namespace trapdoor

#endif // TRAPDOOR_COMMANDHELPER_H
#endif // TRAPDOOR_COMMAND_HELPER_H
10 changes: 5 additions & 5 deletions src/include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ namespace trapdoor {
std::string simPlayerPrefix;
};

struct DefaultEnableFunctions {
bool blockRotate = false;
bool hopperCounter = false;
bool hud = false;
};
// struct DefaultEnableFunctions {
// bool blockRotate = false;
// bool hopperCounter = false;
// bool hud = false;
// };

struct TweakConfig {
int forcePlaceLevel = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/include/DistanceHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Created by xhy on 2022/7/19.
//

#ifndef TRAPDOOR_DISTANCEHELPER_H
#define TRAPDOOR_DISTANCEHELPER_H
#ifndef TRAPDOOR_DISTANCE_HELPER_H
#define TRAPDOOR_DISTANCE_HELPER_H
#include <MC/Player.hpp>

#include "CommandHelper.h"
Expand All @@ -15,4 +15,4 @@ namespace trapdoor {

} // namespace trapdoor

#endif // TRAPDOOR_DISTANCEHELPER_H
#endif // TRAPDOOR_DISTANCE_HELPER_H
6 changes: 3 additions & 3 deletions src/include/EventTrigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Created by xhy on 2022/8/12.
//

#ifndef TRAPDOOR_EVENTTRIGGER_H
#define TRAPDOOR_EVENTTRIGGER_H
#ifndef TRAPDOOR_EVENT_TRIGGER_H
#define TRAPDOOR_EVENT_TRIGGER_H
#include <unordered_map>
#include <unordered_set>

Expand Down Expand Up @@ -36,4 +36,4 @@ namespace trapdoor {
} // namespace trapdoor

class EventTrigger {};
#endif // TRAPDOOR_EVENTTRIGGER_H
#endif // TRAPDOOR_EVENT_TRIGGER_H
4 changes: 2 additions & 2 deletions src/include/HUDHelper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef TRAPDOOR_MINIHUD_HELPER_H
#define TRAPDOOR_MINIHUD_HELPER_H
#ifndef TRAPDOOR_HUD_HELPER_H
#define TRAPDOOR_HUD_HELPER_H
#include <array>
#include <unordered_map>

Expand Down
10 changes: 5 additions & 5 deletions src/include/InventoryTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Created by xhy on 2022/6/29.
//

#ifndef TRAPDOOR_INVENTORYTOOL_H
#define TRAPDOOR_INVENTORYTOOL_H
#ifndef TRAPDOOR_INVENTORY_TOOL_H
#define TRAPDOOR_INVENTORY_TOOL_H
#include <MC/BlockInstance.hpp>
#include <MC/Inventory.hpp>
#include <MC/Player.hpp>
namespace trapdoor {
bool onStartDestroyBlock(Player * player, const BlockInstance &instance);
bool onStartDestroyBlock(Player *player, const BlockInstance &instance);

void swapItemInContainer(Container & cont, int s1, int s2);
void swapItemInContainer(Container &cont, int s1, int s2);

} // namespace trapdoor

#endif // TRAPDOOR_INVENTORYTOOL_H
#endif // TRAPDOOR_INVENTORY_TOOL_H
13 changes: 8 additions & 5 deletions src/include/Msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Created by xhy on 2020/8/24.
//

#ifndef TRAPDOOR_MSGBUILDER_H
#define TRAPDOOR_MSGBUILDER_H
#ifndef TRAPDOOR_MSG_BUILDER_H
#define TRAPDOOR_MSG_BUILDER_H

#include <cstdarg>
#include <map>
Expand All @@ -19,7 +19,7 @@
#define PH_GREEN "§a{}§r"
#define PH_AQUA "§b{}§r"
#define PH_BLUE "§9{}§r"
#define PH_LIGHT_PURLPE "§d{}§r"
#define PH_LIGHT_PURPLE "§d{}§r"
#define PH_WHITE "§f{}§r"
#define PH_GRAY "§7{}§r"
#define PH_DOUB "§f{:.3lf}§r"
Expand Down Expand Up @@ -80,7 +80,10 @@ namespace trapdoor {
return *this;
}

inline TextBuilder &endl() { this->messageBuffer.emplace_back("\n"); }
inline TextBuilder &endl() {
this->messageBuffer.emplace_back("\n");
return *this;
}

TextBuilder &sText(uint8_t style, const std::string &s);

Expand Down Expand Up @@ -120,4 +123,4 @@ namespace trapdoor {

typedef TextBuilder TB;
} // namespace trapdoor
#endif // TRAPDOOR_MSGBUILDER_H
#endif // TRAPDOOR_MSG_BUILDER_H
8 changes: 4 additions & 4 deletions src/include/SimpleProfiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ namespace trapdoor {
/*
ServerLevel::tick
- Redstone
- Dimension::tickRedstone(shouldUpdate,cacueValue,evaluate)
- Dimension::tickRedstone(shouldUpdate,cacheValue,evaluate)
- pendingUpdate
- pendinnRemove
- pendingRemove
- pendingAdd
- Dimension::tick(chunk load/village)
- entitySystem
- Lvevl::tick
- Level::tick
- LevelChunk::Tick
- blockEnties
- blockEntities
- randomChunk
- Actor::tick(non global)
*/
Expand Down
6 changes: 3 additions & 3 deletions src/include/SpawnHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ namespace trapdoor {
#pragma pack(pop)

ActionResult printCap(const ActorDefinitionIdentifier *id);
ActionResult countActors(Player * p, const std::string &type);
ActionResult countActors(Player *p, const std::string &type);

ActionResult printSpawnProbability(Player * player, const BlockPos &pos);
ActionResult printSpawnProbability(Player *player, const BlockPos &pos);

ActionResult forceSpawn(Player * p, const ActorDefinitionIdentifier *id, const BlockPos &pos);
ActionResult forceSpawn(Player *p, const ActorDefinitionIdentifier *id, const BlockPos &pos);

class SpawnHelper {
std::vector<BlockPos> verticalSpawnPositions;
Expand Down