Skip to content

Commit

Permalink
Merge branch 'main' into overridefolder
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove committed Jun 28, 2024
2 parents c0938f2 + 92b3944 commit 2ba8ed9
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 12 deletions.
2 changes: 1 addition & 1 deletion skymp5-client/src/services/services/remoteServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ export class RemoteServer extends ClientListener {
return this.worldModel.playerCharacterFormIdx;
}

private getIdManager() {
getIdManager() {
return this.idManager_;
}

Expand Down
24 changes: 21 additions & 3 deletions skymp5-server/cpp/addon/ScampServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,12 @@ Napi::Value ScampServer::GetIdFromDesc(const Napi::CallbackInfo& info)

Napi::Value ScampServer::CallPapyrusFunction(const Napi::CallbackInfo& info)
{
// This function throws exceptions in case of bad input
// But it also catches exceptions from the Papyrus VM functions
// This is because
// 1) they're rare and unexpected, and we don't want to crash the sever
// 2) in Papyrus (not JS) we catch them all. so it's consistent
// 3) we plan replacing all exceptions with logs in Papyrus VM functions
try {
auto callType = NapiHelper::ExtractString(info[0], "callType");
auto className = NapiHelper::ExtractString(info[1], "className");
Expand All @@ -1045,15 +1051,27 @@ Napi::Value ScampServer::CallPapyrusFunction(const Napi::CallbackInfo& info)
auto& vm = partOne->worldState.GetPapyrusVm();
if (callType == "method") {
if (self.GetType() == VarValue::Type::kType_Object) {
res = vm.CallMethod(static_cast<IGameObject*>(self),
functionName.data(), args);
try {
res = vm.CallMethod(static_cast<IGameObject*>(self),
functionName.data(), args);
} catch (std::exception& e) {
res = VarValue::None();
spdlog::error("ScampServer::CallPapyrusFunction {} {} - {}",
self.ToString(), functionName, e.what());
}
} else {
throw std::runtime_error(
"Can't call Papyrus method on non-object self '" + self.ToString() +
"'");
}
} else if (callType == "global") {
res = vm.CallStatic(className, functionName, args);
try {
res = vm.CallStatic(className, functionName, args);
} catch (std::exception& e) {
res = VarValue::None();
spdlog::error("ScampServer::CallPapyrusFunction {} {} - {}", className,
functionName, e.what());
}
} else {
throw std::runtime_error("Unknown call type '" + callType +
"', expected one of ['method', 'global']");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,20 @@ VarValue PapyrusObjectReference::RemoveItem(

auto worldState = selfRefr->GetParent();
if (!worldState) {
throw std::runtime_error("RemoveItem - no WorldState attached");
spdlog::error("RemoveItem {:x} - no WorldState attached",
selfRefr->GetFormId());
return VarValue::None();
}

if (!selfRefr || !item.rec)
return VarValue::None();

if (!espm::utils::Is<espm::FLST>(item.rec->GetType())) {
if (!espm::utils::IsItem(item.rec->GetType())) {
throw std::runtime_error("RemoveItem - form is not an item");
spdlog::error("RemoveItem {:x} - form {:x} is not an item, it is {}",
selfRefr->GetFormId(), item.ToGlobalId(item.rec->GetId()),
item.rec->GetType().ToString());
return VarValue::None();
}
}

Expand All @@ -205,8 +210,10 @@ VarValue PapyrusObjectReference::RemoveItem(
espm::Convert<espm::LIGH>(item.rec)->GetData(worldState->GetEspmCache());
bool isTorch = res.data.flags & espm::LIGH::Flags::CanBeCarried;
if (!isTorch) {
throw std::runtime_error(
"RemoveItem - form is LIGH without CanBeCarried flag");
spdlog::error(
"RemoveItem {:x} - form {:x} is LIGH without CanBeCarried flag",
selfRefr->GetFormId(), item.ToGlobalId(item.rec->GetId()));
return VarValue::None();
}
}

Expand Down
9 changes: 9 additions & 0 deletions skymp5-server/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,15 @@ const main = async () => {
main();

// This is needed at least to handle axios errors in masterClient
// TODO: implement alerts
process.on("unhandledRejection", (...args) => {
console.error("[!!!] unhandledRejection")
console.error(...args);
});

// setTimeout on gamemode should not be able to kill the entire server
// TODO: implement alerts
process.on("uncaughtException", (...args) => {
console.error("[!!!] uncaughtException")
console.error(...args);
});
8 changes: 4 additions & 4 deletions skymp5-server/ts/systems/discordBanSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ export class DiscordBanSystem implements System {
return console.log("discord ban system is disabled due to offline mode");
}
if (!discordAuth) {
return console.error("discordAuth is missing, skipping Discord ban system");
return console.warn("discordAuth is missing, skipping Discord ban system");
}
if (!discordAuth.botToken) {
return console.error("discordAuth.botToken is missing, skipping Discord ban system");
return console.warn("discordAuth.botToken is missing, skipping Discord ban system");
}
if (!discordAuth.guildId) {
return console.error("discordAuth.guildId is missing, skipping Discord ban system");
return console.warn("discordAuth.guildId is missing, skipping Discord ban system");
}
if (!discordAuth.banRoleId) {
return console.error("discordAuth.banRoleId is missing, skipping Discord ban system");
return console.warn("discordAuth.banRoleId is missing, skipping Discord ban system");
}

const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers] });
Expand Down
5 changes: 5 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
{
"name": "asio",
"platform": "windows"
},
{
"name": "libarchive",
"platform": "windows",
"features": []
}
],
"features": {
Expand Down

0 comments on commit 2ba8ed9

Please sign in to comment.