mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-09-11 01:00:02 +00:00
Compare commits
10 Commits
06d1ccc17e
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9e5ec2fd6 | ||
|
|
0639bf2ae8 | ||
|
|
ed3bf6a952 | ||
|
|
c7bccd62c6 | ||
|
574d3111bc
|
|||
|
424f83ed94
|
|||
|
cd7caafec7
|
|||
|
ecc3e7731c
|
|||
| b2aa43b467 | |||
|
04ebd46769
|
2
.clangd
Normal file
2
.clangd
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
CompileFlags:
|
||||||
|
Add: [-Wall, -Wno-unknown-pragmas, -std=c++17, -DPROTOCOL_VERSION=1013, -DGIT_VERSION="", -I./src, -I./vendor]
|
||||||
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
**/*.o
|
||||||
9
.github/workflows/check-builds.yaml
vendored
9
.github/workflows/check-builds.yaml
vendored
@@ -84,11 +84,8 @@ jobs:
|
|||||||
Invoke-Expression "vcpkg integrate install"
|
Invoke-Expression "vcpkg integrate install"
|
||||||
|
|
||||||
foreach ($version in $versions) {
|
foreach ($version in $versions) {
|
||||||
if (Test-Path -LiteralPath "build") {
|
$buildDir = "build-$version"
|
||||||
Remove-Item "build" -Recurse
|
Invoke-Expression "cmake -B $buildDir -DPROTOCOL_VERSION=$version -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||||
Write-Output "Deleted existing build folder"
|
|
||||||
}
|
|
||||||
Invoke-Expression "cmake -B build -DPROTOCOL_VERSION=$version -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
|
||||||
if ($LASTEXITCODE -ne "0") {
|
if ($LASTEXITCODE -ne "0") {
|
||||||
Write-Error "cmake generation failed for version $version" -ErrorAction Stop
|
Write-Error "cmake generation failed for version $version" -ErrorAction Stop
|
||||||
}
|
}
|
||||||
@@ -96,7 +93,7 @@ jobs:
|
|||||||
|
|
||||||
foreach ($configuration in $configurations) {
|
foreach ($configuration in $configurations) {
|
||||||
Write-Output "Building version $version $configuration"
|
Write-Output "Building version $version $configuration"
|
||||||
Invoke-Expression "msbuild build\OpenFusion.sln /maxcpucount:8 /p:BuildInParallel=true /p:CL_MPCount=8 /p:UseMultiToolTask=true /p:Configuration=$configuration"
|
Invoke-Expression "msbuild $buildDir\OpenFusion.sln /maxcpucount:8 /nodeReuse:false /p:BuildInParallel=true /p:CL_MPCount=8 /p:UseMultiToolTask=true /p:Configuration=$configuration"
|
||||||
if ($LASTEXITCODE -ne "0") {
|
if ($LASTEXITCODE -ne "0") {
|
||||||
Write-Error "msbuild build failed for version $version" -ErrorAction Stop
|
Write-Error "msbuild build failed for version $version" -ErrorAction Stop
|
||||||
}
|
}
|
||||||
|
|||||||
26
Dockerfile
26
Dockerfile
@@ -1,36 +1,34 @@
|
|||||||
# build
|
# build
|
||||||
FROM alpine:3 as build
|
FROM debian:trixie-slim as build
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
RUN apk update && apk upgrade && apk add \
|
RUN apt update && apt upgrade -y && apt install -y \
|
||||||
linux-headers \
|
|
||||||
git \
|
git \
|
||||||
clang18 \
|
clang \
|
||||||
make \
|
build-essential \
|
||||||
sqlite-dev
|
libsqlite3-dev
|
||||||
|
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
COPY vendor ./vendor
|
COPY vendor ./vendor
|
||||||
COPY .git ./.git
|
COPY .git ./.git
|
||||||
COPY Makefile CMakeLists.txt version.h.in ./
|
COPY Makefile CMakeLists.txt version.h.in ./
|
||||||
|
|
||||||
RUN sed -i 's/^CC=clang$/&-18/' Makefile
|
|
||||||
RUN sed -i 's/^CXX=clang++$/&-18/' Makefile
|
|
||||||
|
|
||||||
RUN make nosandbox -j$(nproc)
|
RUN make nosandbox -j$(nproc)
|
||||||
|
|
||||||
|
# export-only stage: `docker build --target=export --output=./bin .`
|
||||||
|
FROM scratch AS export
|
||||||
|
COPY --from=build /usr/src/app/bin/fusion /fusion
|
||||||
|
|
||||||
# prod
|
# prod
|
||||||
FROM alpine:3
|
FROM debian:trixie-slim
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
RUN apk update && apk upgrade && apk add \
|
RUN apt update && apt upgrade -y && apt install -y \
|
||||||
libstdc++ \
|
libsqlite3-dev
|
||||||
sqlite-dev
|
|
||||||
|
|
||||||
COPY --from=build /usr/src/app/bin/fusion /bin/fusion
|
COPY --from=build /usr/src/app/bin/fusion /bin/fusion
|
||||||
COPY sql ./sql
|
|
||||||
|
|
||||||
CMD ["/bin/fusion"]
|
CMD ["/bin/fusion"]
|
||||||
|
|
||||||
|
|||||||
1
build_docker.sh
Executable file
1
build_docker.sh
Executable file
@@ -0,0 +1 @@
|
|||||||
|
docker build --target=export --output=./bin .
|
||||||
@@ -8,6 +8,7 @@ services:
|
|||||||
- ./config.ini:/usr/src/app/config.ini
|
- ./config.ini:/usr/src/app/config.ini
|
||||||
- ./database.db:/usr/src/app/database.db
|
- ./database.db:/usr/src/app/database.db
|
||||||
- ./tdata:/usr/src/app/tdata
|
- ./tdata:/usr/src/app/tdata
|
||||||
|
- ./sql:/usr/src/app/sql
|
||||||
ports:
|
ports:
|
||||||
- "23000:23000"
|
- "23000:23000"
|
||||||
- "23001:23001"
|
- "23001:23001"
|
||||||
|
|||||||
@@ -804,8 +804,20 @@ static void projectileHit(CNSocket* sock, CNPacketData* data) {
|
|||||||
sP_CL2FE_REQ_PC_ROCKET_STYLE_HIT* pkt = (sP_CL2FE_REQ_PC_ROCKET_STYLE_HIT*)data->buf;
|
sP_CL2FE_REQ_PC_ROCKET_STYLE_HIT* pkt = (sP_CL2FE_REQ_PC_ROCKET_STYLE_HIT*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (pkt->iTargetCnt == 0) {
|
if (plr == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Bullets.find(plr->iID) == Bullets.end() || Bullets[plr->iID].find(pkt->iBulletID) == Bullets[plr->iID].end()) {
|
||||||
|
std::cout << "[WARN] projectileHit: bullet not found" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the bullet immediately to prevent leaking it in early return paths
|
||||||
|
Bullet bullet = Bullets[plr->iID][pkt->iBulletID];
|
||||||
Bullets[plr->iID].erase(pkt->iBulletID);
|
Bullets[plr->iID].erase(pkt->iBulletID);
|
||||||
|
|
||||||
|
if (pkt->iTargetCnt == 0) {
|
||||||
// no targets hit, don't send response
|
// no targets hit, don't send response
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -848,11 +860,6 @@ static void projectileHit(CNSocket* sock, CNPacketData* data) {
|
|||||||
sAttackResult* respdata = (sAttackResult*)(respbuf + sizeof(sP_FE2CL_PC_GRENADE_STYLE_HIT));
|
sAttackResult* respdata = (sAttackResult*)(respbuf + sizeof(sP_FE2CL_PC_GRENADE_STYLE_HIT));
|
||||||
|
|
||||||
resp->iTargetCnt = pkt->iTargetCnt;
|
resp->iTargetCnt = pkt->iTargetCnt;
|
||||||
if (Bullets.find(plr->iID) == Bullets.end() || Bullets[plr->iID].find(pkt->iBulletID) == Bullets[plr->iID].end()) {
|
|
||||||
std::cout << "[WARN] projectileHit: bullet not found" << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bullet* bullet = &Bullets[plr->iID][pkt->iBulletID];
|
|
||||||
|
|
||||||
for (int i = 0; i < pkt->iTargetCnt; i++) {
|
for (int i = 0; i < pkt->iTargetCnt; i++) {
|
||||||
if (NPCManager::NPCs.find(pktdata[i]) == NPCManager::NPCs.end()) {
|
if (NPCManager::NPCs.find(pktdata[i]) == NPCManager::NPCs.end()) {
|
||||||
@@ -870,10 +877,10 @@ static void projectileHit(CNSocket* sock, CNPacketData* data) {
|
|||||||
Mob* mob = (Mob*)npc;
|
Mob* mob = (Mob*)npc;
|
||||||
std::pair<int, int> damage;
|
std::pair<int, int> damage;
|
||||||
|
|
||||||
damage.first = pkt->iTargetCnt > 1 ? bullet->groupDamage : bullet->pointDamage;
|
damage.first = pkt->iTargetCnt > 1 ? bullet.groupDamage : bullet.pointDamage;
|
||||||
|
|
||||||
int difficulty = (int)mob->data["m_iNpcLevel"];
|
int difficulty = (int)mob->data["m_iNpcLevel"];
|
||||||
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, bullet->weaponBoost, Nanos::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, bullet.weaponBoost, Nanos::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
||||||
|
|
||||||
damage.first = mob->takeDamage(sock, damage.first);
|
damage.first = mob->takeDamage(sock, damage.first);
|
||||||
|
|
||||||
@@ -885,11 +892,9 @@ static void projectileHit(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
resp->iPC_ID = plr->iID;
|
resp->iPC_ID = plr->iID;
|
||||||
resp->iBulletID = pkt->iBulletID;
|
resp->iBulletID = pkt->iBulletID;
|
||||||
resp->Bullet.iID = bullet->bulletType;
|
resp->Bullet.iID = bullet.bulletType;
|
||||||
sock->sendPacket((void*)respbuf, P_FE2CL_PC_GRENADE_STYLE_HIT, resplen);
|
sock->sendPacket((void*)respbuf, P_FE2CL_PC_GRENADE_STYLE_HIT, resplen);
|
||||||
PlayerManager::sendToViewable(sock, (void*)respbuf, P_FE2CL_PC_GRENADE_STYLE_HIT, resplen);
|
PlayerManager::sendToViewable(sock, (void*)respbuf, P_FE2CL_PC_GRENADE_STYLE_HIT, resplen);
|
||||||
|
|
||||||
Bullets[plr->iID].erase(resp->iBulletID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void playerTick(CNServer *serv, time_t currTime) {
|
static void playerTick(CNServer *serv, time_t currTime) {
|
||||||
|
|||||||
@@ -595,10 +595,17 @@ void Missions::mobKilled(CNSocket *sock, int mobid, std::map<int, int>& rolls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// drop quest item
|
// drop quest item
|
||||||
if (task["m_iCSUItemNumNeeded"][j] != 0 && !isQuestItemFull(sock, task["m_iCSUItemID"][j], task["m_iCSUItemNumNeeded"][j]) ) {
|
if (task["m_iCSUItemNumNeeded"][j] != 0) {
|
||||||
|
if (!isQuestItemFull(sock, task["m_iCSUItemID"][j], task["m_iCSUItemNumNeeded"][j])) {
|
||||||
bool drop = rolls[plr->tasks[i]] % 100 < task["m_iSTItemDropRate"][j];
|
bool drop = rolls[plr->tasks[i]] % 100 < task["m_iSTItemDropRate"][j];
|
||||||
if (drop) {
|
if (drop) {
|
||||||
dropQuestItem(sock, plr->tasks[i], 1, task["m_iCSUItemID"][j], mobid);
|
dropQuestItem(sock, plr->tasks[i], 1, task["m_iCSUItemID"][j], mobid);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// fail to drop (itemID == 0)
|
||||||
|
dropQuestItem(sock, plr->tasks[i], 1, 0, mobid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Workaround: The client has a bug where it only sends a TASK_END request
|
* Workaround: The client has a bug where it only sends a TASK_END request
|
||||||
@@ -616,10 +623,6 @@ void Missions::mobKilled(CNSocket *sock, int mobid, std::map<int, int>& rolls) {
|
|||||||
|
|
||||||
sock->sendPacket(end, P_FE2CL_REP_PC_TASK_END_SUCC);
|
sock->sendPacket(end, P_FE2CL_REP_PC_TASK_END_SUCC);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// fail to drop (itemID == 0)
|
|
||||||
dropQuestItem(sock, plr->tasks[i], 1, 0, mobid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,6 +340,9 @@ static void tradeConfirmCancel(CNSocket* sock, CNPacketData* data) {
|
|||||||
static void tradeRegisterItem(CNSocket* sock, CNPacketData* data) {
|
static void tradeRegisterItem(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_TRADE_ITEM_REGISTER* pacdat = (sP_CL2FE_REQ_PC_TRADE_ITEM_REGISTER*)data->buf;
|
sP_CL2FE_REQ_PC_TRADE_ITEM_REGISTER* pacdat = (sP_CL2FE_REQ_PC_TRADE_ITEM_REGISTER*)data->buf;
|
||||||
|
|
||||||
|
if (pacdat->Item.iInvenNum < 0 || pacdat->Item.iInvenNum >= AINVEN_COUNT)
|
||||||
|
return; // inventory bounds check
|
||||||
|
|
||||||
if (pacdat->Item.iSlotNum < 0 || pacdat->Item.iSlotNum > 4)
|
if (pacdat->Item.iSlotNum < 0 || pacdat->Item.iSlotNum > 4)
|
||||||
return; // sanity check, there are only 5 trade slots
|
return; // sanity check, there are only 5 trade slots
|
||||||
|
|
||||||
@@ -353,7 +356,13 @@ static void tradeRegisterItem(CNSocket* sock, CNPacketData* data) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
if (!plr->isTrading)
|
||||||
|
return;
|
||||||
|
|
||||||
Player* plr2 = PlayerManager::getPlayer(otherSock);
|
Player* plr2 = PlayerManager::getPlayer(otherSock);
|
||||||
|
if (!plr2->isTrading)
|
||||||
|
return;
|
||||||
|
|
||||||
plr->Trade[pacdat->Item.iSlotNum] = pacdat->Item;
|
plr->Trade[pacdat->Item.iSlotNum] = pacdat->Item;
|
||||||
plr->isTradeConfirm = false;
|
plr->isTradeConfirm = false;
|
||||||
plr2->isTradeConfirm = false;
|
plr2->isTradeConfirm = false;
|
||||||
@@ -397,7 +406,13 @@ static void tradeUnregisterItem(CNSocket* sock, CNPacketData* data) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
if (!plr->isTrading)
|
||||||
|
return;
|
||||||
|
|
||||||
Player* plr2 = PlayerManager::getPlayer(otherSock);
|
Player* plr2 = PlayerManager::getPlayer(otherSock);
|
||||||
|
if (!plr2->isTrading)
|
||||||
|
return;
|
||||||
|
|
||||||
plr->isTradeConfirm = false;
|
plr->isTradeConfirm = false;
|
||||||
plr2->isTradeConfirm = false;
|
plr2->isTradeConfirm = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user