Skip to content

Commit

Permalink
[debug menu] new: show own player info on first players page
Browse files Browse the repository at this point in the history
  • Loading branch information
Istador committed May 29, 2024
1 parent 45306e1 commit 4af309b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
6 changes: 6 additions & 0 deletions include/server/Client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ class Client {
// public for debug purposes
SocketClient *mSocket;

PlayerInf* getLastPlayerInfPacket() { return &this->lastPlayerInfPacket; }
GameInf* getLastGameInfPacket() { return &this->lastGameInfPacket; }
CostumeInf* getLastCostumeInfPacket() { return &this->lastCostumeInfPacket; }
TagInf* getLastTagInfPacket() { return &this->lastTagInfPacket; }
CaptureInf* getLastCaptureInfPacket() { return &this->lastCaptureInfPacket; }

private:
void updatePlayerInfo(PlayerInf *packet);
void updateHackCapInfo(HackCapInf *packet);
Expand Down
35 changes: 27 additions & 8 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ void drawMainHook(HakoniwaSequence *curSequence, sead::Viewport *viewport, sead:

PlayerActorBase* playerBase = rs::getPlayerActor(curScene);

PuppetActor* curPuppet = Client::getPuppet(debugPuppetIndex);

PuppetActor* curPuppet = Client::getPuppet(debugPuppetIndex - 1);
PuppetActor *debugPuppet = Client::getDebugPuppet();
if (debugPuppet) {
curPuppet = debugPuppet;
Expand All @@ -173,12 +172,29 @@ void drawMainHook(HakoniwaSequence *curSequence, sead::Viewport *viewport, sead:
"(ZL ←)----------%s Player %d/%d %s-----------(ZL →)\n\n",
debugPuppetIndex + 1 < 10 ? "-" : "",
debugPuppetIndex + 1,
Client::getMaxPlayerCount() - 1,
Client::getMaxPlayerCount() - 1 < 10 ? "-" : ""
Client::getMaxPlayerCount(),
Client::getMaxPlayerCount() < 10 ? "-" : ""
);

if(curPuppet) {
if (debugPuppetIndex == 0) {
gTextWriter->printf("Player Name: %s\n", Client::getClientName());
gTextWriter->printf("Connection Status: %s\n", isConnected ? "Online" : "Offline");
gTextWriter->printf("Is in same Stage: Yes\n");
gTextWriter->printf("Stage: %s\n", client->getLastGameInfPacket()->stageName);
gTextWriter->printf("Scenario: %u\n", client->getLastGameInfPacket()->scenarioNo);
gTextWriter->printf("Costume: H: %s B: %s\n", client->getLastCostumeInfPacket()->capModel, client->getLastCostumeInfPacket()->bodyModel);
gTextWriter->printf("Capture: %s\n", client->getLastCaptureInfPacket()->hackName);

PlayerHackKeeper* hackKeeper = playerBase->getPlayerHackKeeper();
if (hackKeeper) {
PlayerActorHakoniwa *p1 = (PlayerActorHakoniwa*)playerBase;
if (hackKeeper->currentHackActor) {
gTextWriter->printf("Animation: %s\n", al::getActionName(hackKeeper->currentHackActor));
} else {
gTextWriter->printf("Animation: %s\n", p1->mPlayerAnimator->mAnimFrameCtrl->getActionName());
}
}
} else if (curPuppet) {
al::LiveActor* curModel = curPuppet->getCurrentModel();

PuppetInfo* curPupInfo = curPuppet->getInfo();
Expand Down Expand Up @@ -267,6 +283,8 @@ void drawMainHook(HakoniwaSequence *curSequence, sead::Viewport *viewport, sead:
if (curPuppet) {
renderer->drawSphere4x8(curPuppet->getInfo()->playerPos, 20, sead::Color4f(1.f, 0.f, 0.f, 0.25f));
renderer->drawSphere4x8(al::getTrans(curPuppet), 20, sead::Color4f(0.f, 0.f, 1.f, 0.25f));
} else if (debugPuppetIndex == 0) {
renderer->drawSphere4x8(client->getLastPlayerInfPacket()->playerPos, 20, sead::Color4f(1.f, 0.f, 0.f, 0.25f));
}

renderer->end();
Expand Down Expand Up @@ -383,11 +401,12 @@ bool hakoniwaSequenceHook(HakoniwaSequence* sequence) {
if (al::isPadTriggerLeft(-1)) debugPuppetIndex--;
if (al::isPadTriggerRight(-1)) debugPuppetIndex++;

if(debugPuppetIndex < 0) {
debugPuppetIndex = Client::getMaxPlayerCount() - 2;
if (debugPuppetIndex < 0) {
debugPuppetIndex = Client::getMaxPlayerCount() - 1;
}
if (debugPuppetIndex >= Client::getMaxPlayerCount() - 1)
if (debugPuppetIndex >= Client::getMaxPlayerCount()) {
debugPuppetIndex = 0;
}
}

} else if (al::isPadHoldL(-1)) {
Expand Down
3 changes: 3 additions & 0 deletions source/server/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,9 @@ bool Client::tryAddDebugPuppet(PuppetActor *puppet) {
* @return PuppetActor*
*/
PuppetActor *Client::getPuppet(int idx) {
if (idx < 0) {
return nullptr;
}
if(sInstance) {
return sInstance->mPuppetHolder->getPuppetActor(idx);
}else {
Expand Down

0 comments on commit 4af309b

Please sign in to comment.