OpenFusion/src/MissionManager.hpp

60 lines
1.7 KiB
C++
Raw Normal View History

#pragma once
#include "CNShardServer.hpp"
#include "Player.hpp"
#include "contrib/JSON.hpp"
struct Reward {
int32_t id;
int32_t itemTypes[4];
int32_t itemIds[4];
int32_t money;
int32_t fusionmatter;
Reward(int32_t id, nlohmann::json types, nlohmann::json ids, int32_t m, int32_t fm) :
id(id), money(m), fusionmatter(fm) {
for (int i = 0; i < 4; i++) {
itemTypes[i] = types[i];
itemIds[i] = ids[i];
}
};
};
struct TaskData {
/*
* TODO: We'll probably want to keep only the data the server actually needs,
* but for now RE/development is much easier if we have everything at
* our fingertips.
*/
nlohmann::json task;
TaskData(nlohmann::json t) : task(t) {}
// convenience
auto operator[](std::string s) { return task[s]; }
};
namespace MissionManager {
extern std::map<int32_t, Reward*> Rewards;
extern std::map<int32_t, TaskData*> Tasks;
2020-09-23 19:44:27 +00:00
extern nlohmann::json AvatarGrowth[36];
void init();
void taskStart(CNSocket* sock, CNPacketData* data);
void taskEnd(CNSocket* sock, CNPacketData* data);
void setMission(CNSocket* sock, CNPacketData* data);
void quitMission(CNSocket* sock, CNPacketData* data);
int findQSlot(Player *plr, int id);
void dropQuestItem(CNSocket *sock, int task, int count, int id, int mobid);
Database saving update (#104) * implemented saving BatteryN and BatteryW * implemented saving mentor * moved int64->blob parsing to a separate function * moved parsing blob->int64 to a separate function * added functions for parsing int32->blob and vice versa * added functions for parsing int16->blob and vice versa * WIP saving quest items and active tasks * Quest items are stored in inventory table instead of blob * added sanity check for missionId * saving active missions works * removed unneccesary include * implemented saving warplocationflag, skywaylocationflag and currentmissionid in database * INFO DB message now shows how many accounts and player characters are in the database * fixed dbsaveinterval being in [login] instead of [shard] * fixed mission quit: - fixed wrong json name, causing qitems not deleting properly - quitting mission now resets npc kill count * adjusted saving active missions * removed blob parsing functions that ended up being unused * removed accidentaly added include * removed sending PCStyle2 on Player Enter * added a sanity check in itemMoveHandler * removed MapNum from PCLoad, as client doesn't even read it * set BuddyWarpCooldown to 60s on PCLoad * fixed a bug causing EXIT DUPLICATE not working * added creation and last login timestamps to accounts and players * added a sanity check for P_CL2LS_REQ_PC_EXIT_DUPLICATE * implemented web api support, toggled by new setting (off by default) * add usewebapi to config Co-authored-by: Gent <gentsemaj@live.com>
2020-09-21 19:43:53 +00:00
//checks if player doesn't have n/n quest items
bool isQuestItemFull(CNSocket* sock, int itemId, int itemCount);
int giveMissionReward(CNSocket *sock, int task);
2020-09-23 19:44:27 +00:00
void updateFusionMatter(CNSocket* sock);
void mobKilled(CNSocket *sock, int mobid);
2020-09-13 18:45:51 +00:00
void saveMission(Player* player, int missionId);
}