The great re-#include

Was getting frustrated by the inconsistency in our include statements,
which were causing me problems. As a result, I went through and manually
re-organized every include statement in non-core files.

I'm just gonna copy my rant from Discord:
FOR HEADER FILES (.hpp):
- everything you use IN THE HEADER must be EXPLICITLY INCLUDED with the exception of things that fall under Core.hpp
- you may NOT include ANYTHING ELSE

FOR SOURCE FILES (.cpp):
- you can #include whatever you want as long as the partner header is included first
- anything that gets included by another include is fair game
- redundant includes are ok because they'll be harmless AS LONG AS our header files stay lean.

the point of this is NOT to optimize the number of includes used all around or make things more efficient necessarily. it's to improve readability & coherence and make it easier to avoid cyclical issues
This commit is contained in:
gsemaj 2022-07-16 16:19:40 -07:00 committed by gsemaj
parent 13c009b448
commit d32827b692
No known key found for this signature in database
GPG Key ID: 24B96BAA40497929
55 changed files with 200 additions and 175 deletions

View File

@ -1,10 +1,7 @@
#include "Abilities.hpp"
#include "PlayerManager.hpp"
#include "Player.hpp"
#include "NPCManager.hpp"
#include "Nanos.hpp"
#include "Groups.hpp"
#include "Eggs.hpp"
#include "PlayerManager.hpp"
std::map<int32_t, SkillData> Abilities::SkillTable;

View File

@ -1,7 +1,9 @@
#pragma once
#include "core/Core.hpp"
#include "Combat.hpp"
#include "Entities.hpp"
#include <map>
#include <vector>
enum class SkillEffectTarget {
POINT = 1,

View File

@ -1,15 +1,10 @@
#include "servers/CNShardServer.hpp"
#include "Buddies.hpp"
#include "PlayerManager.hpp"
#include "Buddies.hpp"
#include "db/Database.hpp"
#include "Items.hpp"
#include "db/Database.hpp"
#include <iostream>
#include <chrono>
#include <algorithm>
#include <thread>
#include "db/Database.hpp"
#include "servers/CNShardServer.hpp"
#include "Player.hpp"
#include "PlayerManager.hpp"
using namespace Buddies;

View File

@ -1,7 +1,5 @@
#pragma once
#include "Player.hpp"
#include "core/Core.hpp"
#include "core/Core.hpp"
namespace Buddies {

View File

@ -1,10 +1,13 @@
#include "BuiltinCommands.hpp"
#include "servers/CNShardServer.hpp"
#include "Player.hpp"
#include "PlayerManager.hpp"
#include "Chat.hpp"
#include "Items.hpp"
#include "Missions.hpp"
#include "Chat.hpp"
#include "Nanos.hpp"
#include "Rand.hpp"
// helper function, not a packet handler
void BuiltinCommands::setSpecialState(CNSocket* sock, CNPacketData* data) {

View File

@ -1,6 +1,9 @@
#include "Chat.hpp"
#include "servers/CNShardServer.hpp"
#include "Player.hpp"
#include "PlayerManager.hpp"
#include "Groups.hpp"
#include "CustomCommands.hpp"
#include <assert.h>

View File

@ -2,7 +2,10 @@
#define CMD_PREFIX '/'
#include "servers/CNShardServer.hpp"
#include "core/Core.hpp"
#include <string>
#include <vector>
namespace Chat {
extern std::vector<std::string> dump;

View File

@ -1,9 +1,9 @@
#include "Chunking.hpp"
#include "PlayerManager.hpp"
#include "MobAI.hpp"
#include "NPCManager.hpp"
#include "settings.hpp"
#include "Combat.hpp"
#include "Eggs.hpp"
#include <assert.h>
using namespace Chunking;

View File

@ -1,12 +1,10 @@
#pragma once
#include "core/Core.hpp"
#include "Entities.hpp"
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include <algorithm>
#include <vector>
struct EntityRef;

View File

@ -1,14 +1,13 @@
#include "Combat.hpp"
#include "PlayerManager.hpp"
#include "Nanos.hpp"
#include "NPCManager.hpp"
#include "Items.hpp"
#include "Missions.hpp"
#include "Groups.hpp"
#include "Transport.hpp"
#include "Racing.hpp"
#include "Abilities.hpp"
#include "servers/CNShardServer.hpp"
#include "Rand.hpp"
#include "Player.hpp"
#include "PlayerManager.hpp"
#include "NPCManager.hpp"
#include "Nanos.hpp"
#include "Abilities.hpp"
#include <assert.h>

View File

@ -1,14 +1,10 @@
#pragma once
#include "core/Core.hpp"
#include "servers/CNShardServer.hpp"
#include "Player.hpp"
#include "MobAI.hpp"
#include "JSON.hpp"
#include <map>
#include <unordered_map>
#include <queue>
#include <vector>
struct Bullet {
int pointDamage;
@ -17,8 +13,6 @@ struct Bullet {
int bulletType;
};
namespace Combat {
extern std::map<int32_t, std::map<int8_t, Bullet>> Bullets;

View File

@ -1,18 +1,18 @@
#include "CustomCommands.hpp"
#include "Chat.hpp"
#include "db/Database.hpp"
#include "Player.hpp"
#include "PlayerManager.hpp"
#include "Chat.hpp"
#include "TableData.hpp"
#include "NPCManager.hpp"
#include "Eggs.hpp"
#include "MobAI.hpp"
#include "Items.hpp"
#include "db/Database.hpp"
#include "Transport.hpp"
#include "Missions.hpp"
#include "Eggs.hpp"
#include "Items.hpp"
#include <sstream>
#include <iterator>
#include <math.h>
#include <limits.h>
typedef void (*CommandHandler)(std::string fullString, std::vector<std::string>& args, CNSocket* sock);

View File

@ -2,6 +2,8 @@
#include "core/Core.hpp"
#include <string>
namespace CustomCommands {
void init();

View File

@ -1,10 +1,13 @@
#include "core/Core.hpp"
#include "Eggs.hpp"
#include "servers/CNShardServer.hpp"
#include "Player.hpp"
#include "PlayerManager.hpp"
#include "Items.hpp"
#include "Nanos.hpp"
#include "Abilities.hpp"
#include "Groups.hpp"
#include "NPCManager.hpp"
#include "Entities.hpp"
#include "Items.hpp"
#include <assert.h>

View File

@ -1,7 +1,6 @@
#pragma once
#include "core/Core.hpp"
#include "Entities.hpp"
struct EggType {
int dropCrateId;

View File

@ -1,9 +1,9 @@
#include "Email.hpp"
#include "core/Core.hpp"
#include "db/Database.hpp"
#include "servers/CNShardServer.hpp"
#include "db/Database.hpp"
#include "PlayerManager.hpp"
#include "Items.hpp"
#include "Chat.hpp"

View File

@ -1,12 +1,9 @@
#include "core/Core.hpp"
#include "Entities.hpp"
#include "Chunking.hpp"
#include "PlayerManager.hpp"
#include "NPCManager.hpp"
#include "Eggs.hpp"
#include "MobAI.hpp"
#include <type_traits>
#include "NPCManager.hpp"
#include "PlayerManager.hpp"
#include <assert.h>
static_assert(std::is_standard_layout<EntityRef>::value);
static_assert(std::is_trivially_copyable<EntityRef>::value);

View File

@ -3,8 +3,8 @@
#include "core/Core.hpp"
#include "Chunking.hpp"
#include <stdint.h>
#include <set>
#include <map>
enum EntityKind {
INVALID,

View File

@ -1,13 +1,9 @@
#include "servers/CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "Groups.hpp"
#include "Nanos.hpp"
#include "Abilities.hpp"
#include <iostream>
#include <chrono>
#include <algorithm>
#include <thread>
#include "servers/CNShardServer.hpp"
#include "Player.hpp"
#include "PlayerManager.hpp"
/*
* NOTE: Variadic response packets that list group members are technically

View File

@ -1,14 +1,13 @@
#pragma once
#include "core/Core.hpp"
#include "servers/CNShardServer.hpp"
#include "Entities.hpp"
#include <vector>
#include <map>
#include <list>
/* forward declaration(s) */
struct Player;
enum EntityKind;
struct Group {
std::vector<EntityRef> members;

View File

@ -1,16 +1,18 @@
#include "servers/CNShardServer.hpp"
#include "Items.hpp"
#include "servers/CNShardServer.hpp"
#include "Player.hpp"
#include "PlayerManager.hpp"
#include "Nanos.hpp"
#include "NPCManager.hpp"
#include "Player.hpp"
#include "Abilities.hpp"
#include "Missions.hpp"
#include "Eggs.hpp"
#include "Rand.hpp"
#include "MobAI.hpp"
#include "Missions.hpp"
#include <string.h> // for memset()
#include <assert.h>
#include <numeric>
using namespace Items;

View File

@ -1,9 +1,13 @@
#pragma once
#include "servers/CNShardServer.hpp"
#include "core/Core.hpp"
#include "Player.hpp"
#include "MobAI.hpp"
#include "Rand.hpp"
#include "MobAI.hpp"
#include <vector>
#include <map>
struct CrocPotEntry {
int multStats, multLooks;

View File

@ -1,11 +1,10 @@
#include "servers/CNShardServer.hpp"
#include "Missions.hpp"
#include "PlayerManager.hpp"
#include "Nanos.hpp"
#include "Items.hpp"
#include "Transport.hpp"
#include "string.h"
#include "servers/CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "Items.hpp"
#include "Nanos.hpp"
using namespace Missions;

View File

@ -1,9 +1,11 @@
#pragma once
#include "servers/CNShardServer.hpp"
#include "core/Core.hpp"
#include "JSON.hpp"
#include "Player.hpp"
#include "JSON.hpp"
#include <map>
struct Reward {
int32_t id;

View File

@ -1,13 +1,16 @@
#include "MobAI.hpp"
#include "Player.hpp"
#include "Chunking.hpp"
#include "NPCManager.hpp"
#include "Entities.hpp"
#include "PlayerManager.hpp"
#include "Racing.hpp"
#include "Transport.hpp"
#include "Nanos.hpp"
#include "Combat.hpp"
#include "Abilities.hpp"
#include "Rand.hpp"
#include "Combat.hpp"
#include "Items.hpp"
#include "Missions.hpp"
#include "Rand.hpp"
#include <cmath>
#include <limits.h>

View File

@ -1,11 +1,13 @@
#pragma once
#include "core/Core.hpp"
#include "NPCManager.hpp"
#include "JSON.hpp"
#include "Entities.hpp"
/* kill me */
struct Mob;
#include <unordered_map>
#include <string>
namespace MobAI {
void deadStep(CombatNPC* self, time_t currTime);
void combatStep(CombatNPC* self, time_t currTime);

View File

@ -1,4 +1,8 @@
#include "NPCManager.hpp"
#include "servers/CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "Items.hpp"
#include "settings.hpp"
#include "Combat.hpp"
@ -20,8 +24,6 @@
#include <assert.h>
#include <limits.h>
#include "JSON.hpp"
using namespace NPCManager;
std::unordered_map<int32_t, BaseNPC*> NPCManager::NPCs;

View File

@ -1,14 +1,15 @@
#pragma once
#include "core/Core.hpp"
#include "PlayerManager.hpp"
#include "Transport.hpp"
#include "JSON.hpp"
#include "Transport.hpp"
#include "Chunking.hpp"
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#define RESURRECT_HEIGHT 400
@ -28,8 +29,6 @@ struct NPCEvent {
: npcType(t), trigger(tr), handler(hndlr) {}
};
struct WarpLocation;
namespace NPCManager {
extern std::unordered_map<int32_t, BaseNPC*> NPCs;
extern std::map<int32_t, WarpLocation> Warps;

View File

@ -1,11 +1,11 @@
#include "servers/CNShardServer.hpp"
#include "Nanos.hpp"
#include "servers/CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "NPCManager.hpp"
#include "Combat.hpp"
#include "Missions.hpp"
#include "Groups.hpp"
#include "Abilities.hpp"
#include "NPCManager.hpp"
#include <cmath>

View File

@ -1,10 +1,10 @@
#pragma once
#include <set>
#include <vector>
#include "core/Core.hpp"
#include "Player.hpp"
#include "servers/CNShardServer.hpp"
#include <map>
struct NanoData {
int style;

View File

@ -1,13 +1,12 @@
#pragma once
#include <string>
#include <cstring>
#include "core/Core.hpp"
#include "Chunking.hpp"
#include "Entities.hpp"
#include "Groups.hpp"
#include <vector>
#define ACTIVE_MISSION_COUNT 6
#define PC_MAXHEALTH(level) (925 + 75 * (level))

View File

@ -1,25 +1,20 @@
#include "core/Core.hpp"
#include "PlayerManager.hpp"
#include "db/Database.hpp"
#include "core/CNShared.hpp"
#include "servers/CNShardServer.hpp"
#include "db/Database.hpp"
#include "PlayerManager.hpp"
#include "NPCManager.hpp"
#include "Missions.hpp"
#include "Items.hpp"
#include "Nanos.hpp"
#include "Groups.hpp"
#include "Chat.hpp"
#include "Buddies.hpp"
#include "Combat.hpp"
#include "Racing.hpp"
#include "BuiltinCommands.hpp"
#include "Abilities.hpp"
#include "Eggs.hpp"
#include "settings.hpp"
#include "Missions.hpp"
#include "Chat.hpp"
#include "Items.hpp"
#include "Buddies.hpp"
#include "BuiltinCommands.hpp"
#include <assert.h>
#include <algorithm>
#include <vector>
#include <cmath>

View File

@ -1,16 +1,15 @@
#pragma once
#include "Player.hpp"
#include "core/Core.hpp"
#include "servers/CNShardServer.hpp"
#include "Chunking.hpp"
#include <utility>
#include "Player.hpp"
#include "Chunking.hpp"
#include "Transport.hpp"
#include "Entities.hpp"
#include <map>
#include <list>
struct WarpLocation;
namespace PlayerManager {
extern std::map<CNSocket*, Player*> players;
void init();

View File

@ -1,4 +1,7 @@
#include "PlayerMovement.hpp"
#include "servers/CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "TableData.hpp"
#include "core/Core.hpp"

View File

@ -1,10 +1,12 @@
#include "servers/CNShardServer.hpp"
#include "Racing.hpp"
#include "db/Database.hpp"
#include "servers/CNShardServer.hpp"
#include "NPCManager.hpp"
#include "PlayerManager.hpp"
#include "Missions.hpp"
#include "Items.hpp"
#include "db/Database.hpp"
#include "NPCManager.hpp"
using namespace Racing;

View File

@ -1,8 +1,10 @@
#pragma once
#include <set>
#include "core/Core.hpp"
#include "servers/CNShardServer.hpp"
#include <map>
#include <vector>
#include <set>
struct EPInfo {
int zoneX, zoneY, EPID, maxScore, maxTime;

View File

@ -2,6 +2,7 @@
#include <random>
#include <memory>
#include <vector>
namespace Rand {
extern std::unique_ptr<std::mt19937> generator;

View File

@ -1,18 +1,14 @@
#include "TableData.hpp"
#include "NPCManager.hpp"
#include "Transport.hpp"
#include "Items.hpp"
#include "settings.hpp"
#include "Missions.hpp"
#include "Chunking.hpp"
#include "Nanos.hpp"
#include "Racing.hpp"
#include "Items.hpp"
#include "Vendors.hpp"
#include "Racing.hpp"
#include "Nanos.hpp"
#include "Abilities.hpp"
#include "Eggs.hpp"
#include "JSON.hpp"
#include <fstream>
#include <sstream>
#include <cmath>

View File

@ -1,8 +1,13 @@
#pragma once
#include <map>
#include "JSON.hpp"
#include "NPCManager.hpp"
#include "Entities.hpp"
#include "Transport.hpp"
#include <map>
#include <unordered_map>
#include <vector>
// these are added to the NPC's static key to avoid collisions
const int NPC_ID_OFFSET = 1;

View File

@ -1,4 +1,7 @@
#include "Trading.hpp"
#include "servers/CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "db/Database.hpp"

View File

@ -1,7 +1,5 @@
#pragma once
#include "Items.hpp"
namespace Trading {
void init();
}

View File

@ -1,9 +1,12 @@
#include "Transport.hpp"
#include "servers/CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "Nanos.hpp"
#include "Transport.hpp"
#include "TableData.hpp"
#include "Combat.hpp"
#include "Entities.hpp"
#include "NPCManager.hpp"
#include "MobAI.hpp"
#include <unordered_map>

View File

@ -1,8 +1,11 @@
#pragma once
#include "servers/CNShardServer.hpp"
#include "core/Core.hpp"
#include <unordered_map>
#include <map>
#include <vector>
#include <queue>
const int SLIDER_SPEED = 1200;
const int SLIDER_STOP_TICKS = 16;

View File

@ -1,4 +1,9 @@
#include "Vendors.hpp"
#include "servers/CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "Items.hpp"
#include "Rand.hpp"
// 7 days

View File

@ -1,10 +1,9 @@
#pragma once
#include "core/Core.hpp"
#include "servers/CNShardServer.hpp"
#include "Items.hpp"
#include "PlayerManager.hpp"
#include <vector>
#include <map>
struct VendorListing {
int sort, type, id;

View File

@ -23,6 +23,7 @@
#include <string>
#include <locale>
#include <codecvt>
#include <tuple>
// yes this is ugly, but this is needed to zero out the memory so we don't have random stackdata in our structs.
#define INITSTRUCT(T, x) T x; \

View File

@ -1,13 +1,15 @@
#include "servers/CNLoginServer.hpp"
#include "core/CNShared.hpp"
#include "db/Database.hpp"
#include "PlayerManager.hpp"
#include "Items.hpp"
#include <regex>
#include "bcrypt/BCrypt.hpp"
#include "PlayerManager.hpp"
#include "Items.hpp"
#include "settings.hpp"
#include <regex>
std::map<CNSocket*, CNLoginData> CNLoginServer::loginSessions;
CNLoginServer::CNLoginServer(uint16_t p) {

View File

@ -1,6 +1,7 @@
#pragma once
#include "core/Core.hpp"
#include "Player.hpp"
#include <map>

View File

@ -1,10 +1,12 @@
#include "servers/CNShardServer.hpp"
#include "core/Core.hpp"
#include "core/CNShared.hpp"
#include "db/Database.hpp"
#include "servers/Monitor.hpp"
#include "servers/CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "MobAI.hpp"
#include "core/CNShared.hpp"
#include "settings.hpp"
#include "TableData.hpp" // for flush()

View File

@ -3,6 +3,7 @@
#include "core/Core.hpp"
#include <map>
#include <list>
#define REGISTER_SHARD_PACKET(pactype, handlr) CNShardServer::ShardPackets[pactype] = handlr;
#define REGISTER_SHARD_TIMER(handlr, delta) CNShardServer::Timers.push_back(TimerEvent(handlr, delta));

View File

@ -1,8 +1,10 @@
#include "servers/Monitor.hpp"
#include "servers/CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "Chat.hpp"
#include "Email.hpp"
#include "servers/Monitor.hpp"
#include "settings.hpp"
#include <cstdio>

View File

@ -2,9 +2,6 @@
#include "core/Core.hpp"
#include <list>
#include <mutex>
namespace Monitor {
SOCKET init();
bool acceptConnection(SOCKET, uint16_t);

View File

@ -1,9 +1,10 @@
#include <iostream>
#include "settings.hpp"
#include "core/CNStructs.hpp" // so we get the ACADEMY definition
#include "INIReader.hpp"
// so we get the ACADEMY definition
#include "core/CNStructs.hpp"
#include <iostream>
// defaults :)
int settings::VERBOSITY = 1;

View File

@ -1,5 +1,7 @@
#pragma once
#include <string>
namespace settings {
extern int VERBOSITY;
extern bool SANDBOX;

2
vendor/JSON.hpp vendored
View File

@ -27,6 +27,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifndef INCLUDE_NLOHMANN_JSON_HPP_
#define INCLUDE_NLOHMANN_JSON_HPP_