Client builds & runs, can't test the gameplay without the server

SDL_ttf is now being initialized, and all usages of fonts are now checked for nullptr.
A bug where the renderer's logical size was not properly set has been fixed.
The FPS counter is disabled for now.
This commit is contained in:
2015-08-20 20:45:13 +10:00
parent dc5b09a9b4
commit 3d6509b5a5
15 changed files with 100 additions and 22 deletions
+1 -4
View File
@@ -6,9 +6,6 @@ CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
#source
CXXSRC=$(wildcard *.cpp)
#DEBUG: Overwrite the wildcard
CXXSRC=world_logic.cpp
#objects
OBJDIR=obj
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
@@ -19,7 +16,7 @@ OUT=$(addprefix $(OUTDIR)/,client.a)
#targets
all: $(OBJ) $(OUT)
# ar -crs $(OUT) $(OBJ)
ar -crs $(OUT) $(OBJ)
$(OBJ): | $(OBJDIR)
+5 -4
View File
@@ -69,7 +69,7 @@ void World::hCharacterCreate(CharacterPacket* const argPacket) {
//fill the character's info
character->SetHandle(argPacket->handle);
character->SetAvatar(argPacket->avatar);
character->SetAvatar(GetRenderer(), argPacket->avatar);
character->SetOwner(argPacket->accountIndex);
character->SetOrigin(argPacket->origin);
character->SetMotion(argPacket->motion);
@@ -82,8 +82,8 @@ void World::hCharacterCreate(CharacterPacket* const argPacket) {
localCharacter = static_cast<LocalCharacter*>(character);
//focus the camera on this character's sprite
camera.marginX = (camera.width / 2 - localCharacter->GetSprite()->GetImage()->GetClipW() / 2);
camera.marginY = (camera.height/ 2 - localCharacter->GetSprite()->GetImage()->GetClipH() / 2);
camera.marginX = (camera.width / 2 - localCharacter->GetSprite()->GetClipW() / 2);
camera.marginY = (camera.height/ 2 - localCharacter->GetSprite()->GetClipH() / 2);
//focus on this character's info
characterIndex = argPacket->characterIndex;
@@ -135,6 +135,7 @@ void World::hCharacterDelete(CharacterPacket* const argPacket) {
void World::hQueryCharacterExists(CharacterPacket* const argPacket) {
//prevent a double message about this player's character
//TODO: why is this commented out?
// if (argPacket->accountIndex == accountIndex) {
// return;
// }
@@ -152,7 +153,7 @@ void World::hQueryCharacterExists(CharacterPacket* const argPacket) {
character->SetMotion(argPacket->motion);
character->SetBounds({CHARACTER_BOUNDS_X, CHARACTER_BOUNDS_Y, CHARACTER_BOUNDS_WIDTH, CHARACTER_BOUNDS_HEIGHT});
character->SetHandle(argPacket->handle);
character->SetAvatar(argPacket->avatar);
character->SetAvatar(GetRenderer(), argPacket->avatar);
character->SetOwner(argPacket->accountIndex);
character->CorrectSprite();
+3 -3
View File
@@ -52,7 +52,7 @@ void World::CheckHeartBeat() {
if (attemptedBeats > 2) {
//escape to the disconnect screen
SendDisconnectRequest();
SetNextScene(SceneList::DISCONNECTEDSCREEN);
SetSceneSignal(SceneSignal::DISCONNECTEDSCREEN);
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "Error: Lost connection to the server";
}
else {
@@ -122,13 +122,13 @@ void World::hLogoutResponse(ClientPacket* const argPacket) {
void World::hDisconnectResponse(ClientPacket* const argPacket) {
hLogoutResponse(argPacket);//shortcut
SetNextScene(SceneList::DISCONNECTEDSCREEN);
SetSceneSignal(SceneSignal::DISCONNECTEDSCREEN);
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "You have successfully logged out";
}
void World::hAdminDisconnectForced(ClientPacket* const argPacket) {
hDisconnectResponse(argPacket);//shortcut
SetNextScene(SceneList::DISCONNECTEDSCREEN);
SetSceneSignal(SceneSignal::DISCONNECTEDSCREEN);
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "You have been forcibly disconnected by the server";
}
+11
View File
@@ -43,6 +43,13 @@ World::World(int* const argClientIndex, int* const argAccountIndex):
buttonImage.Load(GetRenderer(), config["dir.interface"] + "button.png");
font = TTF_OpenFont(config["client.font"].c_str(), 12);
//check that the font loaded
if (!font) {
std::ostringstream msg;
msg << "Failed to load a font file; " << SDL_GetError();
throw(std::runtime_error(msg.str()));
}
//setup the buttons
disconnectButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
disconnectButton.SetText(GetRenderer(), font, "Disconnect", {255, 255, 255, 255});
@@ -216,6 +223,10 @@ void World::MouseButtonUp(SDL_MouseButtonEvent const& event) {
}
}
void World::MouseWheel(SDL_MouseWheelEvent const& event) {
//
}
void World::KeyDown(SDL_KeyboardEvent const& key) {
//hotkeys
switch(key.keysym.sym) {
+1 -1
View File
@@ -103,7 +103,7 @@ void World::UpdateMap() {
}
else if (regionChecksum(region) == 0) {
//checksum failed
//NOTE: this patches bug #45, but does not resolve it
//BUG: #45 Regions occasionally lose their tile data; this patches the issue, but does not resolve it
regionPager.UnloadIf([region](Region const& ref) -> bool {
//remove the erroneous region
return region == &ref;
+2 -2
View File
@@ -55,7 +55,7 @@ void World::hMonsterCreate(MonsterPacket* const argPacket) {
//fill the monster's info
monster->SetHandle(argPacket->handle);
monster->SetAvatar(argPacket->avatar);
monster->SetAvatar(GetRenderer(), argPacket->avatar);
monster->SetBounds(argPacket->bounds);
monster->SetOrigin(argPacket->origin);
monster->SetMotion(argPacket->motion);
@@ -89,7 +89,7 @@ void World::hQueryMonsterExists(MonsterPacket* const argPacket) {
//fill the monster's info
monster->SetHandle(argPacket->handle);
monster->SetAvatar(argPacket->avatar);
monster->SetAvatar(GetRenderer(), argPacket->avatar);
monster->SetBounds(argPacket->bounds);
monster->SetOrigin(argPacket->origin);
monster->SetMotion(argPacket->motion);