bool parser::register_rc_pal(const std::string& map_entry_name, const std::string& rc_array) { if(debug_mode()) { std::cerr << "registering RC palette '" << map_entry_name << "' of color array: " << rc_array << '\n'; } std::vector<uint32_t> cvt_pal = string2rgb(rc_array); return rc_pal_tab_.insert( std::make_pair(map_entry_name, cvt_pal) ).second; }
void game_config_manager::load_game_config(FORCE_RELOAD_CONFIG force_reload) { // Make sure that 'debug mode' symbol is set // if command line parameter is selected // also if we're in multiplayer and actual debug mode is disabled. game_config::scoped_preproc_define debug_mode("DEBUG_MODE", game_config::debug || game_config::mp_debug); // Game_config already holds requested config in memory. if(!game_config_.empty() && (force_reload == NO_FORCE_RELOAD) && old_defines_map_ == cache_.get_preproc_map()) { return; } loadscreen::global_loadscreen_manager loadscreen_manager(disp_.video()); cursor::setter cur(cursor::WAIT); // The loadscreen will erase the titlescreen. // NOTE: even without loadscreen, needed after MP lobby. try { // Read all game configs. // First we should load data/, // then handle terrains so that they are last loaded from data/. // 2nd everything in userdata. loadscreen::start_stage("verify cache"); data_tree_checksum(); loadscreen::start_stage("create cache"); // Start transaction so macros are shared. game_config::config_cache_transaction main_transaction; cache_.get_config(game_config::path +"/data", game_config_); main_transaction.lock(); // Put the gfx rules aside so that we can prepend the add-on // rules to them. config core_terrain_rules; core_terrain_rules.splice_children(game_config_, "terrain_graphics"); load_addons_cfg(); // Extract the Lua scripts at toplevel. extract_preload_scripts(game_config_); game_config_.clear_children("lua"); // Put the gfx rules back to game config. game_config_.splice_children(core_terrain_rules, "terrain_graphics"); set_multiplayer_hashes(); set_color_info(); set_unit_data(); terrain_builder::set_terrain_rules_cfg(game_config()); ::init_strings(game_config()); theme::set_known_themes(&game_config()); } catch(game::error& e) { ERR_CONFIG << "Error loading game configuration files\n"; gui2::show_error_message(disp_.video(), _("Error loading game configuration files: '") + e.message + _("' (The game will now exit)")); throw; } old_defines_map_ = cache_.get_preproc_map(); // Set new binary paths. paths_manager_.set_paths(game_config()); }
void game_config_manager::load_game_config(FORCE_RELOAD_CONFIG force_reload, game_classification const* classification) { // Make sure that 'debug mode' symbol is set // if command line parameter is selected // also if we're in multiplayer and actual debug mode is disabled. game_config::scoped_preproc_define debug_mode("DEBUG_MODE", game_config::debug || game_config::mp_debug); // Game_config already holds requested config in memory. if(!game_config_.empty() && (force_reload == NO_FORCE_RELOAD) && old_defines_map_ == cache_.get_preproc_map()) { return; } loadscreen::global_loadscreen_manager loadscreen_manager(disp_.video()); cursor::setter cur(cursor::WAIT); // The loadscreen will erase the titlescreen. // NOTE: even without loadscreen, needed after MP lobby. try { // Read all game configs. // First we should load data/, // then handle terrains so that they are last loaded from data/. // 2nd everything in userdata. loadscreen::start_stage("verify cache"); data_tree_checksum(); loadscreen::start_stage("create cache"); // Start transaction so macros are shared. game_config::config_cache_transaction main_transaction; // Load the selected core cache_.get_config(get_wml_location(preferences::wml_tree_root()), game_config_); // Load the mainline core definitions to make sure switching back is always possible. config default_core_cfg; cache_.get_config(game_config::path + "/data/cores.cfg", default_core_cfg); game_config_.append(default_core_cfg); main_transaction.lock(); // Put the gfx rules aside so that we can prepend the add-on // rules to them. config core_terrain_rules; core_terrain_rules.splice_children(game_config_, "terrain_graphics"); load_addons_cfg(); // If multiplayer campaign is being loaded, [scenario] tags should // become [multiplayer] tags and campaign's id should be added to them // to allow to recognize which scenarios belongs to a loaded campaign. if (classification != NULL) { if (classification->campaign_type == game_classification::MULTIPLAYER && !classification->campaign_define.empty()) { const config& campaign = game_config().find_child("campaign", "define", classification->campaign_define); const std::string& campaign_id = campaign["id"]; const bool require_campaign = campaign["require_campaign"].to_bool(true); const config::const_child_itors &ci = game_config().child_range("scenario"); std::vector<config> scenarios(ci.first, ci.second); game_config_.clear_children("scenario"); BOOST_FOREACH(config& cfg, scenarios) { cfg["campaign_id"] = campaign_id; cfg["require_scenario"] = require_campaign; game_config_.add_child(lexical_cast<std::string>(game_classification::MULTIPLAYER), cfg); } } } // Extract the Lua scripts at toplevel. extract_preload_scripts(game_config_); game_config_.clear_children("lua"); // Put the gfx rules back to game config. game_config_.splice_children(core_terrain_rules, "terrain_graphics"); set_multiplayer_hashes(); set_color_info(); set_unit_data(); terrain_builder::set_terrain_rules_cfg(game_config()); ::init_strings(game_config()); theme::set_known_themes(&game_config()); } catch(game::error& e) {
int trs_main(void) { const int value = u.c[UC_VALUE]; int tmp, typ = TRS_NORM; int trs; double adj; if (debug_mode()) printf("trs: l = %d\r\n", value); tmp = roll(1, 100); if (tmp > 80 && tmp <= 90) typ = TRS_CHEST; else if (tmp > 90) typ = TRS_OBJ; switch (typ) { case TRS_CHEST: if ((trs = trs_chest()) == YEP) return(YEP); if (trs == MAYBE) break; /* fall through */ case TRS_OBJ: if (trs_obj() == YEP) return(YEP); break; case TRS_NORM: if (tmp <= 30) { printf("You see a pile of silver...\r\n"); trs = 100 * rnd() * value + 10; } else if (tmp <= 40) { printf("You see a pile of gold...\r\n"); trs = 500 * rnd() * value + 50; } else if (tmp <= 60) { printf("You see a pile of platinum...\r\n"); trs = 1000 * rnd() * value + 100; } else if (tmp <= 72) { printf("You see some gems...\r\n"); trs = 500.0 * sqrt((double)rnd()) * value + 150.0; } else { printf("You see a jewel...\r\n"); trs = 6000.0 * rnd() * rnd() * rnd() * value + 500; } trs_top: utl_dtrp(); printf("Press <CR> to pick it up, <LF> to leave it behind: "); tmp = getchar(); printf("\r\n"); if (tmp < 0) tmp = '\n'; if (tmp == '\n') { u.c[UC_STATE] = XXX_NORM; break; } if (tmp != '\r') { printf("DUMMY!\007\r\n"); goto trs_top; } if (u.i[ROOM_TREASURE_BOOBYTRAPPED] == 1) if (cbt_ohitu((int) (u.c[UC_DGNLVL] / 1.2)) == YEP) return(YEP); printf("The treasure is worth %d gold.\r\n", trs); u.c[UC_GOLDFOUND] += trs; u.c[UC_STATE] = XXX_NORM; adj = u.c[UC_DGNLVL] / (double) u.c[UC_LEVEL]; if (adj > 1.0) adj = 1.0; u.c[UC_EXPGAIN] += trs * adj; break; default: printf("trs: internal error\r\n"); unix_exit(1); } u.i[ROOM_MONSTER] = u.i[ROOM_TREASURE] = u.i[ROOM_TREASURE_BOOBYTRAPPED] = 0; save_room(false); if (u.i[ROOM_SPECIAL] == 0) { u.c[UC_STATE] = DGN_PROMPT; return(NOPE); } utl_pplot(NOPE); return(spc_main()); }