Jump to content

  • Log In with Google      Sign In   
  • Create Account


levijgraham

Member Since 10 Jan 2011
Offline Last Active Dec 16 2011 05:14 PM
-----

Topics I've Started

Saving File Help

16 December 2011 - 04:24 AM

Hello im trying to save the chuncks of my map in in the folder called level each chunk is supposed to be represented by a diffrent file but i cant seem to figure out how to get what number my loop is on to save in with my file name so i end up getting files called all sorts of names that i dont want.

void Map::Save()
{
	for(int loop = 0; loop < Map::AmountOfChuncks;loop++)
	{
		for(int loop2 = 0; loop2 < Map::AmountOfChuncks;loop2++)
		{
			ofstream file( "Level/Chunck"+loop+"_"+loop2".Data" );
			Map::GenerateChunck();
			for(int loop3 = 0; loop3 < Map::AmountOfChuncks;loop3++)
			{
				for(int loop4 = 0; loop4 < Map::AmountOfChuncks;loop4++)
				{
					file << Map::Data[loop3][loop4];
				}
			}
			file.close();
		}
	}}

Project Dark Ages

08 October 2011 - 03:55 PM

Project Dark Ages is a medieval sim game
In Development

My link

i really need some help

09 August 2011 - 02:23 AM

i have attached a picture of the error i get it when i send my map between the server and the client.
theres my main
#include <iostream>
#include <string>
#include "GameState.h"
#include "Socket.h"
#include "Level.h"

using namespace std;

GameState CurrentGameState;
const int STRLEN = 256;
const int MAPLENGTH = 250;
Level CurrentLevel;

int main()
{
	CurrentLevel.init();
	int port = 666;
	char *ipAddress = "127.0.0.1";
	char recMessage[STRLEN];
	char sendMessage[STRLEN];
	bool run = true;
	while (true)
	{
		int a = CurrentGameState.run();
		if(a == 1)
		{
			bool run2 = true;
			ServerSocket sockServer;
			cout << "HOSTING..."<<endl;
			sockServer.StartHosting(port);
			sockServer.Listen();
			while (run2)
			{
				char sendMap[MAPLENGTH];
				CurrentLevel.draw();
				CurrentLevel.Edit(true);
				int id = 0;
				for(int y = 0;y < 10;y++)
				{
					for(int x = 0;x < 25;x++)
					{
						sendMap[id] = CurrentLevel.map[x][y];
						id++;
					}
				}
				sockServer.SendData( sendMap );

				sockServer.ReceiveData(sendMap,MAPLENGTH);
				id = 0;
				for(int y = 0;y < 10;y++)
				{
					for(int x = 0;x < 25;x++)
					{
						CurrentLevel.map[x][y] = sendMap[id];
						id++;
					}
				}

				if (strcmp(recMessage,"end") == 0 || strcmp(sendMessage,"end") == 0)
				{
					run2 = false;
				}
			}
		}
		else if(a == 2)
		{
			ClientSocket sockClient;
			cout << "ATTEMPTING TO CONNECT" << endl;
			sockClient.ConnectToServer(ipAddress,port);
			bool run2 = true;
			while (run2)
			{
				char sendMap[MAPLENGTH];
				CurrentLevel.draw();
				sockClient.ReceiveData(sendMap,MAPLENGTH);
				int id = 0;
				for(int y = 0;y < 10;y++)
				{
					for(int x = 0;x < 25;x++)
					{
						CurrentLevel.map[x][y] = sendMap[id];
						id++;
					}
				}
				CurrentLevel.Edit(false);
				
				id = 0;
				for(int y = 0;y < 10;y++)
				{
					for(int x = 0;x < 25;x++)
					{
						sendMap[id] = CurrentLevel.map[x][y];
						id++;
					}
				}
				sockClient.SendData( sendMap );

				if (strcmp(recMessage,"end") == 0 || strcmp(sendMessage,"end") == 0)
				{
					run2 = false;
				}
			}
		sockClient.CloseConnection();
		}
		else if(a == 3)
		{
			exit(0);
		}
	}
	return 0;}

trying to use winsock2

08 August 2011 - 06:46 PM

Hey i am trying to run a simple chat program in c++ and a keep getting this error. Can anyone tell me how to fix it?


1>------ Build started: Project: RTS, Configuration: Debug Win32 ------
1>Build started 8/8/2011 5:43:59 PM.
1>InitializeBuildStatus:
1> Touching "Debug\RTS.unsuccessfulbuild".
1>ClCompile:
1> main.cpp
1> Socket.cpp
1>c:\users\levi\desktop\game\testfolder\rts\socket.cpp(19): warning C4551: function call missing argument list
1> Generating Code...
1>Socket.obj : error LNK2019: unresolved external symbol __imp__socket@12 referenced in function "public: __thiscall Socket::Socket(void)" (??0Socket@@QAE@XZ)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function "public: __thiscall Socket::Socket(void)" (??0Socket@@QAE@XZ)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function "public: __thiscall Socket::Socket(void)" (??0Socket@@QAE@XZ)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__send@16 referenced in function "public: bool __thiscall Socket::SendData(char *)" (?SendData@Socket@@QAE_NPAD@Z)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__recv@16 referenced in function "public: bool __thiscall Socket::ReceiveData(char *,int)" (?ReceiveData@Socket@@QAE_NPADH@Z)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function "public: void __thiscall Socket::CloseConnection(void)" (?CloseConnection@Socket@@QAEXXZ)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__accept@12 referenced in function "public: void __thiscall ServerSocket::Listen(void)" (?Listen@ServerSocket@@QAEXXZ)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__listen@8 referenced in function "public: void __thiscall ServerSocket::StartHosting(int)" (?StartHosting@ServerSocket@@QAEXH@Z)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__connect@12 referenced in function "public: void __thiscall ServerSocket::StartHosting(int)" (?StartHosting@ServerSocket@@QAEXH@Z)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__htons@4 referenced in function "public: void __thiscall ServerSocket::StartHosting(int)" (?StartHosting@ServerSocket@@QAEXH@Z)
1>Socket.obj : error LNK2019: unresolved external symbol __imp__inet_addr@4 referenced in function "public: void __thiscall ServerSocket::StartHosting(int)" (?StartHosting@ServerSocket@@QAEXH@Z)
1>C:\Users\levi\Desktop\Game\TestFolder\RTS\Debug\RTS.exe : fatal error LNK1120: 11 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:03.97
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

fstream loading text file into char array

02 April 2011 - 01:30 PM

Hello I am trying to get a text file to load up through this bit of code here and get put into a char array but it wont let me, It says my array is corrupt ... any ideas?

int MenuRead(string SaveFileNameInfo)
{
	char FILE[255];
	char acTemp;
	ifstream in(SaveFileNameInfo, ios::in | ios::binary);
	if(!in)
	{
		cout << "can't open file! " << SaveFileNameInfo << endl;
		return 1;
	}

	while(in)
	{
		in.get(acTemp);
		if(in) cout << acTemp;
		FILE[255] = acTemp;
	}
	in.close();
	cout << FILE;
	return 0;}

PARTNERS