/* Rise one level highter.*/ bool ascend(char map[MAPH][MAPW], char seen[MAPH][MAPW], Enemy enemies[MAPH][MAPW], Enemy enemylist[FLOORS], Item items[MAPH][MAPW], int x, int y, int level) { /* Standing on chairs then generate us new maps and new enemies and return true.*/ if (map[y][x] == '>') { level++; mapgen(map, x, y); clearenemies(enemies); spawnenemies(map, enemies, enemylist, x, y, level, 10); spawnhealth(map, enemies, x, y, level); clearmemory(seen); clearitems(items); clear(); return true; } return false; }
//---------- Begin of function main ----------// // // Compilation constants: // // DEBUG - normal debugging // DEBUG2 - shortest path searching and unit action debugging // DEBUG3 - debugging some functions (e.g. Location::get_loc()) which // will cause major slowdown. // // Command line paramters: // -join <named or ip address> // Begin the program by attempting to connect to the specified address. // -host // Begin the program by hosting a multiplayer match // -name <player name> // Set the name you wish to be known as. // // You cannot specify -join or -host more than once. // int main(int argc, char **argv) { #ifndef _MSC_VER setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); #endif sys.set_config_dir(); //try to read from CONFIG.DAT, moved to AM.CPP if( !config.load("CONFIG.DAT") ) { new_config_dat_flag = 1; config.init(); } //----- read command line arguments -----// for (int i = 0; i < argc; i++) { // Examine command line here } if( !sys.init() ) return FALSE; //err.set_extra_handler( extra_error_handler ); // set extra error handler, save the game when a error happens // 7kmapgen: We take over from here //game.main_menu(); mapgen(); sys.deinit(); // [BUG/WORKAROUND] For some reason, stdout fails to flush. It does works for 7kaa, and I can't find a difference... // Needed for ERR and MSG logs. fflush(0); return 1; }
C4MapgenHandle* c4_mapgen_handle_new(const char* filename, const char* source, const char* script_path, C4MaterialMapHandle* material_map, C4TextureMapHandle* texture_map, unsigned int map_width, unsigned int map_height) { try { C4SLandscape landscape; landscape.Default(); landscape.MapWdt.Set(map_width, 0, map_width, map_width); landscape.MapHgt.Set(map_height, 0, map_height, map_height); landscape.MapPlayerExtend = 0; C4MapCreatorS2 mapgen( &landscape, HANDLE_TO_TEXTURE_MAP(texture_map), HANDLE_TO_MATERIAL_MAP(material_map), 1 ); C4MCParser parser(&mapgen); parser.ParseMemFile(source, filename); C4MCMap* map = mapgen.GetMap(NULL); if(!map) throw std::runtime_error("No map definition in source file"); // Setup the script engine if there is an algo=script overlay in the // Landscape.txt file if(HasAlgoScript(mapgen.GetMap(NULL))) { // Re-initialize script engine. Otherwise, we get a warning when the user // changes the value of a constant, since it is defined already from the // previous map rendering. Note that we do not need to re-load the map library. c4_mapgen_handle_deinit_script_engine(); c4_mapgen_handle_init_script_engine(); if(script_path == NULL) throw std::runtime_error("For algo=script overlays to work, save the file first at the location of the Script.c file"); gchar* dirname = g_path_get_dirname(script_path); gchar* basename = g_path_get_basename(script_path); C4Group File; if(!File.Open(dirname)) { StdStrBuf error_msg = FormatString("Failed to open directory '%s': %s", dirname, File.GetError()); g_free(dirname); g_free(basename); throw std::runtime_error(error_msg.getData()); } // get scripts File.ResetSearch(); if(!File.FindNextEntry(basename, (char*)NULL)) { g_free(dirname); g_free(basename); StdStrBuf error_msg = FormatString("Failed to load '%s': No such file", script_path); throw std::runtime_error(error_msg.getData()); } c4_log_handle_clear(); GameScript.Load(File, basename, NULL, NULL); g_free(dirname); g_free(basename); const char* parse_error = c4_log_handle_get_first_log_message(); if(parse_error) throw std::runtime_error(parse_error); // Link script engine (resolve includes/appends, generate code) c4_log_handle_clear(); ScriptEngine.Link(&::Definitions); if(c4_log_handle_get_n_log_messages() > 1) throw std::runtime_error(c4_log_handle_get_first_log_message()); // Set name list for globals ScriptEngine.GlobalNamed.SetNameList(&ScriptEngine.GlobalNamedNames); } c4_log_handle_clear(); int32_t out_width, out_height; BYTE* array = mapgen.RenderBuf(NULL, out_width, out_height); // Don't show any map if there was a script runtime error const char* runtime_error = c4_log_handle_get_first_log_message(); if(runtime_error) { delete[] array; throw std::runtime_error(runtime_error); } C4MapgenHandle* handle = new C4MapgenHandle; handle->width = map_width; handle->height = map_height; handle->rowstride = out_width; handle->error_message = NULL; handle->data = array; return handle; } catch(const C4MCParserErr& err) { C4MapgenHandle* handle = new C4MapgenHandle; handle->width = 0; handle->height = 0; handle->error_message.Copy(err.Msg); handle->data = NULL; return handle; } catch(const std::exception& ex) { C4MapgenHandle* handle = new C4MapgenHandle; handle->width = 0; handle->height = 0; handle->error_message.Copy(ex.what()); handle->data = NULL; return handle; } }