Imported updates from Codebase
This commit is contained in:
@@ -0,0 +1,96 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "button.hpp"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
Button::Button():
|
||||||
|
Button(0,0, nullptr, nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Button::Button(Sint16 i, Sint16 j, SDL_Surface* imageSurface, SDL_Surface* fontSurface, std::string s) {
|
||||||
|
x = i;
|
||||||
|
y = j;
|
||||||
|
state = State::NORMAL;
|
||||||
|
|
||||||
|
//graphical stuff
|
||||||
|
image.SetSurface(imageSurface);
|
||||||
|
image.SetClipH(image.GetClipH() / 3); //3 phases
|
||||||
|
font.SetSurface(fontSurface);
|
||||||
|
|
||||||
|
SetText(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
Button::State Button::MouseMotion(SDL_MouseMotionEvent& motion) {
|
||||||
|
if (motion.state & SDL_BUTTON_LMASK) {
|
||||||
|
return CalcState(motion.x, motion.y, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return CalcState(motion.x, motion.y, false);
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
Button::State Button::MouseButtonDown(SDL_MouseButtonEvent& button) {
|
||||||
|
if (button.button == SDL_BUTTON_LEFT) {
|
||||||
|
return CalcState(button.x, button.y, true);
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
Button::State Button::MouseButtonUp(SDL_MouseButtonEvent& button) {
|
||||||
|
if (button.button == SDL_BUTTON_LEFT) {
|
||||||
|
return CalcState(button.x, button.y, false);
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button::DrawTo(SDL_Surface* const dest) {
|
||||||
|
image.DrawTo(dest, x, y);
|
||||||
|
font.DrawStringTo(text, dest, textX, textY);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Button::SetText(std::string s) {
|
||||||
|
//one line
|
||||||
|
text = s;
|
||||||
|
textX = (image.GetClipW() / 2 + x) - (font.GetClipW() * text.size() / 2);
|
||||||
|
textY = (image.GetClipH() / 2 + y) - (font.GetClipH() / 2);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
Button::State Button::CalcState(Sint16 i, Sint16 j, bool leftPressed) {
|
||||||
|
if (i < x || i > (x + image.GetClipW()) ||
|
||||||
|
j < y || j > (y + image.GetClipH())
|
||||||
|
) {
|
||||||
|
image.SetClipY(0);
|
||||||
|
return state = State::NORMAL;
|
||||||
|
}
|
||||||
|
if (leftPressed) {
|
||||||
|
image.SetClipY(image.GetClipH()*2);
|
||||||
|
return state = State::PRESSED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
image.SetClipY(image.GetClipH());
|
||||||
|
return state = State::HOVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef BUTTON_HPP_
|
||||||
|
#define BUTTON_HPP_
|
||||||
|
|
||||||
|
#include "image.hpp"
|
||||||
|
#include "raster_font.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
//3-phases, no toggle, centred text
|
||||||
|
class Button {
|
||||||
|
public:
|
||||||
|
enum class State {
|
||||||
|
NORMAL, HOVER, PRESSED
|
||||||
|
};
|
||||||
|
|
||||||
|
Button();
|
||||||
|
Button(Sint16 x, Sint16 y, SDL_Surface* imageSurface, SDL_Surface* fontSurface, std::string text = "");
|
||||||
|
|
||||||
|
//return the current state
|
||||||
|
State MouseMotion(SDL_MouseMotionEvent&);
|
||||||
|
State MouseButtonDown(SDL_MouseButtonEvent&);
|
||||||
|
State MouseButtonUp(SDL_MouseButtonEvent&);
|
||||||
|
State GetState() const {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
//yet another draw function
|
||||||
|
void DrawTo(SDL_Surface* const);
|
||||||
|
|
||||||
|
//simple accessors and mutators
|
||||||
|
Sint16 SetX(Sint16 i) { return x = i; }
|
||||||
|
Sint16 SetY(Sint16 i) { return y = i; }
|
||||||
|
Sint16 GetX() const { return x; }
|
||||||
|
Sint16 GetY() const { return y; }
|
||||||
|
|
||||||
|
std::string SetText(std::string s);
|
||||||
|
std::string GetText() const { return text; }
|
||||||
|
|
||||||
|
//raw access, be careful
|
||||||
|
Image* GetImage() { return ℑ }
|
||||||
|
RasterFont* GetFont() { return &font; }
|
||||||
|
|
||||||
|
//debug
|
||||||
|
Sint16 GetTextX() const { return textX; }
|
||||||
|
Sint16 GetTextY() const { return textY; }
|
||||||
|
private:
|
||||||
|
State CalcState(Sint16 x, Sint16 y, bool leftPressed);
|
||||||
|
|
||||||
|
Sint16 x, y;
|
||||||
|
Sint16 textX, textY; //prevent recalc every loop
|
||||||
|
Image image;
|
||||||
|
RasterFont font;
|
||||||
|
State state;
|
||||||
|
std::string text;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -21,6 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "image.hpp"
|
#include "image.hpp"
|
||||||
|
|
||||||
|
Image::Image() {
|
||||||
|
SetSurface(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
Image::Image(SDL_Surface* p) {
|
Image::Image(SDL_Surface* p) {
|
||||||
SetSurface(p);
|
SetSurface(p);
|
||||||
}
|
}
|
||||||
@@ -31,7 +35,12 @@ Image::Image(SDL_Surface* p, SDL_Rect r) {
|
|||||||
|
|
||||||
SDL_Surface* Image::SetSurface(SDL_Surface* p) {
|
SDL_Surface* Image::SetSurface(SDL_Surface* p) {
|
||||||
surface = p;
|
surface = p;
|
||||||
|
if (!surface) {
|
||||||
|
clip = {0, 0, 0, 0};
|
||||||
|
}
|
||||||
|
else {
|
||||||
clip = {0, 0, (Uint16)surface->w, (Uint16)surface->h};
|
clip = {0, 0, (Uint16)surface->w, (Uint16)surface->h};
|
||||||
|
}
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +55,9 @@ SDL_Surface* Image::GetSurface() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Image::DrawTo(SDL_Surface* dest, Sint16 x, Sint16 y) {
|
void Image::DrawTo(SDL_Surface* dest, Sint16 x, Sint16 y) {
|
||||||
|
if (!surface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
SDL_Rect sclip = clip, dclip = {x,y};
|
SDL_Rect sclip = clip, dclip = {x,y};
|
||||||
|
|
||||||
SDL_BlitSurface(surface, &sclip, dest, &dclip);
|
SDL_BlitSurface(surface, &sclip, dest, &dclip);
|
||||||
|
|||||||
+16
-15
@@ -26,30 +26,31 @@
|
|||||||
|
|
||||||
class Image {
|
class Image {
|
||||||
public:
|
public:
|
||||||
|
Image();
|
||||||
Image(SDL_Surface*);
|
Image(SDL_Surface*);
|
||||||
Image(SDL_Surface*, SDL_Rect);
|
Image(SDL_Surface*, SDL_Rect);
|
||||||
virtual ~Image() {}
|
virtual ~Image() {}
|
||||||
|
|
||||||
SDL_Surface* SetSurface(SDL_Surface*);
|
virtual SDL_Surface* SetSurface(SDL_Surface*);
|
||||||
SDL_Surface* SetSurface(SDL_Surface*, SDL_Rect);
|
virtual SDL_Surface* SetSurface(SDL_Surface*, SDL_Rect);
|
||||||
SDL_Surface* GetSurface() const;
|
virtual SDL_Surface* GetSurface() const;
|
||||||
|
|
||||||
void DrawTo(SDL_Surface* const, Sint16 x, Sint16 y);
|
virtual void DrawTo(SDL_Surface* const, Sint16 x, Sint16 y);
|
||||||
|
|
||||||
//Clip handlers
|
//Clip handlers
|
||||||
SDL_Rect SetClip(SDL_Rect r) { return clip = r; }
|
virtual SDL_Rect SetClip(SDL_Rect r) { return clip = r; }
|
||||||
SDL_Rect GetClip() const { return clip; }
|
virtual SDL_Rect GetClip() const { return clip; }
|
||||||
|
|
||||||
Sint16 SetClipX(Sint16 x) { return clip.x = x; }
|
virtual Sint16 SetClipX(Sint16 x) { return clip.x = x; }
|
||||||
Sint16 SetClipY(Sint16 y) { return clip.y = y; }
|
virtual Sint16 SetClipY(Sint16 y) { return clip.y = y; }
|
||||||
Uint16 SetClipW(Uint16 w) { return clip.w = w; }
|
virtual Uint16 SetClipW(Uint16 w) { return clip.w = w; }
|
||||||
Uint16 SetClipH(Uint16 h) { return clip.h = h; }
|
virtual Uint16 SetClipH(Uint16 h) { return clip.h = h; }
|
||||||
|
|
||||||
Sint16 GetClipX() const { return clip.x; }
|
virtual Sint16 GetClipX() const { return clip.x; }
|
||||||
Sint16 GetClipY() const { return clip.y; }
|
virtual Sint16 GetClipY() const { return clip.y; }
|
||||||
Uint16 GetClipW() const { return clip.w; }
|
virtual Uint16 GetClipW() const { return clip.w; }
|
||||||
Uint16 GetClipH() const { return clip.h; }
|
virtual Uint16 GetClipH() const { return clip.h; }
|
||||||
private:
|
protected:
|
||||||
SDL_Surface* surface;
|
SDL_Surface* surface;
|
||||||
SDL_Rect clip;
|
SDL_Rect clip;
|
||||||
};
|
};
|
||||||
|
|||||||
+22
-1
@@ -1,3 +1,24 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
#include "scene_manager.hpp"
|
#include "scene_manager.hpp"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -9,8 +30,8 @@ int main(int, char**) {
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
cout << "Beginning program" << endl;
|
cout << "Beginning program" << endl;
|
||||||
#endif
|
#endif
|
||||||
SceneManager app;
|
|
||||||
try {
|
try {
|
||||||
|
SceneManager app;
|
||||||
app.Init();
|
app.Init();
|
||||||
app.Proc();
|
app.Proc();
|
||||||
app.Quit();
|
app.Quit();
|
||||||
|
|||||||
+3
-19
@@ -3,23 +3,7 @@ CXXFLAGS+=-std=c++11 -DDEBUG
|
|||||||
LIB=-lmingw32 -lSDLmain -lSDL -lwsock32 -lWS2_32
|
LIB=-lmingw32 -lSDLmain -lSDL -lwsock32 -lWS2_32
|
||||||
|
|
||||||
#source
|
#source
|
||||||
SRC=base_scene.cpp \
|
SRC=$(filter-out unit.cpp, $(wildcard *.cpp))
|
||||||
scene_manager.cpp \
|
|
||||||
test_systems.cpp \
|
|
||||||
splash.cpp \
|
|
||||||
main_menu.cpp \
|
|
||||||
in_game.cpp \
|
|
||||||
lobby.cpp \
|
|
||||||
combat.cpp \
|
|
||||||
surface_manager.cpp \
|
|
||||||
image.cpp \
|
|
||||||
sprite_sheet.cpp \
|
|
||||||
player.cpp \
|
|
||||||
player_manager.cpp \
|
|
||||||
config_utility.cpp \
|
|
||||||
network.cpp \
|
|
||||||
network_tcp.cpp \
|
|
||||||
main.cpp
|
|
||||||
|
|
||||||
#objects
|
#objects
|
||||||
OBJDIR=obj
|
OBJDIR=obj
|
||||||
@@ -27,7 +11,7 @@ OBJ=$(addprefix $(OBJDIR)/,$(SRC:.cpp=.o))
|
|||||||
|
|
||||||
#output
|
#output
|
||||||
OUTDIR=out
|
OUTDIR=out
|
||||||
OUT=$(addprefix $(OUTDIR)/,a)
|
OUT=$(addprefix $(OUTDIR)/,client)
|
||||||
|
|
||||||
#targets
|
#targets
|
||||||
all: $(OBJ) $(OUT)
|
all: $(OBJ) $(OUT)
|
||||||
@@ -44,7 +28,7 @@ $(OUTDIR):
|
|||||||
mkdir $(OUTDIR)
|
mkdir $(OUTDIR)
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $(@) $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) *.o *.a *.exe
|
$(RM) *.o *.a *.exe
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "network.hpp"
|
||||||
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "raster_font.hpp"
|
||||||
|
|
||||||
|
void RasterFont::DrawStringTo(std::string s, SDL_Surface* const dest, Sint16 x, Sint16 y) {
|
||||||
|
if (!surface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//character size won't change here
|
||||||
|
const Sint16 w = surface->w/16;
|
||||||
|
const Sint16 h = surface->h/16;
|
||||||
|
SDL_Rect sclip, dclip = {x,y,0,0};
|
||||||
|
for (auto c : s) {
|
||||||
|
//TODO: inefficient
|
||||||
|
sclip = {Sint16(c%w*w), Sint16(c/h*h), clip.w, clip.h};
|
||||||
|
// sclip.x = c % w;
|
||||||
|
// sclip.h = c / h;
|
||||||
|
// sclip.w = clip.w;
|
||||||
|
// sclip.h = clip.h;
|
||||||
|
SDL_BlitSurface(surface, &sclip, dest, &dclip);
|
||||||
|
dclip.x += w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Surface* RasterFont::SetSurface(SDL_Surface* p) {
|
||||||
|
surface = p;
|
||||||
|
if (!surface) {
|
||||||
|
clip = {0, 0, 0, 0};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clip = {0, 0, Uint16(surface->w/16), Uint16(surface->h/16)};
|
||||||
|
}
|
||||||
|
return surface;
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef RASTERFONT_HPP_
|
||||||
|
#define RASTERFONT_HPP_
|
||||||
|
|
||||||
|
#include "image.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class RasterFont : protected Image {
|
||||||
|
public:
|
||||||
|
RasterFont() {}
|
||||||
|
RasterFont(SDL_Surface* p) {SetSurface(p);}
|
||||||
|
virtual ~RasterFont() {}
|
||||||
|
virtual void DrawStringTo(std::string, SDL_Surface* const, Sint16 x, Sint16 y);
|
||||||
|
virtual SDL_Surface* SetSurface(SDL_Surface*) override;
|
||||||
|
|
||||||
|
using Image::GetSurface;
|
||||||
|
using Image::GetClip;
|
||||||
|
using Image::GetClipW;
|
||||||
|
using Image::GetClipH;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -39,7 +39,7 @@ void SceneManager::Init() {
|
|||||||
if (SDL_Init(SDL_INIT_VIDEO))
|
if (SDL_Init(SDL_INIT_VIDEO))
|
||||||
throw(std::runtime_error("Failed to initialize SDL"));
|
throw(std::runtime_error("Failed to initialize SDL"));
|
||||||
|
|
||||||
GetSingletonPtr<ConfigUtility>()->Load("rsc\\config.cfg");
|
GetSingletonPtr<ConfigUtility>()->Load("rsc/config.cfg");
|
||||||
|
|
||||||
//set the screen from the config file
|
//set the screen from the config file
|
||||||
int flags = SDL_HWSURFACE|SDL_DOUBLEBUF;
|
int flags = SDL_HWSURFACE|SDL_DOUBLEBUF;
|
||||||
|
|||||||
+4
-4
@@ -6,10 +6,10 @@ screen.h = 600
|
|||||||
screen.f = false
|
screen.f = false
|
||||||
|
|
||||||
#directories
|
#directories
|
||||||
fonts = rsc\graphics\fonts
|
fonts = rsc/graphics/fonts
|
||||||
logos = rsc\graphics\logos
|
logos = rsc/graphics/logos
|
||||||
sprites = rsc\graphics\sprites
|
sprites = rsc/graphics/sprites
|
||||||
tilesets = rsc\graphics\tilesets
|
tilesets = rsc/graphics/tilesets
|
||||||
|
|
||||||
#debugging
|
#debugging
|
||||||
debug = true
|
debug = true
|
||||||
|
|||||||
+8
-9
@@ -2,20 +2,19 @@
|
|||||||
CXXFLAGS+=-std=c++11 -DDEBUG
|
CXXFLAGS+=-std=c++11 -DDEBUG
|
||||||
LIB=-lwsock32 -lWS2_32
|
LIB=-lwsock32 -lWS2_32
|
||||||
|
|
||||||
|
#source
|
||||||
|
SRC=$(filter-out unit.cpp main.cpp, $(wildcard *.cpp))
|
||||||
|
|
||||||
#objects
|
#objects
|
||||||
OBJDIR=obj
|
OBJDIR=obj
|
||||||
OBJ=$(addprefix $(OBJDIR)/,config_utility.o network.o network_tcp.o)
|
OBJ=$(addprefix $(OBJDIR)/,$(SRC:.cpp=.o))
|
||||||
|
|
||||||
#output
|
#output
|
||||||
OUTDIR=out
|
OUTDIR=out
|
||||||
OUT=$(addprefix $(OUTDIR)/,server)
|
|
||||||
|
|
||||||
#source
|
|
||||||
SRC=server.cpp main.cpp
|
|
||||||
|
|
||||||
#targets
|
#targets
|
||||||
all: $(OBJ) $(OUT)
|
all: $(OBJ) $(OUT)
|
||||||
$(CXX) $(CXXFLAGS) -o $(OUT) $(SRC) $(OBJ) $(LIB)
|
$(CXX) $(CXXFLAGS) -o $(OUTDIR)/server main.cpp $(OBJ) $(LIB)
|
||||||
|
|
||||||
$(OBJ): | $(OBJDIR)
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|
||||||
@@ -28,12 +27,12 @@ $(OUTDIR):
|
|||||||
mkdir $(OUTDIR)
|
mkdir $(OUTDIR)
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $(@) $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) *.o *.a *.exe
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
rebuild: clean all
|
rebuild: clean all unit
|
||||||
|
|
||||||
unit:
|
unit: $(OBJ) $(OUT)
|
||||||
$(CXX) $(CXXFLAGS) -o $(OUTDIR)\unit unit.cpp $(OBJ) $(LIB)
|
$(CXX) $(CXXFLAGS) -o $(OUTDIR)\unit unit.cpp $(OBJ) $(LIB)
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "network.hpp"
|
||||||
|
|
||||||
Reference in New Issue
Block a user