Skip to content

Commit 9dfef1b

Browse files
DaDev123DaDev123
authored andcommitted
Added Speedboot AutoLoad function, fixed emulators randomly crashing
1 parent 8255543 commit 9dfef1b

16 files changed

Lines changed: 204 additions & 241 deletions

Makefile

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@
33

44
.PHONY: all clean starlight send
55

6+
7+
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
8+
GIT_COMMIT := $(shell git rev-parse --short HEAD)
9+
GIT_REV := ${GIT_BRANCH}-${GIT_COMMIT}
10+
ifneq (,$(strip $(shell git status --porcelain 2>/dev/null)))
11+
GIT_REV := $(GIT_REV)-dirty
12+
endif
13+
614
SMOVER ?= 100
7-
BUILDVER ?= 101
8-
BUILDVERSTR ?= 1.3.0
9-
IP ?= 192.168.0.9 # ftp server ip (usually is switch's local IP)
10-
DEBUGLOG ?= 1 # defaults to disable debug logger
11-
SERVERIP ?= 192.168.178.37 # put debug logger server IP here
15+
BUILDVER ?= 101
16+
BUILDVERSTR ?= 1.4.0
17+
IP ?= 10.0.0.221 # ftp server ip (usually is switch's local IP)
18+
DEBUGLOG ?= 0 # defaults to disable debug logger
19+
SERVERIP ?= 0.0.0.0 # put debug logger server IP here
1220
ISEMU ?= 0 # set to 1 to compile for emulators
1321

1422
PROJNAME ?= StarlightBase
@@ -33,26 +41,39 @@ starlight_patch_$(SMOVER)/*.ips: patches/*.slpatch patches/configs/$(SMOVER).con
3341
@rm -f starlight_patch_$(SMOVER)/*.ips
3442
python3 scripts/genPatch.py $(SMOVER)
3543

36-
# builds project with the file structure and flags used for emulators
44+
# builds project with the file structure for SMOO-Emulator
3745
emu:
3846
$(MAKE) all -f MakefileNSO SMOVER=$(SMOVER) BUILDVERSTR=$(BUILDVERSTR) BUILDVER=$(BUILDVER) EMU=1
3947
$(MAKE) starlight_patch_$(SMOVER)/*.ips
4048

41-
mkdir -p starlight_patch_$(SMOVER)/yuzu/
49+
@echo "Creating SMOO-Emulator folder structure inside starlight_patch_$(SMOVER)..."
50+
mkdir -p starlight_patch_$(SMOVER)/SMOO-Emulator/exefs/
51+
mkdir -p starlight_patch_$(SMOVER)/SMOO-Emulator/romfs/
52+
53+
# Move .ips file to exefs folder
54+
mv starlight_patch_$(SMOVER)/3CA12DFAAF9C82DA064D1698DF79CDA1.ips starlight_patch_$(SMOVER)/SMOO-Emulator/exefs/3CA12DFAAF9C82DA064D1698DF79CDA1.ips
55+
56+
# Move subsdk9 (nso file) to exefs folder
57+
mv $(shell basename $(CURDIR))$(SMOVER).nso starlight_patch_$(SMOVER)/SMOO-Emulator/exefs/subsdk9
58+
59+
# Copy romfs folder contents
60+
cp -R romfs/* starlight_patch_$(SMOVER)/SMOO-Emulator/romfs/ 2>/dev/null || true
61+
62+
# Clean up temporary files
63+
rm -f $(shell basename $(CURDIR))$(SMOVER).elf
64+
65+
@echo "SMOO-Emulator folder created successfully inside starlight_patch_$(SMOVER)!"
4266

43-
mv starlight_patch_$(SMOVER)/3CA12DFAAF9C82DA064D1698DF79CDA1.ips starlight_patch_$(SMOVER)/yuzu/3CA12DFAAF9C82DA064D1698DF79CDA1.ips
44-
mv $(shell basename $(CURDIR))$(SMOVER).elf starlight_patch_$(SMOVER)/subsdk1.elf
45-
mv $(shell basename $(CURDIR))$(SMOVER).nso starlight_patch_$(SMOVER)/yuzu/subsdk1
4667
# builds and sends project to FTP server hosted on provided IP
4768
send: all
48-
python3.8 scripts/sendPatch.py $(IP) $(PROJNAME)
69+
python3 scripts/sendPatch.py $(IP) $(PROJNAME)
4970

5071
log: all
51-
python3.8 scripts/tcpServer.py $(SERVERIP)
72+
python3 scripts/tcpServer.py $(SERVERIP)
5273

5374
sendlog: all
54-
python3.8 scripts/sendPatch.py $(IP) $(PROJNAME) $(USER) $(PASS)
55-
python3.8 scripts/tcpServer.py $(SERVERIP)
75+
python3 scripts/sendPatch.py $(IP) $(PROJNAME) $(USER) $(PASS)
76+
python3 scripts/tcpServer.py $(SERVERIP)
5677

5778
clean:
5879
$(MAKE) clean -f MakefileNSO

MakefileNSO

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,22 @@ include $(DEVKITPRO)/libnx/switch_rules
3232
#---------------------------------------------------------------------------------
3333
TARGET ?= $(notdir $(CURDIR))$(SMOVER)
3434
BUILD ?= build$(SMOVER)
35-
SOURCES := source/sead/time source/sead source/puppets source/speedboot source/server/hns source/server/snh source/server/freeze source/server/gamemode source/server/gamemode/modifiers source/server source/layouts source/states source/cameras source/nx source
35+
SOURCES := \
36+
source/sead/time \
37+
source/sead \
38+
source/puppets \
39+
source/speedboot \
40+
source/server/hns \
41+
source/server/snh \
42+
source/server/freeze \
43+
source/server/gamemode \
44+
source/server/gamemode/modifiers \
45+
source/server \
46+
source/layouts \
47+
source/states \
48+
source/cameras \
49+
source/nx \
50+
source
3651
SOURCES += source/al/execute
3752
DATA := data
3853
INCLUDES := include include/sead
@@ -47,7 +62,7 @@ CFLAGS := -g -Wall -ffunction-sections \
4762

4863
CFLAGS += $(INCLUDE) -D__SWITCH__ -DSMOVER=$(SMOVER) -O3 -DNNSDK -DSWITCH -DBUILDVERSTR=$(BUILDVERSTR) -DBUILDVER=$(BUILDVER) -DDEBUGLOG=$(DEBUGLOG) -DSERVERIP=$(SERVERIP) -DEMU=$(EMU)
4964

50-
CXXFLAGS := $(CFLAGS) -Wno-invalid-offsetof -Wno-volatile -fomit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables -std=gnu++20
65+
CXXFLAGS := $(CFLAGS) -Wno-invalid-offsetof -Wno-volatile -fno-rtti -fomit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables -std=gnu++20
5166

5267
ASFLAGS := -g $(ARCH)
5368
LDFLAGS = -specs=../switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--version-script=$(TOPDIR)/exported.txt -Wl,-init=__custom_init -Wl,-fini=__custom_fini -nostdlib
@@ -174,4 +189,4 @@ $(OFILES_SRC) : $(HFILES_BIN)
174189

175190
#---------------------------------------------------------------------------------------
176191
endif
177-
#---------------------------------------------------------------------------------------
192+
#---------------------------------------------------------------------------------------
701 Bytes
Binary file not shown.

exefs/subsdk1

334 KB
Binary file not shown.

include/packets/CostumeInf.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1+
12
#pragma once
23

34
#include "Packet.h"
45

5-
// Structure for sending/receiving costume information (Mod <-> Server)
66
struct PACKED CostumeInf : Packet {
7-
CostumeInf() : Packet() {
8-
this->mType = PacketType::COSTUMEINF;
9-
mPacketSize = sizeof(CostumeInf) - sizeof(Packet);
10-
}
7+
CostumeInf() : Packet() {this->mType = PacketType::COSTUMEINF; mPacketSize = sizeof(CostumeInf) - sizeof(Packet);};
118
CostumeInf(const char* body, const char* cap) : Packet() {
129
this->mType = PacketType::COSTUMEINF;
1310
mPacketSize = sizeof(CostumeInf) - sizeof(Packet);
14-
if (body)
15-
strncpy(bodyModel, body, COSTUMEBUFSIZE - 1);
16-
bodyModel[COSTUMEBUFSIZE - 1] = '\0';
17-
if (cap)
18-
strncpy(capModel, cap, COSTUMEBUFSIZE - 1);
19-
capModel[COSTUMEBUFSIZE - 1] = '\0';
11+
strcpy(bodyModel, body);
12+
strcpy(capModel, cap);
2013
}
2114
char bodyModel[COSTUMEBUFSIZE] = {};
2215
char capModel[COSTUMEBUFSIZE] = {};
23-
};
16+
};

include/server/Client.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ class Client {
231231
CustomMsg* mCustomMsgLayout;
232232
CustomMsg* getCustomMsg() const { return mCustomMsgLayout; }
233233

234+
static std::string BodyName;
235+
static std::string CapName;
236+
234237
private:
235238
void updatePlayerInfo(PlayerInf *packet);
236239
void updateHackCapInfo(HackCapInf *packet);
@@ -241,7 +244,6 @@ class Client {
241244
void updateCaptureInfo(CaptureInf* packet);
242245
void sendToStage(ChangeStagePacket* packet);
243246
void handleExtrasPacket(ExtrasPacket* curPacket);
244-
void handleCostumSend(CostumeInf* curPacket);
245247

246248
void disconnectPlayer(PlayerDC *packet);
247249

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
#include "al/nerve/Nerve.h"
4+
#include "al/nerve/NerveKeeper.h"
5+
#include "al/util/NerveUtil.h"
6+
#include "game/HakoniwaSequence/HakoniwaSequence.h"
7+
8+
NERVE_HEADER(HakoniwaSequence, LoadStage);
9+
NERVE_HEADER(HakoniwaSequence, LoadWorldResourceWithBoot);
10+
NERVE_IMPL(HakoniwaSequence, LoadStage);
11+
NERVE_IMPL(HakoniwaSequence, LoadWorldResourceWithBoot);
12+
13+
namespace speedboot {
14+
class CustomBootNerve : public al::Nerve {
15+
public:
16+
void execute(al::NerveKeeper* keeper) override {
17+
if (al::updateNerveState(keeper->mParent)) {
18+
al::setNerve(keeper->mParent, &nrvHakoniwaSequenceLoadStage);
19+
}
20+
}
21+
};
22+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#pragma once
2+
3+
#include "al/nerve/NerveStateBase.h"
4+
#include "al/util/NerveUtil.h"
5+
6+
#include "game/GameData/GameDataFunction.h"
7+
#include "game/HakoniwaSequence/HakoniwaSequence.h"
8+
9+
namespace speedboot {
10+
namespace {
11+
NERVE_HEADER(HakoniwaSequenceSpeedboot, InitThread)
12+
NERVE_HEADER(HakoniwaSequenceSpeedboot, LoadStage)
13+
NERVE_HEADER(HakoniwaSequenceSpeedboot, WipeToKill)
14+
}
15+
16+
struct HakoniwaSequenceSpeedboot : public al::NerveStateBase {
17+
public:
18+
HakoniwaSequenceSpeedboot(HakoniwaSequence* sequence) : al::NerveStateBase("Speedboot"), mSequence(sequence) {
19+
initNerve(&nrvHakoniwaSequenceSpeedbootLoadStage, 0);
20+
}
21+
22+
void exeInitThread() {
23+
if (al::isFirstStep(this)) {
24+
mSequence->mInitThread->start();
25+
}
26+
27+
if (mSequence->mInitThread->isDone()) {
28+
al::setNerve(this, &nrvHakoniwaSequenceSpeedbootLoadStage);
29+
}
30+
}
31+
32+
bool isDoneLoading() const {
33+
return mSequence->mResourceLoader->isEndLoadWorldResource()
34+
&& mSequence->mInitThread->isDone()
35+
;
36+
}
37+
38+
void exeLoadStage() {
39+
if (al::isFirstStep(this)) {
40+
mSequence->mInitThread->start();
41+
const char* name = GameDataFunction::getNextStageName(this->mSequence->mGameDataHolder);
42+
if (name == nullptr) {
43+
name = GameDataFunction::getMainStageName(this->mSequence->mGameDataHolder, 0);
44+
}
45+
int scenario = GameDataFunction::calcNextScenarioNo(this->mSequence->mGameDataHolder);
46+
if (scenario == -1) {
47+
scenario = 1;
48+
}
49+
int world = this->mSequence->mGameDataHolder.mData->mWorldList->tryFindWorldIndexByStageName(name);
50+
if (world > -1) {
51+
mSequence->mResourceLoader->requestLoadWorldHomeStageResource(world, scenario);
52+
}
53+
}
54+
55+
if (isDoneLoading()) {
56+
al::setNerve(this, &nrvHakoniwaSequenceSpeedbootWipeToKill);
57+
}
58+
}
59+
60+
void exeWipeToKill() {
61+
if (al::isFirstStep(this)) {
62+
mSequence->mWipeHolder->startClose("FadeWhite", -1);
63+
}
64+
65+
if (mSequence->mWipeHolder->isCloseEnd()) {
66+
kill();
67+
}
68+
}
69+
70+
private:
71+
HakoniwaSequence* mSequence;
72+
};
73+
74+
namespace {
75+
NERVE_IMPL(HakoniwaSequenceSpeedboot, InitThread);
76+
NERVE_IMPL(HakoniwaSequenceSpeedboot, LoadStage);
77+
NERVE_IMPL(HakoniwaSequenceSpeedboot, WipeToKill);
78+
}
79+
}

include/speedboot/SpeedbootLoad.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ class WorldResourceLoader;
77

88
class SpeedbootLoad : public al::LayoutActor {
99
public:
10-
SpeedbootLoad(WorldResourceLoader* resourceLoader, const al::LayoutInitInfo& initInfo);
10+
SpeedbootLoad(
11+
WorldResourceLoader* resourceLoader,
12+
const al::LayoutInitInfo& initInfo,
13+
float autoCloseAfter
14+
);
1115

1216
void exeAppear();
1317
void exeWait();

romfs/LayoutData/SpeedbootLoad.szs

4 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)