-
-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: worlds instantiated by game
- Loading branch information
Showing
17 changed files
with
158 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Canary - A free and open-source MMORPG server emulator | ||
* Copyright (©) 2019-2024 OpenTibiaBR <[email protected]> | ||
* Repository: https://github.com/opentibiabr/canary | ||
* License: https://github.com/opentibiabr/canary/blob/main/LICENSE | ||
* Contributors: https://github.com/opentibiabr/canary/graphs/contributors | ||
* Website: https://docs.opentibiabr.com/ | ||
*/ | ||
|
||
#include "pch.hpp" | ||
|
||
#include "game/worlds/gameworlds.hpp" | ||
#include "game/game_definitions.hpp" | ||
|
||
[[nodiscard]] const char* Worlds::getIp(uint16_t id) { | ||
return ip[id]; | ||
} | ||
|
||
[[nodiscard]] uint16_t Worlds::getPort(uint16_t id) { | ||
return port[id]; | ||
} | ||
|
||
[[nodiscard]] std::string Worlds::getName(uint16_t id) { | ||
return name[id]; | ||
} | ||
|
||
[[nodiscard]] uint16_t Worlds::getId() const noexcept { | ||
return id; | ||
} | ||
|
||
void Worlds::setId(uint16_t newId) noexcept { | ||
id = newId; | ||
} | ||
|
||
void Worlds::setType(WorldType_t newType) noexcept { | ||
type = newType; | ||
} | ||
|
||
[[nodiscard]] WorldType_t Worlds::getType() const noexcept { | ||
return type; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Canary - A free and open-source MMORPG server emulator | ||
* Copyright (©) 2019-2024 OpenTibiaBR <[email protected]> | ||
* Repository: https://github.com/opentibiabr/canary | ||
* License: https://github.com/opentibiabr/canary/blob/main/LICENSE | ||
* Contributors: https://github.com/opentibiabr/canary/graphs/contributors | ||
* Website: https://docs.opentibiabr.com/ | ||
*/ | ||
|
||
#pragma once | ||
|
||
struct World { | ||
World(uint16_t id, std::string name, std::string ip, uint16_t port) : | ||
id(id), name(std::move(name)), ip(std::move(ip)), port(port) { } | ||
|
||
std::string name = ""; | ||
std::string ip = ""; | ||
|
||
uint16_t id = 0; | ||
uint16_t port = 7171; | ||
}; | ||
|
||
class Worlds { | ||
public: | ||
void setId(uint16_t id) noexcept; | ||
[[nodiscard]] const char* getIp(uint16_t id); | ||
[[nodiscard]] uint16_t getPort(uint16_t id); | ||
[[nodiscard]] std::string getName(uint16_t id); | ||
[[nodiscard]] uint16_t getId() const noexcept; | ||
void setType(WorldType_t type) noexcept; | ||
[[nodiscard]] WorldType_t getType() const noexcept; | ||
|
||
[[nodiscard]] const std::vector<World> &getWorlds() const noexcept { | ||
return worlds; | ||
} | ||
|
||
private: | ||
std::vector<GameWorld> worlds; | ||
|
||
uint16_t id = 0; | ||
std::map<uint16_t, const char*> ip; | ||
std::map<uint16_t, std::string> name; | ||
WorldType_t type = WORLD_TYPE_PVP; | ||
std::map<uint16_t, uint16_t> port; | ||
}; |
Oops, something went wrong.