mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-12-22 19:30:05 +00:00
Various bugfixes
* Fixed Nano stamina not being halved on respawn * Reverted the default argument to terminate() change because MSVC is undable to disambiguate the function pointer passed to sigaction() * Fatal errors during init (like in TableData) can just call exit(1) directly anyway (missing "OpenFusion: terminated." be damned) * Switched to a slightly more portable syntax for getting the version in the Makefile * We shouldn't join the shard thread in the signal handler because the thread the signal handler ends up running in is undefined behaviour and we don't strictly need to join it anyway Many of these issues were discovered on OpenBSD.
This commit is contained in:
parent
02c5df5c1b
commit
8ebabac7c0
6
Makefile
6
Makefile
@ -1,9 +1,11 @@
|
||||
GIT_VERSION!=git describe --tags
|
||||
|
||||
CC=clang
|
||||
CXX=clang++
|
||||
# -w suppresses all warnings (the part that's commented out helps me find memory leaks, it ruins performance though!)
|
||||
# If compiling with ASAN, invoke like this: $ LSAN_OPTIONS=suppressions=suppr.txt bin/fusion
|
||||
CFLAGS=-O3 #-g3 -fsanitize=address
|
||||
CXXFLAGS=-Wall -Wno-unknown-pragmas -std=c++17 -O2 -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) -DGIT_VERSION=\"$(shell git describe --tags)\" #-g3 -fsanitize=address
|
||||
CXXFLAGS=-Wall -Wno-unknown-pragmas -std=c++17 -O2 -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) -DGIT_VERSION=\"$(GIT_VERSION)\" #-g3 -fsanitize=address
|
||||
LDFLAGS=-lpthread -ldl #-g3 -fsanitize=address
|
||||
# specifies the name of our exectuable
|
||||
SERVER=bin/fusion
|
||||
@ -18,7 +20,7 @@ WIN_CXX=x86_64-w64-mingw32-g++
|
||||
WIN_CFLAGS=-O3 #-g3 -fsanitize=address
|
||||
WIN_CXX_VANILLA_MINGW_OPT_DISABLES=-fno-tree-dce -fno-inline-small-functions
|
||||
WIN_CXX_MSYS2_MINGW_OPT_DISABLES=-fno-tree-dce -fno-tree-fre -fno-tree-vrp -fno-ipa-sra
|
||||
WIN_CXXFLAGS=-D_WIN32_WINNT=0x0601 -Wall -Wno-unknown-pragmas -std=c++17 -O3 $(WIN_CXX_OPT_DISABLES) -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) -DGIT_VERSION=\"$(shell git describe --tags)\" #-g3 -fsanitize=address
|
||||
WIN_CXXFLAGS=-D_WIN32_WINNT=0x0601 -Wall -Wno-unknown-pragmas -std=c++17 -O3 $(WIN_CXX_OPT_DISABLES) -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) -DGIT_VERSION=\"$(GIT_VERSION)\" #-g3 -fsanitize=address
|
||||
WIN_LDFLAGS=-static -lws2_32 -lwsock32 #-g3 -fsanitize=address
|
||||
WIN_SERVER=bin/winfusion.exe
|
||||
|
||||
|
@ -313,7 +313,7 @@ void CNServer::start() {
|
||||
int n = poll(fds.data(), fds.size(), 50);
|
||||
if (SOCKETERROR(n)) {
|
||||
std::cout << "[FATAL] poll() returned error" << std::endl;
|
||||
terminate();
|
||||
terminate(0);
|
||||
}
|
||||
|
||||
oldnfds = fds.size();
|
||||
@ -329,7 +329,7 @@ void CNServer::start() {
|
||||
// any sort of error on the listener
|
||||
if (fds[i].revents & ~POLLIN) {
|
||||
std::cout << "[FATAL] Error on listener socket" << std::endl;
|
||||
terminate();
|
||||
terminate(0);
|
||||
}
|
||||
|
||||
SOCKET newConnectionSocket = accept(sock, (struct sockaddr *)&address, (socklen_t*)&addressSize);
|
||||
|
@ -41,7 +41,7 @@ std::string U16toU8(char16_t* src);
|
||||
size_t U8toU16(std::string src, char16_t* des, size_t max); // returns number of char16_t that was written at des
|
||||
time_t getTime();
|
||||
time_t getTimestamp();
|
||||
void terminate(int unused=0);
|
||||
void terminate(int);
|
||||
|
||||
// The PROTOCOL_VERSION definition is defined by the build system.
|
||||
#if !defined(PROTOCOL_VERSION)
|
||||
|
@ -123,7 +123,7 @@ bool Monitor::acceptConnection(SOCKET fd, uint16_t revents) {
|
||||
|
||||
if (revents & ~POLLIN) {
|
||||
std::cout << "[FATAL] Error on monitor listener?" << std::endl;
|
||||
terminate();
|
||||
terminate(0);
|
||||
}
|
||||
|
||||
int sock = accept(listener, (struct sockaddr*)&address, &len);
|
||||
|
@ -720,7 +720,7 @@ void PlayerManager::revivePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
int nanoID = plr->equippedNanos[i];
|
||||
// halve nano health if respawning
|
||||
// all revives not 3-5 are normal respawns.
|
||||
if (reviveData->iRegenType < 3 && reviveData->iRegenType > 5)
|
||||
if (reviveData->iRegenType < 3 || reviveData->iRegenType > 5)
|
||||
plr->Nanos[nanoID].iStamina = 75; // max is 150, so 75 is half
|
||||
response.PCRegenData.Nanos[i] = plr->Nanos[nanoID];
|
||||
if (plr->activeNano == nanoID)
|
||||
|
@ -54,7 +54,7 @@ void TableData::init() {
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[FATAL] Malformed NPCs.json file! Reason:" << err.what() << std::endl;
|
||||
terminate();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// load everything else from xdttable
|
||||
@ -230,7 +230,7 @@ void TableData::init() {
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[FATAL] Malformed xdt.json file! Reason:" << err.what() << std::endl;
|
||||
terminate();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// load temporary mob dump
|
||||
@ -303,7 +303,7 @@ void TableData::init() {
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[FATAL] Malformed mobs.json file! Reason:" << err.what() << std::endl;
|
||||
terminate();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
loadDrops();
|
||||
@ -373,7 +373,7 @@ void TableData::loadPaths(int* nextId) {
|
||||
if (firstPoint["iX"] != pair.second->spawnX || firstPoint["iY"] != pair.second->spawnY) {
|
||||
std::cout << "[FATAL] The first point of the route for mob " << pair.first <<
|
||||
" (type " << pair.second->appearanceData.iNPCType << ") does not correspond with its spawn point." << std::endl;
|
||||
terminate();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
constructPathNPC(npcPath, pair.first);
|
||||
@ -386,7 +386,7 @@ void TableData::loadPaths(int* nextId) {
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[FATAL] Malformed paths.json file! Reason:" << err.what() << std::endl;
|
||||
terminate();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,7 +497,7 @@ void TableData::loadDrops() {
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[FATAL] Malformed drops.json file! Reason:" << err.what() << std::endl;
|
||||
terminate();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -539,7 +539,7 @@ void TableData::loadEggs(int32_t* nextId) {
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[FATAL] Malformed eggs.json file! Reason:" << err.what() << std::endl;
|
||||
terminate();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -763,7 +763,7 @@ void TableData::loadGruntwork(int32_t *nextId) {
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[FATAL] Malformed gruntwork.json file! Reason:" << err.what() << std::endl;
|
||||
terminate();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,8 @@ void startShard(CNShardServer* server) {
|
||||
void terminate(int arg) {
|
||||
std::cout << "OpenFusion: terminating." << std::endl;
|
||||
|
||||
if (shardServer != nullptr && shardThread != nullptr) {
|
||||
if (shardServer != nullptr && shardThread != nullptr)
|
||||
shardServer->kill();
|
||||
shardThread->join();
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
@ -111,7 +109,7 @@ int main() {
|
||||
case 3: std::cout << "[INFO] Event active. Have a very hoppy Easter!" << std::endl; break;
|
||||
default:
|
||||
std::cout << "[FATAL] Unknown event set in config file." << std::endl;
|
||||
terminate();
|
||||
exit(1);
|
||||
/* not reached */
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user