Minor code tweaks, this needs a lot of forethought

This commit is contained in:
Kayne Ruse
2014-03-16 00:28:19 +11:00
parent 9db86c19f6
commit e4bfbfb906
4 changed files with 43 additions and 13 deletions
+6 -6
View File
@@ -35,21 +35,21 @@ InWorld::InWorld(ConfigUtility* const argConfig, UDPNetworkUtility* const argNet
clientIndex(*argClientIndex) clientIndex(*argClientIndex)
{ {
//setup the utility objects //setup the utility objects
image.LoadSurface(config["dir.interface"] + "button_menu.bmp"); buttonImage.LoadSurface(config["dir.interface"] + "button_menu.bmp");
image.SetClipH(image.GetClipH()/3); buttonImage.SetClipH(buttonImage.GetClipH()/3);
font.LoadSurface(config["dir.fonts"] + "pk_white_8.bmp"); font.LoadSurface(config["dir.fonts"] + "pk_white_8.bmp");
//pass the utility objects //pass the utility objects
disconnectButton.SetImage(&image); disconnectButton.SetImage(&buttonImage);
disconnectButton.SetFont(&font); disconnectButton.SetFont(&font);
shutDownButton.SetImage(&image); shutDownButton.SetImage(&buttonImage);
shutDownButton.SetFont(&font); shutDownButton.SetFont(&font);
//set the button positions //set the button positions
disconnectButton.SetX(50); disconnectButton.SetX(50);
disconnectButton.SetY(50 + image.GetClipH() * 0); disconnectButton.SetY(50 + buttonImage.GetClipH() * 0);
shutDownButton.SetX(50); shutDownButton.SetX(50);
shutDownButton.SetY(50 + image.GetClipH() * 1); shutDownButton.SetY(50 + buttonImage.GetClipH() * 1);
//set the button texts //set the button texts
disconnectButton.SetText("Disconnect"); disconnectButton.SetText("Disconnect");
+27 -5
View File
@@ -22,17 +22,29 @@
#ifndef INWORLD_HPP_ #ifndef INWORLD_HPP_
#define INWORLD_HPP_ #define INWORLD_HPP_
#include "base_scene.hpp" //maps
#include "map_generator.hpp"
#include "map_file_format.hpp"
#include "region_pager.hpp"
#include "config_utility.hpp" //networking
#include "udp_network_utility.hpp" #include "udp_network_utility.hpp"
#include "network_packet.hpp" #include "network_packet.hpp"
#include "serial.hpp" #include "serial.hpp"
//graphics
#include "image.hpp" #include "image.hpp"
#include "raster_font.hpp" #include "raster_font.hpp"
#include "button.hpp" #include "button.hpp"
//common
#include "config_utility.hpp"
//client
#include "base_scene.hpp"
#include "player_character.hpp" #include "player_character.hpp"
//STL
#include <map> #include <map>
class InWorld : public BaseScene { class InWorld : public BaseScene {
@@ -66,16 +78,26 @@ protected:
void RequestDisconnect(); void RequestDisconnect();
void RequestShutDown(); void RequestShutDown();
//global //globals
ConfigUtility& config; ConfigUtility& config;
UDPNetworkUtility& network; UDPNetworkUtility& network;
int& clientIndex; int& clientIndex;
//members //graphics
Image image; Image buttonImage;
RasterFont font; RasterFont font;
//map
RegionPager<MapGenerator, MapFileFormat> mapPager;
//UI
Button disconnectButton; Button disconnectButton;
Button shutDownButton; Button shutDownButton;
struct {
int x = 0, y = 0;
} camera;
//game
std::map<int, PlayerCharacter> playerCharacters; std::map<int, PlayerCharacter> playerCharacters;
PlayerCharacter* localCharacter = nullptr; PlayerCharacter* localCharacter = nullptr;
int playerIndex = -1; int playerIndex = -1;
+1 -1
View File
@@ -116,6 +116,6 @@ union NetworkPacket {
#pragma pack(pop) #pragma pack(pop)
#define PACKET_BUFFER_SIZE std::max(sizeof(NetworkPacket), REGION_WIDTH * REGION_HEIGHT * REGION_DEPTH * sizeof(Region::type_t) + sizeof(NetworkPacket::Metadata)) #define PACKET_BUFFER_SIZE std::max(sizeof(NetworkPacket), REGION_WIDTH * REGION_HEIGHT * REGION_DEPTH * sizeof(Region::type_t) + sizeof(int) * 2 + sizeof(NetworkPacket::Metadata))
#endif #endif
+9 -1
View File
@@ -81,7 +81,15 @@ void serializeRegion(NetworkPacket* packet, char* buffer) {
memcpy(buffer, &packet->meta.type, sizeof(NetworkPacket::Type)); memcpy(buffer, &packet->meta.type, sizeof(NetworkPacket::Type));
buffer += sizeof(NetworkPacket::Type); buffer += sizeof(NetworkPacket::Type);
//TODO //TODO: incomplete
/* for (register int i = 0; i < packet->mapInfo.region->GetWidth(); i++) {
for (register int j = 0; j < packet->mapInfo.region->GetHeight(); j++) {
for (register int k = 0; k < packet->mapInfo.region->GetDepth(); k++) {
memcpy(buffer, &packet->mapInfo.region->GetTile(i, j, k), sizeof(Region::type_t));
buffer += sizeof(Region::type_t);
}
}
}*/
} }
//------------------------- //-------------------------