Is there any good programmer who can provide me an example C++ code generating an empty and proper CS2D map?
Theory (click me) seems simple but I'm not good at C++ so I'm asking for the code.
Thanks in advance.
#include <iostream>		// all-in-one(std::string, stdio.h, stdlib.h,...) #include <fstream>		// complete file stream type #include <ctime>		// well, iostream does not include time.h typedef struct MapWriter_Info { 	bool scroll_Tiles; 	bool use_Modifier; 	int USGN_ID; 	std::string author_Name; 	int Map_XSize; 	int Map_YSize; 	// without path but with extension, "aztec.bmp" for example 	std::string tileset_Name; 	std::string background_Name; 	int scroll_X; 	int scroll_Y; 	char default_Frame; 	// [0]=R, [1]=G, [2]=B 	char background_RGB[3]; } *PointerMapWriter_Info; void generate_empty_map(std::string& filename,PointerMapWriter_Info mapinfo) { 	int temp_int; 	time_t temp_time_t; 	char temp_str[1024]; 	tm* temp_tm; 	std::fstream file(filename.c_str(),std::ios::out|std::ios::binary|std::ios::trunc);	// fopen(filename.c_str(),"wb"); << fopen equivalent 	// STRING header 	file << "Unreal Software's Counter-Strike 2D Map File (max)\r\n"; 	// BYTE scroll map like tiles? (0 no / 1 yes) 	file.write((const char*)&mapinfo->scroll_Tiles,1); 	// BYTE use modifiers in this map (blending, tile rotation, tile brightness) (0 no / 1 yes) 	file.write((const char*)&mapinfo->use_Modifier,1); 	// 8 bytes are unused + uptime of system = 0 	file.write("\0\0\0\0\0\0\0\0\0\0\0\0",12); 	// INT USGN ID of the map author with an offset of +51 (0 if author was not logged in) 	temp_int=mapinfo->USGN_ID==0 ? 0 : mapinfo->USGN_ID+51; 	file.write((const char*)&temp_int,4); 	// 8 Int are unused. Writing 32 null byte 	file.write("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",32); 	// 10 strings for map settings 	file << mapinfo->author_Name.c_str() << "\r\n" << "\r\n" << "\r\n" << "\r\n" << "\r\n" << "\r\n" << "\r\n" << "\r\n" << "\r\n" << "\r\n"; 	// Time info 	temp_time_t=time(nullptr); 	temp_tm=localtime(&temp_time_t); 	// STRING string which is built this way (map_xsize (in tiles) * map_ysize (in tiles)) + "x" + tile_count + "$" + CurrentSystemTime (HHMMSS) + "%" + SystemUpTime (in Milliseconds) 	sprintf(temp_str,"%dx%d$%02d%02d%02d%%%d",mapinfo->Map_XSize*mapinfo->Map_YSize,255,temp_tm->tm_hour,temp_tm->tm_min,temp_tm->tm_sec,0); 	// and STRING filename of the tilset image (without path but with extension, "aztec.bmp" for example) 	file << temp_str << "\r\n" << mapinfo->tileset_Name.c_str() << "\r\n"; 	// BYTE number of tiles required from this tileset (tile_count) -1 	file.write("\376",1);	// 254 	// INT map width (map_xsize) in tiles -1 (because it starts at 0) 	temp_int=mapinfo->Map_XSize-1; 	file.write((const char*)&temp_int,4); 	// INT map height (map_ysize) in tiles -1 (because it starts at 0) 	temp_int=mapinfo->Map_YSize-1; 	file.write((const char*)&temp_int,4); 	// STRING filename of map background image (without path but with extension) 	file << mapinfo->background_Name.c_str() << "\r\n"; 	// INT map background scroll x speed 	file.write((const char*)&mapinfo->scroll_X,4); 	// INT map background scroll y speed 	file.write((const char*)&mapinfo->scroll_Y,4); 	// 3 BYTE RGB background color 	file.write(mapinfo->background_RGB,3); 	// STRING string to test if header is okay with value "ed.erawtfoslaernu" (unrealsoftware.de backwards) 	file << "ed.erawtfoslaernu\r\n"; 	// Here i'm writting floor soundless tile info and i'm writing 16 bytes in 16x loop because 16*16=256 	for(int i=0;i<16;i++) 		file.write("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",16); 	for(int x=0;x<mapinfo->Map_XSize;x++) { 		for(int y=0;y<mapinfo->Map_YSize;y++) 			file.write(&mapinfo->default_Frame,1); 	} 	// tile modifier 	if(mapinfo->use_Modifier) { 		for(int x=0;x<mapinfo->Map_XSize;x++) { 			for(int y=0;y<mapinfo->Map_YSize;y++) 				file.write("\0",1); 		} 	} 	file.write("\0\0\0\0",4);	// INT number of entities in the map (entity_count) = 0 	file.close();	// close file }
int main(int argc,char* argv[]) { 	MapWriter_Info mapinfo; 	if(argc<2) { 		printf("Usage: %s <file name>\n",argv[0]); 		return 1; 	} 	memset(&mapinfo,0,sizeof(MapWriter_Info)); 	mapinfo.author_Name=std::string("Test name"); 	mapinfo.background_Name=std::string("");		// if there's a string info that you don't need, always create new empty string 	// X and Y size 	mapinfo.Map_XSize=5; 	mapinfo.Map_YSize=5; 	 	mapinfo.scroll_Tiles=false;	// Don't scroll background like tiles 	mapinfo.tileset_Name=std::string("cs2dnorm.bmp");	// change it if necessary 	mapinfo.use_Modifier=true;	// use tile rotation, opacity, etc. 	mapinfo.USGN_ID=88318;		// your USGN ID here. It does +51 while writing only. So just put real USGN id in here 	generate_empty_map(std::string(argv[1]),&mapinfo);	// generate map based from first program argument. 	return 0; }