Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 618666de43 | |||
| 5c74ecdd72 |
@@ -8,6 +8,7 @@ This game is inspired by classic 2D RPGs, as well as more modern sandbox MMOs. T
|
||||
|
||||
Tortuga's full documentation can be found in a separate branch, see [Tortuga/docs](https://github.com/Ratstail91/Tortuga/tree/docs).
|
||||
For Tortuga's primary documentation, please read the [Tortuga Game Design Document](https://github.com/Ratstail91/Tortuga/blob/docs/Tortuga%20Game%20Design%20Document.docx?raw=true).
|
||||
For a list of known bugs, see the [GitHub bug tracker](https://github.com/Ratstail91/Tortuga/issues).
|
||||
|
||||
## External Dependencies
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
#include "restart.hpp"
|
||||
#include "clean_up.hpp"
|
||||
|
||||
#include "channels.hpp"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
//Public access members
|
||||
//-------------------------
|
||||
|
||||
Restart::Restart(
|
||||
CleanUp::CleanUp(
|
||||
ConfigUtility* const argConfig,
|
||||
UDPNetworkUtility* const argNetwork,
|
||||
int* const argClientIndex,
|
||||
@@ -77,7 +77,7 @@ Restart::Restart(
|
||||
startTick = std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
Restart::~Restart() {
|
||||
CleanUp::~CleanUp() {
|
||||
//
|
||||
}
|
||||
|
||||
@@ -85,24 +85,23 @@ Restart::~Restart() {
|
||||
//Frame loop
|
||||
//-------------------------
|
||||
|
||||
void Restart::Update(double delta) {
|
||||
void CleanUp::Update(double delta) {
|
||||
if (std::chrono::steady_clock::now() - startTick > std::chrono::duration<int>(10)) {
|
||||
QuitEvent();
|
||||
}
|
||||
|
||||
while(network.Receive()) {
|
||||
//EAT INCOMING PACKETS
|
||||
}
|
||||
//BUGFIX: Eat incoming packets
|
||||
while(network.Receive());
|
||||
}
|
||||
|
||||
void Restart::RenderFrame() {
|
||||
void CleanUp::RenderFrame() {
|
||||
SDL_FillRect(GetScreen(), 0, 0);
|
||||
Render(GetScreen());
|
||||
SDL_Flip(GetScreen());
|
||||
fps.Calculate();
|
||||
}
|
||||
|
||||
void Restart::Render(SDL_Surface* const screen) {
|
||||
void CleanUp::Render(SDL_Surface* const screen) {
|
||||
backButton.DrawTo(screen);
|
||||
font.DrawStringTo("You have been disconnected.", screen, 50, 30);
|
||||
}
|
||||
@@ -111,32 +110,28 @@ void Restart::Render(SDL_Surface* const screen) {
|
||||
//Event handlers
|
||||
//-------------------------
|
||||
|
||||
void Restart::QuitEvent() {
|
||||
SetNextScene(SceneList::MAINMENU);
|
||||
void CleanUp::QuitEvent() {
|
||||
SetNextScene(SceneList::QUIT);
|
||||
}
|
||||
|
||||
void Restart::MouseMotion(SDL_MouseMotionEvent const& motion) {
|
||||
void CleanUp::MouseMotion(SDL_MouseMotionEvent const& motion) {
|
||||
backButton.MouseMotion(motion);
|
||||
}
|
||||
|
||||
void Restart::MouseButtonDown(SDL_MouseButtonEvent const& button) {
|
||||
void CleanUp::MouseButtonDown(SDL_MouseButtonEvent const& button) {
|
||||
backButton.MouseButtonDown(button);
|
||||
}
|
||||
|
||||
void Restart::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
||||
void CleanUp::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
||||
if (backButton.MouseButtonUp(button) == Button::State::HOVER) {
|
||||
QuitEvent();
|
||||
SetNextScene(SceneList::MAINMENU);
|
||||
}
|
||||
}
|
||||
|
||||
void Restart::KeyDown(SDL_KeyboardEvent const& key) {
|
||||
switch(key.keysym.sym) {
|
||||
case SDLK_ESCAPE:
|
||||
QuitEvent();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Restart::KeyUp(SDL_KeyboardEvent const& key) {
|
||||
void CleanUp::KeyDown(SDL_KeyboardEvent const& key) {
|
||||
//
|
||||
}
|
||||
|
||||
void CleanUp::KeyUp(SDL_KeyboardEvent const& key) {
|
||||
//
|
||||
}
|
||||
@@ -19,8 +19,8 @@
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
#ifndef RESTART_HPP_
|
||||
#define RESTART_HPP_
|
||||
#ifndef CLEANUP_HPP_
|
||||
#define CLEANUP_HPP_
|
||||
|
||||
//network
|
||||
#include "udp_network_utility.hpp"
|
||||
@@ -44,10 +44,10 @@
|
||||
//std namespace
|
||||
#include <chrono>
|
||||
|
||||
class Restart : public BaseScene {
|
||||
class CleanUp : public BaseScene {
|
||||
public:
|
||||
//Public access members
|
||||
Restart(
|
||||
CleanUp(
|
||||
ConfigUtility* const argConfig,
|
||||
UDPNetworkUtility* const argNetwork,
|
||||
int* const argClientIndex,
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
std::map<int, CharacterData>* argCharacterMap,
|
||||
std::map<int, EnemyData>* argEnemyMap
|
||||
);
|
||||
~Restart();
|
||||
~CleanUp();
|
||||
|
||||
protected:
|
||||
//Frame loop
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "lobby_menu.hpp"
|
||||
#include "in_world.hpp"
|
||||
#include "in_combat.hpp"
|
||||
#include "restart.hpp"
|
||||
#include "clean_up.hpp"
|
||||
|
||||
//-------------------------
|
||||
//Public access members
|
||||
@@ -132,8 +132,8 @@ void ClientApplication::LoadScene(SceneList sceneIndex) {
|
||||
case SceneList::INCOMBAT:
|
||||
activeScene = new InCombat(&config, &network, &clientIndex, &accountIndex, &characterIndex, &combatMap, &characterMap, &enemyMap);
|
||||
break;
|
||||
case SceneList::RESTART:
|
||||
activeScene = new Restart(&config, &network, &clientIndex, &accountIndex, &characterIndex, &combatMap, &characterMap, &enemyMap);
|
||||
case SceneList::CLEANUP:
|
||||
activeScene = new CleanUp(&config, &network, &clientIndex, &accountIndex, &characterIndex, &combatMap, &characterMap, &enemyMap);
|
||||
break;
|
||||
default:
|
||||
throw(std::logic_error("Failed to recognize the scene index"));
|
||||
|
||||
+4
-11
@@ -123,7 +123,7 @@ void InCombat::Render(SDL_Surface* const screen) {
|
||||
void InCombat::QuitEvent() {
|
||||
//exit the game AND the server
|
||||
RequestDisconnect();
|
||||
SetNextScene(SceneList::MAINMENU);
|
||||
SetNextScene(SceneList::QUIT);
|
||||
}
|
||||
|
||||
void InCombat::MouseMotion(SDL_MouseMotionEvent const& motion) {
|
||||
@@ -139,11 +139,7 @@ void InCombat::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
||||
}
|
||||
|
||||
void InCombat::KeyDown(SDL_KeyboardEvent const& key) {
|
||||
switch(key.keysym.sym) {
|
||||
case SDLK_ESCAPE:
|
||||
QuitEvent();
|
||||
break;
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
void InCombat::KeyUp(SDL_KeyboardEvent const& key) {
|
||||
@@ -167,7 +163,7 @@ void InCombat::HandlePacket(SerialPacket* const argPacket) {
|
||||
}
|
||||
|
||||
void InCombat::HandleDisconnect(SerialPacket* const) {
|
||||
SetNextScene(SceneList::RESTART);
|
||||
SetNextScene(SceneList::CLEANUP);
|
||||
}
|
||||
|
||||
//TODO: more network handlers
|
||||
@@ -201,10 +197,7 @@ void InCombat::SendPlayerUpdate() {
|
||||
// newPacket.motion = localCharacter->motion;
|
||||
// newPacket.stats = localCharacter->stats;
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||
|
||||
network.SendTo(Channels::SERVER, &newPacket);
|
||||
}
|
||||
|
||||
+4
-12
@@ -135,7 +135,7 @@ void InWorld::Render(SDL_Surface* const screen) {
|
||||
|
||||
//draw characters
|
||||
for (auto& it : characterMap) {
|
||||
//TODO: drawing order according to Y origin
|
||||
//BUG: #29 drawing order according to Y origin
|
||||
it.second.DrawTo(screen, camera.x, camera.y);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ void InWorld::Render(SDL_Surface* const screen) {
|
||||
void InWorld::QuitEvent() {
|
||||
//exit the game AND the server
|
||||
RequestDisconnect();
|
||||
SetNextScene(SceneList::MAINMENU);
|
||||
SetNextScene(SceneList::QUIT);
|
||||
}
|
||||
|
||||
void InWorld::MouseMotion(SDL_MouseMotionEvent const& motion) {
|
||||
@@ -176,11 +176,6 @@ void InWorld::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
||||
|
||||
void InWorld::KeyDown(SDL_KeyboardEvent const& key) {
|
||||
switch(key.keysym.sym) {
|
||||
case SDLK_ESCAPE: {
|
||||
QuitEvent();
|
||||
}
|
||||
break;
|
||||
|
||||
//player movement
|
||||
case SDLK_LEFT:
|
||||
if (localCharacter) {
|
||||
@@ -282,7 +277,7 @@ void InWorld::HandlePacket(SerialPacket* const argPacket) {
|
||||
}
|
||||
|
||||
void InWorld::HandleDisconnect(SerialPacket* const argPacket) {
|
||||
SetNextScene(SceneList::RESTART);
|
||||
SetNextScene(SceneList::CLEANUP);
|
||||
}
|
||||
|
||||
void InWorld::HandleCharacterNew(CharacterPacket* const argPacket) {
|
||||
@@ -386,10 +381,7 @@ void InWorld::SendPlayerUpdate() {
|
||||
newPacket.motion = localCharacter->motion;
|
||||
newPacket.stats = localCharacter->stats;
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||
|
||||
network.SendTo(Channels::SERVER, &newPacket);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,9 @@ LobbyMenu::LobbyMenu(
|
||||
|
||||
//set the server list's position
|
||||
listBox = {300, 50, 200, font.GetCharH()};
|
||||
|
||||
//BUGFIX: Eat incoming packets
|
||||
while(network.Receive());
|
||||
}
|
||||
|
||||
LobbyMenu::~LobbyMenu() {
|
||||
@@ -187,11 +190,7 @@ void LobbyMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
||||
}
|
||||
|
||||
void LobbyMenu::KeyDown(SDL_KeyboardEvent const& key) {
|
||||
switch(key.keysym.sym) {
|
||||
case SDLK_ESCAPE:
|
||||
SetNextScene(SceneList::MAINMENU);
|
||||
break;
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
void LobbyMenu::KeyUp(SDL_KeyboardEvent const& key) {
|
||||
@@ -225,7 +224,7 @@ void LobbyMenu::HandleBroadcastResponse(ServerPacket* const argPacket) {
|
||||
server.playerCount = argPacket->playerCount;
|
||||
server.version = argPacket->version;
|
||||
|
||||
//NOTE: Check compatibility here
|
||||
//Checking compatibility
|
||||
server.compatible = server.version == NETWORK_VERSION;
|
||||
|
||||
//push
|
||||
|
||||
@@ -113,11 +113,7 @@ void MainMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
||||
}
|
||||
|
||||
void MainMenu::KeyDown(SDL_KeyboardEvent const& key) {
|
||||
switch(key.keysym.sym) {
|
||||
case SDLK_ESCAPE:
|
||||
QuitEvent();
|
||||
break;
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
void MainMenu::KeyUp(SDL_KeyboardEvent const& key) {
|
||||
|
||||
@@ -90,11 +90,7 @@ void OptionsMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
||||
}
|
||||
|
||||
void OptionsMenu::KeyDown(SDL_KeyboardEvent const& key) {
|
||||
switch(key.keysym.sym) {
|
||||
case SDLK_ESCAPE:
|
||||
SetNextScene(SceneList::MAINMENU);
|
||||
break;
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
void OptionsMenu::KeyUp(SDL_KeyboardEvent const& key) {
|
||||
|
||||
@@ -35,7 +35,7 @@ enum class SceneList {
|
||||
LOBBYMENU,
|
||||
INWORLD,
|
||||
INCOMBAT,
|
||||
RESTART,
|
||||
CLEANUP,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,10 +53,7 @@ struct CharacterData {
|
||||
//base statistics
|
||||
Statistics stats;
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||
|
||||
//methods
|
||||
void Update(double delta);
|
||||
|
||||
@@ -41,12 +41,7 @@ struct EnemyData {
|
||||
//gameplay
|
||||
Statistics stats;
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
|
||||
//TODO: rewards
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs, rewards
|
||||
|
||||
//active gameplay members
|
||||
//NOTE: these are lost when unloaded
|
||||
|
||||
@@ -44,10 +44,7 @@ struct CharacterPacket : SerialPacketBase {
|
||||
//gameplay
|
||||
Statistics stats;
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -40,7 +40,7 @@ struct CombatPacket : SerialPacketBase {
|
||||
int mapIndex;
|
||||
Vector2 origin;
|
||||
|
||||
//TODO: rewards
|
||||
//TODO: gameplay components: rewards
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -33,12 +33,7 @@ struct EnemyPacket : SerialPacketBase {
|
||||
//gameplay
|
||||
Statistics stats;
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
|
||||
//TODO: rewards
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs, rewards
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -148,7 +148,6 @@ void deserializePacket(SerialPacketBase* packet, void* buffer) {
|
||||
case SerialPacketType::COMBAT_DELETE:
|
||||
case SerialPacketType::COMBAT_UPDATE:
|
||||
|
||||
//TODO: is this the best fit?
|
||||
case SerialPacketType::COMBAT_ENTER_REQUEST:
|
||||
case SerialPacketType::COMBAT_ENTER_RESPONSE:
|
||||
case SerialPacketType::COMBAT_EXIT_REQUEST:
|
||||
|
||||
@@ -45,10 +45,7 @@ void serializeCharacter(CharacterPacket* packet, void* buffer) {
|
||||
serializeStatistics(&packet->stats, buffer);
|
||||
buffer = reinterpret_cast<char*>(buffer) + sizeof(Statistics);
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||
}
|
||||
|
||||
void deserializeCharacter(CharacterPacket* packet, void* buffer) {
|
||||
@@ -73,8 +70,5 @@ void deserializeCharacter(CharacterPacket* packet, void* buffer) {
|
||||
deserializeStatistics(&packet->stats, buffer);
|
||||
buffer = reinterpret_cast<char*>(buffer) + sizeof(Statistics);
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ void serializeCombat(CombatPacket* packet, void* buffer) {
|
||||
SERIALIZE(buffer, &packet->origin.x, sizeof(double));
|
||||
SERIALIZE(buffer, &packet->origin.y, sizeof(double));
|
||||
|
||||
//TODO: rewards
|
||||
//TODO: gameplay components: rewards
|
||||
}
|
||||
|
||||
void deserializeCombat(CombatPacket* packet, void* buffer) {
|
||||
@@ -60,5 +60,5 @@ void deserializeCombat(CombatPacket* packet, void* buffer) {
|
||||
DESERIALIZE(buffer, &packet->origin.x, sizeof(double));
|
||||
DESERIALIZE(buffer, &packet->origin.y, sizeof(double));
|
||||
|
||||
//TODO: rewards
|
||||
//TODO: gameplay components: rewards
|
||||
}
|
||||
|
||||
@@ -37,12 +37,7 @@ void serializeEnemy(EnemyPacket* packet, void* buffer) {
|
||||
serializeStatistics(&packet->stats, buffer);
|
||||
buffer = reinterpret_cast<char*>(buffer) + sizeof(Statistics);
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
|
||||
//TODO: rewards
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs, rewards
|
||||
}
|
||||
|
||||
void deserializeEnemy(EnemyPacket* packet, void* buffer) {
|
||||
@@ -57,10 +52,5 @@ void deserializeEnemy(EnemyPacket* packet, void* buffer) {
|
||||
deserializeStatistics(&packet->stats, buffer);
|
||||
buffer = reinterpret_cast<char*>(buffer) + sizeof(Statistics);
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
|
||||
//TODO: rewards
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs, rewards
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
//DOCS: memset() is used before sending a packet to remove old data; you don't want to send sensitive data over the network
|
||||
//BUGFIX: memset() is used before sending a packet to remove old data; you don't want to send sensitive data over the network
|
||||
//NOTE: don't confuse SerialPacket with UDPpacket
|
||||
|
||||
void UDPNetworkUtility::Open(int port) {
|
||||
|
||||
@@ -58,7 +58,7 @@ static const char* DELETE_CHARACTER = "DELETE FROM Characters WHERE uid = ?;";
|
||||
//Define the methods
|
||||
//-------------------------
|
||||
|
||||
//TODO: default stats as a parameter? This would be good for differing beggining states or multiple classes
|
||||
//NOTE: default stats as a parameter would be good for different beggining states or multiple classes
|
||||
int CharacterManager::CreateCharacter(int owner, std::string handle, std::string avatar) {
|
||||
//Create the character, failing if it exists
|
||||
sqlite3_stmt* statement = nullptr;
|
||||
@@ -157,10 +157,7 @@ int CharacterManager::LoadCharacter(int owner, std::string handle, std::string a
|
||||
newChar.stats.evasion = sqlite3_column_double(statement, 20);
|
||||
newChar.stats.luck = sqlite3_column_double(statement, 21);
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||
|
||||
//finish the routine
|
||||
sqlite3_finalize(statement);
|
||||
@@ -217,10 +214,7 @@ int CharacterManager::SaveCharacter(int uid) {
|
||||
ret |= sqlite3_bind_double(statement, 17, character.stats.evasion) != SQLITE_OK;
|
||||
ret |= sqlite3_bind_double(statement, 18, character.stats.luck) != SQLITE_OK;
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||
|
||||
//check for binding errors
|
||||
if (ret) {
|
||||
|
||||
@@ -338,6 +338,7 @@ void ServerApplication::HandleRegionRequest(RegionPacket* const argPacket) {
|
||||
//-------------------------
|
||||
|
||||
void ServerApplication::HandleCharacterNew(CharacterPacket* const argPacket) {
|
||||
//BUG: #27 Characters can be created with an invalid account index
|
||||
//NOTE: misnomer, try to load the character first
|
||||
int characterIndex = characterMgr.LoadCharacter(argPacket->accountIndex, argPacket->handle, argPacket->avatar);
|
||||
|
||||
@@ -413,10 +414,7 @@ void ServerApplication::HandleCharacterUpdate(CharacterPacket* const argPacket)
|
||||
|
||||
character->stats = argPacket->stats;
|
||||
|
||||
//TODO: equipment
|
||||
//TODO: items
|
||||
//TODO: buffs
|
||||
//TODO: debuffs
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||
|
||||
PumpPacket(argPacket);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
TODO: rename restart scene to cleanup scene
|
||||
TODO: encapsulate the data structures
|
||||
TODO: Get the rooms working
|
||||
|
||||
TODO: Rejection packets
|
||||
TODO: Authentication
|
||||
TODO: server is slaved to the client
|
||||
|
||||
TODO: I need to keep the documentation up to date. Namely, the GDD is getting out of date.
|
||||
TODO: I completely forgot about status ailments
|
||||
TODO: Time delay for requesting region packets
|
||||
TODO: command line parameters overriding config.cfg settings
|
||||
|
||||
Reference in New Issue
Block a user