Hi.
I'm at the stage where I now need to send the games map file's to clients that dont have
correct map version or no map at all.
This all get send on top of a boost::asio rapper I created. the max packet size will be 1200 bytes and the send and recive lockfree queue size is packet * 128(not sure how big to make this) any thing over that amount of messages will be lost.
Map's consist of 8 files.
1.BlendMap .dds or .jpg
2.CostMap, holds cell info for terrain A* path finding
3.HeightMap
4.Map Defined Menus, Menu's for selected objects and that get defined in mapedd
5.Map Defined Objects. Objects also get defined for each map
6.Map.map, defined map data like trees and triggers
7.Object Defined Upgrades, upgrades defined when creating the map
8.Mini Map, .dds
all the data files are stored as google protocol buffers that can be serialized to a string
or stream.
But the image files the .dds and .jpg. What do I do when one is created on win 32 and sent to a win 64 bit system and visa versa.
I can have a google protocol buffer with a byte array(this is infact a string anyway).
Q1.Do I only copy the image data and then create the resource on the other side.
Q2.Or do I memcopy the whole file to the byte buffer.
Second Point.
I think I may need a whole system for file sending and file recieving.
because the files will need to be sent one at a time and also split up to fit into a packet and reassembled at the other end before writting it back to file.
A file will be split into filepackets
.
class filepacket
{
in32_t fileID;//need to be able to send multiple files at same time
int32_t chunkID;//0 for first file chunk
in32_t Totalfilesize;//valid file size for chankID = 0 only the first file packet
bool End;//last file packet = true
bytes data;//all the bits
};
.
Now a class to hold all the file packets for a file.
.
class FileStream
{
std::map<chunkID,filepacket> FileStream;
};
.
Then the big Dirty Manager class
.
class FileDownLoadManager
{
std::map<fileID, FileStream> SendFiles;
std::map<fileID, FileStream> RecievedFiles;
//this class could blow out in code size
void threadProcessSendFiles(void)
{
if(SendFiles.WholeFileReady_And_Not_AllreadySending)
Startfilesend();
//do othere stuff like build the send file stream from file ready for sending
}
void threadProcessRecieveFiles()
{
if(networkpacket_ISFILE)
{
AddRecievedFile(packet);
}
//when a recieved file is completed it saves to file and removes itself
RecievedFile_WriteToFileIfReady();
};
.
Q3.Should it be one class does send and recieve. Only of file chunks
Q4.Or one class to manage sending files, And one for recieving files only.