mirror of
https://github.com/glest/glest-source.git
synced 2025-08-11 19:04:00 +02:00
8 players
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -30,7 +30,7 @@ enum ControlType{
|
|||||||
|
|
||||||
class GameConstants{
|
class GameConstants{
|
||||||
public:
|
public:
|
||||||
static const int maxPlayers= 4;
|
static const int maxPlayers= 8;
|
||||||
static const int serverPort= 61357;
|
static const int serverPort= 61357;
|
||||||
static const int updateFps= 40;
|
static const int updateFps= 40;
|
||||||
static const int cameraFps= 100;
|
static const int cameraFps= 100;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -60,12 +60,12 @@ void BattleEnd::render(){
|
|||||||
|
|
||||||
textRenderer->begin(CoreData::getInstance().getMenuFontBig());
|
textRenderer->begin(CoreData::getInstance().getMenuFontBig());
|
||||||
|
|
||||||
int lm= 80;
|
int lm= 20;
|
||||||
int bm= 100;
|
int bm= 100;
|
||||||
|
|
||||||
for(int i=0; i<stats.getFactionCount(); ++i){
|
for(int i=0; i<stats.getFactionCount(); ++i){
|
||||||
|
|
||||||
int textX= lm+300+i*120;
|
int textX= lm+120+i*110;
|
||||||
int team= stats.getTeam(i) + 1;
|
int team= stats.getTeam(i) + 1;
|
||||||
int kills= stats.getKills(i);
|
int kills= stats.getKills(i);
|
||||||
int deaths= stats.getDeaths(i);
|
int deaths= stats.getDeaths(i);
|
||||||
@@ -110,15 +110,15 @@ void BattleEnd::render(){
|
|||||||
textRenderer->render(intToStr(score).c_str(), textX, bm+20);
|
textRenderer->render(intToStr(score).c_str(), textX, bm+20);
|
||||||
}
|
}
|
||||||
|
|
||||||
textRenderer->render(lang.get("Result"), lm+50, bm+360);
|
textRenderer->render(lang.get("Result"), lm, bm+360);
|
||||||
textRenderer->render(lang.get("Control"), lm+50, bm+320);
|
textRenderer->render(lang.get("Control"), lm, bm+320);
|
||||||
textRenderer->render(lang.get("Faction"), lm+50, bm+280);
|
textRenderer->render(lang.get("Faction"), lm, bm+280);
|
||||||
textRenderer->render(lang.get("Team"), lm+50, bm+240);
|
textRenderer->render(lang.get("Team"), lm, bm+240);
|
||||||
textRenderer->render(lang.get("Kills"), lm+50, bm+200);
|
textRenderer->render(lang.get("Kills"), lm, bm+200);
|
||||||
textRenderer->render(lang.get("Deaths"), lm+50, bm+160);
|
textRenderer->render(lang.get("Deaths"), lm, bm+160);
|
||||||
textRenderer->render(lang.get("UnitsProduced"), lm+50, bm+120);
|
textRenderer->render(lang.get("UnitsProduced"), lm, bm+120);
|
||||||
textRenderer->render(lang.get("ResourcesHarvested"), lm+50, bm+80);
|
textRenderer->render(lang.get("ResourcesHarvested"), lm, bm+80);
|
||||||
textRenderer->render(lang.get("Score"), lm+50, bm+20);
|
textRenderer->render(lang.get("Score"), lm, bm+20);
|
||||||
|
|
||||||
textRenderer->end();
|
textRenderer->end();
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -47,8 +47,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
vector<string> results, teamItems, controlItems;
|
vector<string> results, teamItems, controlItems;
|
||||||
|
|
||||||
//create
|
//create
|
||||||
buttonReturn.init(350, 200, 125);
|
buttonReturn.init(350, 140, 125);
|
||||||
buttonPlayNow.init(525, 200, 125);
|
buttonPlayNow.init(525, 140, 125);
|
||||||
|
|
||||||
//map listBox
|
//map listBox
|
||||||
findAll("maps/*.gbm", results, true);
|
findAll("maps/*.gbm", results, true);
|
||||||
@@ -59,10 +59,10 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
for(int i= 0; i<results.size(); ++i){
|
for(int i= 0; i<results.size(); ++i){
|
||||||
results[i]= formatString(results[i]);
|
results[i]= formatString(results[i]);
|
||||||
}
|
}
|
||||||
listBoxMap.init(200, 320, 150);
|
listBoxMap.init(200, 260, 150);
|
||||||
listBoxMap.setItems(results);
|
listBoxMap.setItems(results);
|
||||||
labelMap.init(200, 350);
|
labelMap.init(200, 290);
|
||||||
labelMapInfo.init(200, 290, 200, 40);
|
labelMapInfo.init(200, 230, 200, 40);
|
||||||
|
|
||||||
//tileset listBox
|
//tileset listBox
|
||||||
findAll("tilesets/*.", results);
|
findAll("tilesets/*.", results);
|
||||||
@@ -73,9 +73,9 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
for(int i= 0; i<results.size(); ++i){
|
for(int i= 0; i<results.size(); ++i){
|
||||||
results[i]= formatString(results[i]);
|
results[i]= formatString(results[i]);
|
||||||
}
|
}
|
||||||
listBoxTileset.init(400, 320, 150);
|
listBoxTileset.init(400, 260, 150);
|
||||||
listBoxTileset.setItems(results);
|
listBoxTileset.setItems(results);
|
||||||
labelTileset.init(400, 350);
|
labelTileset.init(400, 290);
|
||||||
|
|
||||||
//tech Tree listBox
|
//tech Tree listBox
|
||||||
findAll("techs/*.", results);
|
findAll("techs/*.", results);
|
||||||
@@ -86,22 +86,22 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
for(int i= 0; i<results.size(); ++i){
|
for(int i= 0; i<results.size(); ++i){
|
||||||
results[i]= formatString(results[i]);
|
results[i]= formatString(results[i]);
|
||||||
}
|
}
|
||||||
listBoxTechTree.init(600, 320, 150);
|
listBoxTechTree.init(600, 260, 150);
|
||||||
listBoxTechTree.setItems(results);
|
listBoxTechTree.setItems(results);
|
||||||
labelTechTree.init(600, 350);
|
labelTechTree.init(600, 290);
|
||||||
|
|
||||||
//list boxes
|
//list boxes
|
||||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||||
labelPlayers[i].init(200, 500-i*30);
|
labelPlayers[i].init(200, 550-i*30);
|
||||||
listBoxControls[i].init(300, 500-i*30);
|
listBoxControls[i].init(300, 550-i*30);
|
||||||
listBoxFactions[i].init(500, 500-i*30);
|
listBoxFactions[i].init(500, 550-i*30);
|
||||||
listBoxTeams[i].init(700, 500-i*30, 60);
|
listBoxTeams[i].init(700, 550-i*30, 60);
|
||||||
labelNetStatus[i].init(800, 500-i*30, 60);
|
labelNetStatus[i].init(800, 550-i*30, 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
labelControl.init(300, 550, GraphicListBox::defW, GraphicListBox::defH, true);
|
labelControl.init(300, 600, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||||
labelFaction.init(500, 550, GraphicListBox::defW, GraphicListBox::defH, true);
|
labelFaction.init(500, 600, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||||
labelTeam.init(700, 550, 60, GraphicListBox::defH, true);
|
labelTeam.init(700, 600, 60, GraphicListBox::defH, true);
|
||||||
|
|
||||||
//texts
|
//texts
|
||||||
buttonReturn.setText(lang.get("Return"));
|
buttonReturn.setText(lang.get("Return"));
|
||||||
@@ -118,6 +118,10 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
teamItems.push_back("2");
|
teamItems.push_back("2");
|
||||||
teamItems.push_back("3");
|
teamItems.push_back("3");
|
||||||
teamItems.push_back("4");
|
teamItems.push_back("4");
|
||||||
|
teamItems.push_back("5");
|
||||||
|
teamItems.push_back("6");
|
||||||
|
teamItems.push_back("7");
|
||||||
|
teamItems.push_back("8");
|
||||||
|
|
||||||
reloadFactions();
|
reloadFactions();
|
||||||
|
|
||||||
|
@@ -132,6 +132,10 @@ MainWindow::MainWindow():
|
|||||||
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+2, wxT("2 - Player 2 "));
|
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+2, wxT("2 - Player 2 "));
|
||||||
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+3, wxT("3 - Player 3 "));
|
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+3, wxT("3 - Player 3 "));
|
||||||
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+4, wxT("4 - Player 4 "));
|
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+4, wxT("4 - Player 4 "));
|
||||||
|
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+5, wxT("5 - Player 5 "));
|
||||||
|
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+6, wxT("6 - Player 6 "));
|
||||||
|
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+7, wxT("7 - Player 7 "));
|
||||||
|
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+8, wxT("8 - Player 8 "));
|
||||||
menuBrush->Append(miBrushStartLocation, wxT("Player"), menuBrushStartLocation);
|
menuBrush->Append(miBrushStartLocation, wxT("Player"), menuBrushStartLocation);
|
||||||
|
|
||||||
menuBar->Append(menuBrush, wxT("Brush"));
|
menuBar->Append(menuBrush, wxT("Brush"));
|
||||||
@@ -145,6 +149,9 @@ MainWindow::MainWindow():
|
|||||||
menuBar->Append(menuRadius, wxT("Radius"));
|
menuBar->Append(menuRadius, wxT("Radius"));
|
||||||
|
|
||||||
SetMenuBar(menuBar);
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
|
timer = new wxTimer(this);
|
||||||
|
timer->Start(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::init(){
|
void MainWindow::init(){
|
||||||
@@ -414,6 +421,11 @@ void MainWindow::onMenuRadius(wxCommandEvent &event){
|
|||||||
radius= event.GetId() - miRadius + 1;
|
radius= event.GetId() - miRadius + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onTimer(wxTimerEvent &event) {
|
||||||
|
wxPaintEvent paintEvent;
|
||||||
|
onPaint(paintEvent);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::change(int x, int y){
|
void MainWindow::change(int x, int y){
|
||||||
switch(enabledGroup){
|
switch(enabledGroup){
|
||||||
case 0:
|
case 0:
|
||||||
@@ -459,6 +471,7 @@ void MainWindow::uncheckRadius(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
BEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
||||||
|
EVT_TIMER(-1, MainWindow::onTimer)
|
||||||
EVT_CLOSE(MainWindow::onClose)
|
EVT_CLOSE(MainWindow::onClose)
|
||||||
EVT_LEFT_DOWN(MainWindow::onMouseDown)
|
EVT_LEFT_DOWN(MainWindow::onMouseDown)
|
||||||
EVT_MOTION(MainWindow::onMouseMove)
|
EVT_MOTION(MainWindow::onMouseMove)
|
||||||
|
@@ -32,7 +32,7 @@ private:
|
|||||||
static const int surfaceCount= 5;
|
static const int surfaceCount= 5;
|
||||||
static const int objectCount= 11;
|
static const int objectCount= 11;
|
||||||
static const int resourceCount= 6;
|
static const int resourceCount= 6;
|
||||||
static const int startLocationCount= 4;
|
static const int startLocationCount= 8;
|
||||||
static const int radiusCount= 9;
|
static const int radiusCount= 9;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -71,6 +71,8 @@ private:
|
|||||||
Program *program;
|
Program *program;
|
||||||
int lastX, lastY;
|
int lastX, lastY;
|
||||||
|
|
||||||
|
wxTimer *timer;
|
||||||
|
|
||||||
wxMenuBar *menuBar;
|
wxMenuBar *menuBar;
|
||||||
wxMenu *menuFile;
|
wxMenu *menuFile;
|
||||||
wxMenu *menuEdit;
|
wxMenu *menuEdit;
|
||||||
@@ -131,6 +133,8 @@ public:
|
|||||||
void onMenuBrushStartLocation(wxCommandEvent &event);
|
void onMenuBrushStartLocation(wxCommandEvent &event);
|
||||||
void onMenuRadius(wxCommandEvent &event);
|
void onMenuRadius(wxCommandEvent &event);
|
||||||
|
|
||||||
|
void onTimer(wxTimerEvent &event);
|
||||||
|
|
||||||
void change(int x, int y);
|
void change(int x, int y);
|
||||||
|
|
||||||
void uncheckBrush();
|
void uncheckBrush();
|
||||||
|
@@ -320,8 +320,8 @@ void Map::resize(int w, int h, float alt, int surf){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Map::resetPlayers(int maxPlayers){
|
void Map::resetPlayers(int maxPlayers){
|
||||||
if (maxPlayers<1 || maxPlayers>4){
|
if (maxPlayers<1 || maxPlayers>8){
|
||||||
throw runtime_error("Max Players must be in the range 1-4");
|
throw runtime_error("Max Players must be in the range 1-8");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -155,6 +155,10 @@ void Renderer::renderMap(Map *map, int x, int y, int clientW, int clientH, int c
|
|||||||
case 1: glColor3f(0.f, 0.f, 1.f); break;
|
case 1: glColor3f(0.f, 0.f, 1.f); break;
|
||||||
case 2: glColor3f(0.f, 1.f, 0.f); break;
|
case 2: glColor3f(0.f, 1.f, 0.f); break;
|
||||||
case 3: glColor3f(1.f, 1.f, 0.f); break;
|
case 3: glColor3f(1.f, 1.f, 0.f); break;
|
||||||
|
case 4: glColor3f(1.f, 1.f, 1.f); break;
|
||||||
|
case 5: glColor3f(0.f, 1.f, 0.8f); break;
|
||||||
|
case 6: glColor3f(1.f, 0.8f, 0.f); break;
|
||||||
|
case 7: glColor3f(1.f, 0.8f, 1.f); break;
|
||||||
}
|
}
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glVertex2i((map->getStartLocationX(i)-1)*cellSize, clientH- (map->getStartLocationY(i)-1)*cellSize);
|
glVertex2i((map->getStartLocationX(i)-1)*cellSize, clientH- (map->getStartLocationY(i)-1)*cellSize);
|
||||||
|
@@ -38,7 +38,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Ip();
|
Ip();
|
||||||
Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3);
|
Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3,
|
||||||
|
unsigned char byte4, unsigned char byte5, unsigned char byte6, unsigned char byte7);
|
||||||
Ip(const string& ipString);
|
Ip(const string& ipString);
|
||||||
|
|
||||||
unsigned char getByte(int byteIndex) {return bytes[byteIndex];}
|
unsigned char getByte(int byteIndex) {return bytes[byteIndex];}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest Shared Library (www.glest.org)
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -32,7 +32,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Ip();
|
Ip();
|
||||||
Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3);
|
Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3,
|
||||||
|
unsigned char byte4, unsigned char byte5, unsigned char byte6, unsigned char byte7);
|
||||||
Ip(const string& ipString);
|
Ip(const string& ipString);
|
||||||
|
|
||||||
unsigned char getByte(int byteIndex) {return bytes[byteIndex];}
|
unsigned char getByte(int byteIndex) {return bytes[byteIndex];}
|
||||||
|
@@ -39,13 +39,22 @@ Ip::Ip(){
|
|||||||
bytes[1]= 0;
|
bytes[1]= 0;
|
||||||
bytes[2]= 0;
|
bytes[2]= 0;
|
||||||
bytes[3]= 0;
|
bytes[3]= 0;
|
||||||
|
bytes[4]= 0;
|
||||||
|
bytes[5]= 0;
|
||||||
|
bytes[6]= 0;
|
||||||
|
bytes[7]= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ip::Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3){
|
Ip::Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3,
|
||||||
|
unsigned char byte4, unsigned char byte5, unsigned char byte6, unsigned char byte7){
|
||||||
bytes[0]= byte0;
|
bytes[0]= byte0;
|
||||||
bytes[1]= byte1;
|
bytes[1]= byte1;
|
||||||
bytes[2]= byte2;
|
bytes[2]= byte2;
|
||||||
bytes[3]= byte3;
|
bytes[3]= byte3;
|
||||||
|
bytes[4]= byte4;
|
||||||
|
bytes[5]= byte5;
|
||||||
|
bytes[6]= byte6;
|
||||||
|
bytes[7]= byte7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -53,7 +62,7 @@ Ip::Ip(const string& ipString){
|
|||||||
int offset= 0;
|
int offset= 0;
|
||||||
int byteIndex= 0;
|
int byteIndex= 0;
|
||||||
|
|
||||||
for(byteIndex= 0; byteIndex<4; ++byteIndex){
|
for(byteIndex= 0; byteIndex<8; ++byteIndex){
|
||||||
int dotPos= ipString.find_first_of('.', offset);
|
int dotPos= ipString.find_first_of('.', offset);
|
||||||
|
|
||||||
bytes[byteIndex]= atoi(ipString.substr(offset, dotPos-offset).c_str());
|
bytes[byteIndex]= atoi(ipString.substr(offset, dotPos-offset).c_str());
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest Shared Library (www.glest.org)
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2007 Marti<74>o Figueroa
|
// Copyright (C) 2001-2007 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -165,21 +165,29 @@ Ip::Ip(){
|
|||||||
bytes[1]= 0;
|
bytes[1]= 0;
|
||||||
bytes[2]= 0;
|
bytes[2]= 0;
|
||||||
bytes[3]= 0;
|
bytes[3]= 0;
|
||||||
|
bytes[4]= 4;
|
||||||
|
bytes[5]= 5;
|
||||||
|
bytes[6]= 6;
|
||||||
|
bytes[7]= 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ip::Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3){
|
Ip::Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3,
|
||||||
|
unsigned char byte4, unsigned char byte5, unsigned char byte6, unsigned char byte7){
|
||||||
bytes[0]= byte0;
|
bytes[0]= byte0;
|
||||||
bytes[1]= byte1;
|
bytes[1]= byte1;
|
||||||
bytes[2]= byte2;
|
bytes[2]= byte2;
|
||||||
bytes[3]= byte3;
|
bytes[3]= byte3;
|
||||||
|
bytes[4]= byte4;
|
||||||
|
bytes[5]= byte5;
|
||||||
|
bytes[6]= byte6;
|
||||||
|
bytes[7]= byte7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Ip::Ip(const string& ipString){
|
Ip::Ip(const string& ipString){
|
||||||
int offset= 0;
|
int offset= 0;
|
||||||
int byteIndex= 0;
|
int byteIndex= 0;
|
||||||
|
|
||||||
for(byteIndex= 0; byteIndex<4; ++byteIndex){
|
for(byteIndex= 0; byteIndex<8; ++byteIndex){
|
||||||
int dotPos= ipString.find_first_of('.', offset);
|
int dotPos= ipString.find_first_of('.', offset);
|
||||||
|
|
||||||
bytes[byteIndex]= atoi(ipString.substr(offset, dotPos-offset).c_str());
|
bytes[byteIndex]= atoi(ipString.substr(offset, dotPos-offset).c_str());
|
||||||
@@ -188,7 +196,8 @@ Ip::Ip(const string& ipString){
|
|||||||
}
|
}
|
||||||
|
|
||||||
string Ip::getString() const{
|
string Ip::getString() const{
|
||||||
return intToStr(bytes[0]) + "." + intToStr(bytes[1]) + "." + intToStr(bytes[2]) + "." + intToStr(bytes[3]);
|
return intToStr(bytes[0]) + "." + intToStr(bytes[1]) + "." + intToStr(bytes[2]) + "." + intToStr(bytes[3])
|
||||||
|
+ "." +intToStr(bytes[4]) + "." + intToStr(bytes[5]) + "." + intToStr(bytes[6]) + "." + intToStr(bytes[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
Reference in New Issue
Block a user