From 5fb57f5f9551a21ba4e8daf32095b3b2c5a208d1 Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Sun, 29 Mar 2026 15:00:53 -0600 Subject: [PATCH] gen(bar_codemod): spring-split --- common/configs/unit_restrictions_config.lua | 12 +- common/holidays.lua | 6 +- common/lib_startpoint_guesser.lua | 6 +- common/springFunctions.lua | 10 +- common/springOverrides.lua | 12 +- common/springUtilities/debug.lua | 16 +- common/springUtilities/image_tga.lua | 6 +- common/springUtilities/synced.lua | 2 +- common/springUtilities/tableFunctions.lua | 4 +- common/springUtilities/teamFunctions.lua | 22 +- common/tableFunctionsTests.lua | 42 +- common/testing/test_extra_utils.lua | 10 +- common/traversability_grid.lua | 2 +- common/upgets/api_resource_spot_finder.lua | 18 +- common/wav.lua | 4 +- gamedata/alldefs_post.lua | 17 +- gamedata/defs.lua | 2 +- gamedata/featuredefs.lua | 4 +- gamedata/featuredefs_post.lua | 2 +- gamedata/modrules.lua | 4 +- gamedata/post_save_to_customparams.lua | 4 +- gamedata/unitdefs.lua | 18 +- gamedata/unitdefs_post.lua | 24 +- gamedata/weapondefs.lua | 6 +- luaintro/Addons/engine_taskbar_control.lua | 4 +- luaintro/Addons/main.lua | 26 +- luaintro/Addons/music.lua | 40 +- luaintro/config.lua | 2 +- luaintro/main.lua | 12 +- luaintro/springconfig.lua | 190 +-- .../Utilities/damgam_lib/nearby_capture.lua | 30 +- .../Utilities/damgam_lib/position_checks.lua | 86 +- luarules/Utilities/damgam_lib/spawn_queue.lua | 14 +- luarules/Utilities/damgam_lib/unit_swap.lua | 32 +- luarules/Utilities/unitrendering.lua | 8 +- .../Atmosphereconfigs/acidicquarry.lua | 2 +- .../Atmosphereconfigs/all that simmers.lua | 2 +- .../Atmosphereconfigs/all that smolders.lua | 2 +- .../altored divide bar remake.lua | 2 +- .../configs/Atmosphereconfigs/ascendancy.lua | 2 +- .../centerrock remake dry.lua | 2 +- .../Atmosphereconfigs/centerrock remake.lua | 2 +- .../configs/Atmosphereconfigs/colorado_v2.lua | 2 +- luarules/configs/Atmosphereconfigs/dsdr.lua | 2 +- .../Atmosphereconfigs/eye of horus.lua | 2 +- .../configs/Atmosphereconfigs/folsomdamr.lua | 2 +- luarules/configs/Atmosphereconfigs/forge.lua | 2 +- .../generic_config_setup.lua | 2 +- .../Atmosphereconfigs/koom valley 3.lua | 2 +- .../Atmosphereconfigs/koomvalleybar.lua | 2 +- luarules/configs/Atmosphereconfigs/lv412.lua | 2 +- .../Atmosphereconfigs/onyx cauldron.lua | 2 +- .../Atmosphereconfigs/quicksilver remake.lua | 2 +- .../Atmosphereconfigs/red comet remake.lua | 2 +- .../Atmosphereconfigs/riverdale remake.lua | 2 +- .../Atmosphereconfigs/seths ravine.lua | 2 +- .../Atmosphereconfigs/tabula_remake.lua | 2 +- luarules/configs/Atmosphereconfigs/tma20x.lua | 2 +- .../Atmosphereconfigs/trefoil remake.lua | 2 +- luarules/configs/icon_generator.lua | 2 +- luarules/configs/raptor_spawn_defs.lua | 78 +- luarules/configs/scav_spawn_defs.lua | 82 +- luarules/configs/timeslow_defs.lua | 2 +- luarules/gadgets.lua | 68 +- luarules/gadgets/AILoader.lua | 32 +- luarules/gadgets/activity_broadcast.lua | 8 +- luarules/gadgets/ai/STAI/ai.lua | 2 +- luarules/gadgets/ai/STAI/buildingshst.lua | 4 +- luarules/gadgets/ai/STAI/damagehst.lua | 4 +- luarules/gadgets/ai/STAI/ecohst.lua | 8 +- luarules/gadgets/ai/STAI/labsbst.lua | 4 +- luarules/gadgets/ai/STAI/loshst.lua | 20 +- luarules/gadgets/ai/STAI/maphst.lua | 16 +- luarules/gadgets/ai/STAI/reclaimbst.lua | 2 +- luarules/gadgets/ai/STAI/schedulerHST.lua | 4 +- luarules/gadgets/ai/STAI/scoutbst.lua | 2 +- luarules/gadgets/ai/Shard/unithandler.lua | 2 +- luarules/gadgets/ai/shard_runtime/aibase.lua | 2 +- luarules/gadgets/ai/shard_runtime/shardai.lua | 2 +- .../ai/shard_runtime/spring_lua/boot.lua | 6 +- .../ai/shard_runtime/spring_lua/damage.lua | 4 +- .../ai/shard_runtime/spring_lua/feature.lua | 4 +- .../ai/shard_runtime/spring_lua/game.lua | 30 +- .../ai/shard_runtime/spring_lua/geo.lua | 8 +- .../ai/shard_runtime/spring_lua/map.lua | 28 +- .../ai/shard_runtime/spring_lua/metal.lua | 12 +- .../ai/shard_runtime/spring_lua/shard.lua | 2 +- .../ai/shard_runtime/spring_lua/unit.lua | 68 +- luarules/gadgets/ai/shard_runtime/unit.lua | 2 +- luarules/gadgets/ai_namer.lua | 6 +- luarules/gadgets/ai_ruin_blueprint_tester.lua | 20 +- luarules/gadgets/ai_ruins.lua | 82 +- luarules/gadgets/ai_simpleai.lua | 44 +- luarules/gadgets/api_build_blocking.lua | 34 +- luarules/gadgets/api_damage_stats.lua | 18 +- luarules/gadgets/api_enemyunitdestroyed.lua | 8 +- luarules/gadgets/api_garbage_collector.lua | 2 +- luarules/gadgets/api_missions.lua | 2 +- luarules/gadgets/api_pbr_enabler.lua | 12 +- luarules/gadgets/api_permissions.lua | 18 +- luarules/gadgets/api_widget_events.lua | 6 +- luarules/gadgets/camera_lockcamera.lua | 22 +- luarules/gadgets/cmd_alliance_break.lua | 30 +- luarules/gadgets/cmd_area_mex.lua | 4 +- luarules/gadgets/cmd_build_bugger_off.lua | 32 +- luarules/gadgets/cmd_commander_dance.lua | 28 +- luarules/gadgets/cmd_dev_helpers.lua | 442 +++--- .../gadgets/cmd_factory_stop_production.lua | 16 +- luarules/gadgets/cmd_get_player_data.lua | 52 +- luarules/gadgets/cmd_give.lua | 48 +- luarules/gadgets/cmd_idle_players.lua | 68 +- luarules/gadgets/cmd_limiter.lua | 12 +- luarules/gadgets/cmd_luaui_reload.lua | 2 +- luarules/gadgets/cmd_manual_launch.lua | 6 +- luarules/gadgets/cmd_mex_denier.lua | 14 +- luarules/gadgets/cmd_mouse_pos_broadcast.lua | 14 +- luarules/gadgets/cmd_onoffdesc.lua | 8 +- luarules/gadgets/cmd_paused_is_paused.lua | 4 +- .../gadgets/cmd_place_target_on_ground.lua | 12 +- luarules/gadgets/cmd_remove_stop.lua | 8 +- luarules/gadgets/cmd_remove_wait.lua | 8 +- luarules/gadgets/cmd_selected_units.lua | 12 +- luarules/gadgets/cmd_sendcommand.lua | 20 +- luarules/gadgets/cmd_undo.lua | 84 +- luarules/gadgets/cus_gl4.lua | 258 ++-- luarules/gadgets/dbg_buildicons_run.lua | 18 +- luarules/gadgets/dbg_cob_debug.lua | 6 +- luarules/gadgets/dbg_gadget_profiler.lua | 56 +- luarules/gadgets/dbg_synced_proxy.lua | 12 +- luarules/gadgets/dbg_test_env_helper.lua | 22 +- luarules/gadgets/dbg_unit_callins.lua | 86 +- luarules/gadgets/dbg_unitposition_logger.lua | 26 +- luarules/gadgets/dev_replay_data.lua | 2 +- luarules/gadgets/feature_dead_explosion.lua | 10 +- luarules/gadgets/feature_debris_physics.lua | 4 +- luarules/gadgets/fx_atmosphere.lua | 48 +- luarules/gadgets/fx_depthcharge_splash.lua | 4 +- luarules/gadgets/fx_missile_smoke.lua | 8 +- .../gadgets/fx_missile_starburst_liftoff.lua | 14 +- luarules/gadgets/fx_projectile_effects.lua | 14 +- luarules/gadgets/fx_reclaim_shards.lua | 4 +- luarules/gadgets/fx_submissile_splash.lua | 8 +- luarules/gadgets/fx_watersplash.lua | 8 +- luarules/gadgets/gaia_critters.lua | 62 +- luarules/gadgets/game_allyteam_ranking.lua | 16 +- luarules/gadgets/game_apm_broadcast.lua | 8 +- luarules/gadgets/game_assistdronespawn.lua | 20 +- luarules/gadgets/game_autocolors.lua | 80 +- luarules/gadgets/game_commander_builder.lua | 18 +- luarules/gadgets/game_custom_map_tidal.lua | 4 +- luarules/gadgets/game_disable_assist_ally.lua | 28 +- .../gadgets/game_disable_unit_sharing.lua | 2 +- luarules/gadgets/game_draft_spawn_order.lua | 46 +- luarules/gadgets/game_dynamic_maxunits.lua | 94 +- luarules/gadgets/game_easter_eggs.lua | 10 +- luarules/gadgets/game_end.lua | 98 +- luarules/gadgets/game_energy_conversion.lua | 24 +- luarules/gadgets/game_ffa_start_setup.lua | 28 +- luarules/gadgets/game_fogofwar_remover.lua | 6 +- luarules/gadgets/game_fps_broadcast.lua | 6 +- luarules/gadgets/game_id.lua | 2 +- luarules/gadgets/game_initial_spawn.lua | 124 +- luarules/gadgets/game_logger.lua | 14 +- luarules/gadgets/game_message.lua | 6 +- luarules/gadgets/game_no_rush_mode.lua | 24 +- luarules/gadgets/game_no_share_to_enemy.lua | 12 +- .../gadgets/game_prevent_excessive_share.lua | 10 +- luarules/gadgets/game_quick_start.lua | 94 +- luarules/gadgets/game_replace_afk_players.lua | 56 +- .../gadgets/game_restrict_resurrection.lua | 6 +- .../gadgets/game_restrict_unit_sharing.lua | 14 +- luarules/gadgets/game_selfd_resign.lua | 28 +- .../gadgets/game_tax_resource_sharing.lua | 32 +- luarules/gadgets/game_team_com_ends.lua | 32 +- luarules/gadgets/game_team_death_effect.lua | 42 +- luarules/gadgets/game_team_power_watcher.lua | 34 +- luarules/gadgets/game_team_resources.lua | 34 +- luarules/gadgets/game_tech_blocking.lua | 30 +- .../gadgets/game_territorial_domination.lua | 78 +- luarules/gadgets/game_volcano_pyroclastic.lua | 40 +- luarules/gadgets/gfx_debrisexplosions.lua | 6 +- luarules/gadgets/gfx_explosion_lights.lua | 10 +- luarules/gadgets/gfx_raptor_scum_gl4.lua | 64 +- luarules/gadgets/gfx_reclaim_fx.lua | 46 +- luarules/gadgets/gfx_tree_feller.lua | 72 +- luarules/gadgets/gfx_unit_glass.lua | 46 +- luarules/gadgets/gfx_unit_script_decals.lua | 6 +- luarules/gadgets/gfx_unit_script_lights.lua | 6 +- luarules/gadgets/gfx_unit_shield_effects.lua | 58 +- luarules/gadgets/gfx_wade_fx.lua | 16 +- luarules/gadgets/gpumem_broadcast.lua | 6 +- .../graphics_territorial_domination.lua | 24 +- luarules/gadgets/gui_awards.lua | 34 +- luarules/gadgets/gui_display_dps.lua | 32 +- luarules/gadgets/gui_soundeffects.lua | 44 +- luarules/gadgets/include/GenBrdfLut.lua | 10 +- luarules/gadgets/include/GenEnvLut.lua | 8 +- luarules/gadgets/include/LuaShader.lua | 2 +- luarules/gadgets/include/SpawnerEnemyLib.lua | 2 +- .../gadgets/include/startbox_utilities.lua | 2 +- luarules/gadgets/map_atmosphere_cegs.lua | 152 +- .../gadgets/map_explosion_deformation_fix.lua | 6 +- luarules/gadgets/map_geofix.lua | 8 +- luarules/gadgets/map_lava.lua | 60 +- luarules/gadgets/map_metal_spot_placer.lua | 8 +- luarules/gadgets/map_nightmode.lua | 28 +- luarules/gadgets/map_sun_handler.lua | 6 +- luarules/gadgets/map_voidground.lua | 14 +- luarules/gadgets/map_waterlevel.lua | 32 +- luarules/gadgets/mo_battle_royale.lua | 16 +- luarules/gadgets/mo_com_counter.lua | 8 +- luarules/gadgets/mo_coop_II.lua | 36 +- luarules/gadgets/mo_ffa.lua | 42 +- luarules/gadgets/mo_preventcombomb.lua | 24 +- luarules/gadgets/pve_areahealers.lua | 22 +- luarules/gadgets/pve_attachments.lua | 18 +- luarules/gadgets/pve_boss_drones.lua | 28 +- .../gadgets/pve_boss_priority_targetting.lua | 10 +- luarules/gadgets/pve_builder_controller.lua | 18 +- luarules/gadgets/pve_nuke_controller.lua | 24 +- luarules/gadgets/pve_supply_drops.lua | 28 +- luarules/gadgets/raptor_spawner_defense.lua | 120 +- .../Blueprints/BYAR/blueprint_controller.lua | 4 +- .../ruins/Blueprints/BYAR/blueprint_tiers.lua | 2 +- luarules/gadgets/scav_cloud_spawner.lua | 28 +- luarules/gadgets/scav_lootbox_collector.lua | 20 +- luarules/gadgets/scav_spawn_effect.lua | 16 +- luarules/gadgets/scav_spawner_defense.lua | 318 ++-- luarules/gadgets/sfx_notifications.lua | 67 +- .../gadgets/sfx_notifications_broadcaster.lua | 8 +- .../gadgets/snd_battle_volume_controller.lua | 10 +- luarules/gadgets/system_info.lua | 10 +- .../gadgets/unit_aa_targeting_priority.lua | 4 +- .../gadgets/unit_air_attacksafetydistance.lua | 12 +- luarules/gadgets/unit_air_plants.lua | 10 +- .../gadgets/unit_airtransport_load_unload.lua | 10 +- luarules/gadgets/unit_airunitsturnradius.lua | 18 +- luarules/gadgets/unit_area_timed_damage.lua | 34 +- luarules/gadgets/unit_areaattack.lua | 10 +- luarules/gadgets/unit_areaattack_limiter.lua | 4 +- luarules/gadgets/unit_attached_con_turret.lua | 62 +- .../gadgets/unit_attached_con_turret_mex.lua | 84 +- luarules/gadgets/unit_attributes.lua | 50 +- luarules/gadgets/unit_block_fake_geo.lua | 4 +- .../gadgets/unit_bomber_no_air_target.lua | 2 +- luarules/gadgets/unit_builder_priority.lua | 34 +- .../gadgets/unit_cancel_orders_on_share.lua | 10 +- luarules/gadgets/unit_capture_decay.lua | 4 +- luarules/gadgets/unit_capture_only_enemy.lua | 6 +- luarules/gadgets/unit_carrier_spawner.lua | 118 +- luarules/gadgets/unit_cheat_no_waste.lua | 12 +- luarules/gadgets/unit_cloak.lua | 28 +- .../unit_collision_damage_behavior.lua | 12 +- luarules/gadgets/unit_combomb_full_damage.lua | 8 +- luarules/gadgets/unit_commando_watch.lua | 14 +- luarules/gadgets/unit_continuous_aim.lua | 2 +- luarules/gadgets/unit_corpse_link.lua | 8 +- luarules/gadgets/unit_crashing_aircraft.lua | 40 +- luarules/gadgets/unit_cursors.lua | 2 +- .../unit_custom_weapons_behaviours.lua | 50 +- .../gadgets/unit_custom_weapons_cluster.lua | 40 +- .../gadgets/unit_custom_weapons_overpen.lua | 48 +- luarules/gadgets/unit_custommaxranges.lua | 6 +- luarules/gadgets/unit_dead.lua | 8 +- luarules/gadgets/unit_death_animations.lua | 12 +- luarules/gadgets/unit_dgun_behaviour.lua | 24 +- luarules/gadgets/unit_dgun_cmdtype_fix.lua | 6 +- .../gadgets/unit_disallow_underwater_load.lua | 8 +- luarules/gadgets/unit_dragons_disguise.lua | 10 +- .../gadgets/unit_dynamic_collision_volume.lua | 44 +- luarules/gadgets/unit_evolution.lua | 96 +- luarules/gadgets/unit_explosion_spawner.lua | 46 +- luarules/gadgets/unit_factory_guard.lua | 24 +- luarules/gadgets/unit_factory_quota.lua | 10 +- luarules/gadgets/unit_factory_unblocking.lua | 12 +- luarules/gadgets/unit_footprint_clearance.lua | 16 +- .../gadgets/unit_geo_upgrade_reclaimer.lua | 30 +- luarules/gadgets/unit_hats.lua | 122 +- .../unit_healthbars_widget_forwarding.lua | 22 +- luarules/gadgets/unit_icongenerator.lua | 72 +- luarules/gadgets/unit_infestor_spawn.lua | 4 +- luarules/gadgets/unit_inherit_creation_xp.lua | 10 +- .../gadgets/unit_instant_self_destruct.lua | 4 +- luarules/gadgets/unit_interceptors.lua | 10 +- luarules/gadgets/unit_intergrated_hats.lua | 6 +- luarules/gadgets/unit_juno_damage.lua | 16 +- luarules/gadgets/unit_juno_damage_mini.lua | 18 +- luarules/gadgets/unit_juno_rework_damage.lua | 40 +- luarules/gadgets/unit_kill_count.lua | 8 +- .../gadgets/unit_lightning_splash_dmg.lua | 20 +- .../gadgets/unit_mex_upgrade_reclaimer.lua | 30 +- .../gadgets/unit_minesweeper_detection.lua | 22 +- luarules/gadgets/unit_nanoradarpos.lua | 2 +- luarules/gadgets/unit_no_land_damage.lua | 2 +- luarules/gadgets/unit_nonblocking_mines.lua | 4 +- luarules/gadgets/unit_objectify.lua | 58 +- luarules/gadgets/unit_onlytargetcategory.lua | 2 +- luarules/gadgets/unit_onlytargetempable.lua | 6 +- .../gadgets/unit_paralyze_damage_limit.lua | 6 +- .../unit_paralyze_damage_multiplier.lua | 2 +- luarules/gadgets/unit_paralyze_on_off.lua | 2 +- .../gadgets/unit_playable_raptor_manager.lua | 8 +- luarules/gadgets/unit_preaim.lua | 2 +- .../gadgets/unit_prevent_aircraft_hax.lua | 20 +- .../unit_prevent_cloaked_unit_reclaim.lua | 20 +- luarules/gadgets/unit_prevent_lab_hax2.lua | 8 +- luarules/gadgets/unit_prevent_load_hax.lua | 12 +- .../unit_prevent_nanoframe_blocking_hax.lua | 30 +- luarules/gadgets/unit_prevent_range_hax.lua | 2 +- luarules/gadgets/unit_prevent_share_load.lua | 2 +- .../gadgets/unit_prevent_share_self_d.lua | 16 +- luarules/gadgets/unit_prevent_unload_hax.lua | 18 +- .../gadgets/unit_projectile_overrange.lua | 14 +- luarules/gadgets/unit_reactive_armor.lua | 36 +- luarules/gadgets/unit_reclaim_fix.lua | 8 +- luarules/gadgets/unit_respawning.lua | 70 +- luarules/gadgets/unit_resurrected.lua | 26 +- luarules/gadgets/unit_reverse_move.lua | 18 +- luarules/gadgets/unit_scenario_loadout.lua | 44 +- luarules/gadgets/unit_scenario_script.lua | 6 +- luarules/gadgets/unit_script.lua | 46 +- luarules/gadgets/unit_seismic_ping.lua | 14 +- luarules/gadgets/unit_shield_behaviour.lua | 38 +- luarules/gadgets/unit_sinking_ship.lua | 12 +- luarules/gadgets/unit_stack_hack_fix.lua | 14 +- luarules/gadgets/unit_stealthy_passengers.lua | 4 +- luarules/gadgets/unit_stockpile_limit.lua | 8 +- luarules/gadgets/unit_stockpile_script.lua | 12 +- luarules/gadgets/unit_stomp.lua | 2 +- luarules/gadgets/unit_stun_control.lua | 2 +- luarules/gadgets/unit_stun_script.lua | 10 +- luarules/gadgets/unit_stun_storage.lua | 22 +- luarules/gadgets/unit_sunfacing.lua | 2 +- luarules/gadgets/unit_target_on_the_move.lua | 72 +- luarules/gadgets/unit_timeslow.lua | 20 +- luarules/gadgets/unit_tombstones.lua | 10 +- .../gadgets/unit_transport_dies_load_dies.lua | 16 +- luarules/gadgets/unit_transportable_nanos.lua | 12 +- .../unit_transported_building_ghost.lua | 2 +- luarules/gadgets/unit_transportee_hider.lua | 14 +- .../gadgets/unit_transports_air_speed.lua | 8 +- luarules/gadgets/unit_turretspeed.lua | 6 +- luarules/gadgets/unit_wanted_speed.lua | 14 +- luarules/gadgets/unit_water_depth_damage.lua | 24 +- .../gadgets/unit_waterspeedmultiplier.lua | 14 +- .../unit_weapon_smart_select_helper.lua | 24 +- luarules/gadgets/unit_windmill_control.lua | 14 +- luarules/gadgets/unit_workertime_boost.lua | 12 +- luarules/gadgets/unit_xmas.lua | 72 +- luarules/gadgets/unit_xp_range_bonus.lua | 6 +- luarules/gadgets/unit_zombies.lua | 204 +-- luarules/mission_api/actions.lua | 8 +- luarules/mission_api/actions_loader.lua | 6 +- luarules/mission_api/triggers_loader.lua | 10 +- luarules/system.lua | 2 +- luaui.lua | 2 +- luaui/Include/AtlasOnDemand.lua | 36 +- luaui/Include/DrawPrimitiveAtUnit.lua | 4 +- luaui/Include/LuaShader.lua | 2 +- luaui/Include/action_hotkeys.lua | 2 +- .../blueprint_substitution/definitions.lua | 6 +- .../Include/blueprint_substitution/logic.lua | 42 +- .../blueprint_substitution/reports.lua | 16 +- luaui/Include/instancevbotable.lua | 2 +- luaui/Include/minimap_utils.lua | 6 +- luaui/Include/select_api.lua | 52 +- luaui/Include/unitBlocking.lua | 6 +- .../gui_quick_start/gui_quick_start.lua | 28 +- .../gui_tech_points/gui_tech_points.lua | 10 +- .../gui_territorial_domination.lua | 72 +- luaui/RmlWidgets/rml_context_manager.lua | 6 +- luaui/Scenarios/stresstest/circle_attack.lua | 16 +- luaui/Scenarios/stresstest/multi_attack.lua | 22 +- .../stresstest/multi_unsynced_attack.lua | 4 +- luaui/Scenarios/stresstest/nano_commands.lua | 20 +- .../stresstest/nano_unsynced_commands.lua | 4 +- .../Scenarios/stresstest/unsynced_attack.lua | 10 +- .../test_cmd_blueprint_filter.lua | 14 +- .../cmd_blueprint/test_cmd_blueprint_line.lua | 30 +- .../test_cmd_blueprint_single.lua | 24 +- .../cmd_stop_selfd/test_cmd_stop_selfd.lua | 28 +- luaui/Tests/critters/test_critters.lua | 38 +- .../test_gui_pip_autostart_maximize.lua | 12 +- .../test_gui_selfd_icons_armpw.lua | 16 +- .../test_gui_selfd_icons_armvp.lua | 10 +- .../Tests/mex-building/pregame_mex_queue.lua | 16 +- luaui/Tests/mex-building/pregame_mex_snap.lua | 12 +- luaui/Tests/select_api/compare_to_spring.lua | 22 +- luaui/Tests/selftests/test_assertions.lua | 10 +- luaui/Tests/selftests/test_callins.lua | 10 +- luaui/Tests/weapondefs/test_flighttime.lua | 30 +- .../balance/test_arm_vs_cor_fighters.lua | 38 +- .../balance/test_grunts_vs_pawns.lua | 30 +- .../test_gui_battle_resource_tracker.lua | 6 +- .../test_utilities/test_mock.lua | 2 +- .../test_utilities/test_wait.lua | 16 +- luaui/Widgets/__defs_write.lua | 8 +- .../Widgets/ai_ruins_blueprint_generator.lua | 12 +- luaui/Widgets/ana_report_widgets.lua | 2 +- luaui/Widgets/api_analytics.lua | 8 +- luaui/Widgets/api_blueprint.lua | 40 +- luaui/Widgets/api_builder_queue.lua | 14 +- luaui/Widgets/api_chili_draw_gl4.lua | 4 +- luaui/Widgets/api_ignore.lua | 12 +- luaui/Widgets/api_los_combiner_gl4.lua | 10 +- luaui/Widgets/api_object_spotlight.lua | 16 +- luaui/Widgets/api_playernames.lua | 12 +- luaui/Widgets/api_resource_spot_builder.lua | 38 +- luaui/Widgets/api_screencopy_manager.lua | 8 +- luaui/Widgets/api_shared_state.lua | 10 +- luaui/Widgets/api_unit_tracker_gl4.lua | 46 +- luaui/Widgets/api_unit_tracker_tester_gl4.lua | 8 +- luaui/Widgets/api_unitbufferuniform_copy.lua | 4 +- luaui/Widgets/camera_flip.lua | 8 +- luaui/Widgets/camera_fov_changer.lua | 6 +- luaui/Widgets/camera_goto.lua | 2 +- luaui/Widgets/camera_joystick.lua | 26 +- luaui/Widgets/camera_lockcamera.lua | 20 +- .../Widgets/camera_middle_mouse_alternate.lua | 32 +- luaui/Widgets/camera_player_tv.lua | 68 +- luaui/Widgets/camera_remember_mode.lua | 10 +- luaui/Widgets/camera_shake.lua | 4 +- luaui/Widgets/cmd_area_commands_filter.lua | 34 +- luaui/Widgets/cmd_area_mex.lua | 16 +- luaui/Widgets/cmd_area_unload.lua | 10 +- luaui/Widgets/cmd_attack_no_ally.lua | 16 +- luaui/Widgets/cmd_autoquit.lua | 16 +- luaui/Widgets/cmd_bar_hotkeys.lua | 14 +- luaui/Widgets/cmd_blueprint.lua | 48 +- .../cmd_bomber_attack_building_ground.lua | 16 +- luaui/Widgets/cmd_buildsplit.lua | 16 +- luaui/Widgets/cmd_chainactions.lua | 2 +- luaui/Widgets/cmd_commandinsert.lua | 24 +- luaui/Widgets/cmd_commandq_manager.lua | 12 +- luaui/Widgets/cmd_comselect.lua | 10 +- luaui/Widgets/cmd_context_build.lua | 22 +- luaui/Widgets/cmd_customformations2.lua | 52 +- luaui/Widgets/cmd_dance.lua | 8 +- luaui/Widgets/cmd_default_set_target.lua | 14 +- luaui/Widgets/cmd_dgun_no_ally.lua | 8 +- luaui/Widgets/cmd_dgun_no_ground enemies.lua | 14 +- .../cmd_exclude_walls_area_attacks.lua | 8 +- luaui/Widgets/cmd_extractor_snap.lua | 26 +- luaui/Widgets/cmd_fac_holdposition.lua | 4 +- luaui/Widgets/cmd_factory_guard_pref.lua | 2 +- luaui/Widgets/cmd_factory_repeat.lua | 8 +- luaui/Widgets/cmd_factoryqmanager.lua | 42 +- luaui/Widgets/cmd_gamespeed.lua | 8 +- .../cmd_guard_damaged_constructors.lua | 4 +- luaui/Widgets/cmd_guard_remove.lua | 12 +- luaui/Widgets/cmd_guard_transport_factory.lua | 80 +- luaui/Widgets/cmd_holdfire_fix.lua | 8 +- luaui/Widgets/cmd_limit_build_spacing.lua | 6 +- .../Widgets/cmd_line-build_hotkey_ignore.lua | 4 +- .../cmd_nanoturrets_assist_priority.lua | 10 +- luaui/Widgets/cmd_no_duplicate_orders.lua | 18 +- luaui/Widgets/cmd_no_self_selection.lua | 18 +- luaui/Widgets/cmd_onoff.lua | 6 +- .../Widgets/cmd_persistent_build_spacing.lua | 6 +- luaui/Widgets/cmd_quick_build_extractor.lua | 18 +- luaui/Widgets/cmd_resolution_switcher.lua | 28 +- luaui/Widgets/cmd_share_unit.lua | 36 +- luaui/Widgets/cmd_state_remove.lua | 6 +- luaui/Widgets/cmd_state_reverse_toggle.lua | 8 +- luaui/Widgets/cmd_stop_selfd.lua | 4 +- luaui/Widgets/cmd_take_proxy.lua | 2 +- luaui/Widgets/cmd_toggle_key.lua | 2 +- .../cmd_transport_preserve_commands.lua | 8 +- luaui/Widgets/cmd_uikeys_loader.lua | 4 +- luaui/Widgets/cmd_unit_mover.lua | 16 +- ...cmd_unitgroup_clear_selection_on_empty.lua | 6 +- luaui/Widgets/dbg_ceg_auto_reloader.lua | 14 +- .../dbg_deferred_buffer_visualizer.lua | 6 +- luaui/Widgets/dbg_engine_shader_reload.lua | 10 +- luaui/Widgets/dbg_ffa_startpoints_picker.lua | 70 +- luaui/Widgets/dbg_frame_grapher.lua | 18 +- luaui/Widgets/dbg_jitter_timer.lua | 30 +- luaui/Widgets/dbg_mouse_to_mex_portable.lua | 12 +- luaui/Widgets/dbg_profiler_histograms.lua | 18 +- luaui/Widgets/dbg_quadtree_atlas_tester.lua | 4 +- luaui/Widgets/dbg_reloadcob.lua | 8 +- luaui/Widgets/dbg_startbox_editor.lua | 8 +- luaui/Widgets/dbg_test_runner.lua | 46 +- luaui/Widgets/dbg_test_runner_watchdog.lua | 4 +- luaui/Widgets/dbg_unit_callins.lua | 18 +- luaui/Widgets/dbg_unit_csv_export.lua | 2 +- luaui/Widgets/dbg_widget_auto_reloader.lua | 10 +- luaui/Widgets/dbg_widget_profiler.lua | 20 +- luaui/Widgets/death_messages.lua | 16 +- luaui/Widgets/dev_autocheat.lua | 14 +- luaui/Widgets/export_defs.lua | 4 +- luaui/Widgets/flowui_atlas_gl4.lua | 2 +- luaui/Widgets/flowui_gl4.lua | 20 +- luaui/Widgets/gfx_DrawUnitShape_GL4.lua | 12 +- luaui/Widgets/gfx_HighlightUnit_GL4.lua | 10 +- luaui/Widgets/gfx_airjets_gl4.lua | 38 +- luaui/Widgets/gfx_bloom_shader_deferred.lua | 8 +- luaui/Widgets/gfx_cas.lua | 4 +- luaui/Widgets/gfx_darken_map.lua | 8 +- luaui/Widgets/gfx_decals_gl4.lua | 20 +- luaui/Widgets/gfx_deferred_rendering_GL4.lua | 96 +- luaui/Widgets/gfx_distortion_gl4.lua | 68 +- luaui/Widgets/gfx_dof.lua | 10 +- luaui/Widgets/gfx_glass.lua | 22 +- luaui/Widgets/gfx_guishader.lua | 16 +- .../gfx_highlight_commander_wrecks.lua | 20 +- luaui/Widgets/gfx_limit_idle_fps.lua | 26 +- luaui/Widgets/gfx_los_colors.lua | 6 +- luaui/Widgets/gfx_los_view.lua | 16 +- luaui/Widgets/gfx_map_lights.lua | 2 +- luaui/Widgets/gfx_norush_timer_gl4.lua | 22 +- luaui/Widgets/gfx_orb_effects_gl4.lua | 8 +- luaui/Widgets/gfx_paralyze_effect.lua | 16 +- luaui/Widgets/gfx_sepia_tone.lua | 4 +- luaui/Widgets/gfx_showbuilderqueue.lua | 8 +- luaui/Widgets/gfx_snow.lua | 24 +- luaui/Widgets/gfx_ssao.lua | 34 +- luaui/Widgets/gfx_unit_stencil_gl4.lua | 8 +- luaui/Widgets/gfx_volumetric_clouds.lua | 12 +- luaui/Widgets/gui_advplayerslist.lua | 150 +- luaui/Widgets/gui_advplayerslist_gameinfo.lua | 20 +- luaui/Widgets/gui_advplayerslist_mascot.lua | 4 +- .../Widgets/gui_advplayerslist_music_new.lua | 158 +- .../Widgets/gui_advplayerslist_unittotals.lua | 16 +- luaui/Widgets/gui_allySelectedUnits.lua | 24 +- luaui/Widgets/gui_ally_cursors.lua | 30 +- luaui/Widgets/gui_anti_ranges.lua | 24 +- luaui/Widgets/gui_attack_aoe.lua | 30 +- luaui/Widgets/gui_attackrange_gl4.lua | 34 +- luaui/Widgets/gui_awards.lua | 26 +- luaui/Widgets/gui_blast_radius.lua | 26 +- luaui/Widgets/gui_build_eta.lua | 24 +- luaui/Widgets/gui_buildbar.lua | 56 +- luaui/Widgets/gui_building_grid_gl4.lua | 12 +- luaui/Widgets/gui_buildmenu.lua | 78 +- luaui/Widgets/gui_buildspacing.lua | 4 +- luaui/Widgets/gui_cache_icons.lua | 6 +- luaui/Widgets/gui_camera_anchors.lua | 10 +- luaui/Widgets/gui_center_n_select.lua | 12 +- luaui/Widgets/gui_changelog_info.lua | 12 +- luaui/Widgets/gui_chat.lua | 116 +- luaui/Widgets/gui_clearmapmarks.lua | 10 +- luaui/Widgets/gui_com_nametags.lua | 46 +- luaui/Widgets/gui_commanderhurt.lua | 8 +- luaui/Widgets/gui_commands_fx.lua | 38 +- luaui/Widgets/gui_controller_test.lua | 2 +- luaui/Widgets/gui_converter_usage.lua | 8 +- luaui/Widgets/gui_cursor.lua | 24 +- luaui/Widgets/gui_defenserange_gl4.lua | 44 +- luaui/Widgets/gui_easyFacing.lua | 26 +- luaui/Widgets/gui_ecostats.lua | 76 +- luaui/Widgets/gui_emp_decloak_range.lua | 28 +- luaui/Widgets/gui_enemy_spotter.lua | 14 +- luaui/Widgets/gui_factionpicker.lua | 32 +- luaui/Widgets/gui_flanking_icons.lua | 16 +- luaui/Widgets/gui_flowui.lua | 12 +- luaui/Widgets/gui_fonthandler.lua | 14 +- luaui/Widgets/gui_game_type_info.lua | 12 +- luaui/Widgets/gui_gameinfo.lua | 22 +- luaui/Widgets/gui_geothermalspots.lua | 24 +- luaui/Widgets/gui_given_units.lua | 22 +- luaui/Widgets/gui_gridmenu.lua | 94 +- .../gui_ground_ao_plates_features_gl4.lua | 20 +- luaui/Widgets/gui_ground_ao_plates_gl4.lua | 6 +- luaui/Widgets/gui_healthbars_gl4.lua | 68 +- luaui/Widgets/gui_idle_builders.lua | 42 +- luaui/Widgets/gui_info.lua | 148 +- luaui/Widgets/gui_infolos.lua | 10 +- luaui/Widgets/gui_keybind_info.lua | 10 +- luaui/Widgets/gui_language.lua | 4 +- luaui/Widgets/gui_los_view_gl4.lua | 4 +- luaui/Widgets/gui_mapinfo.lua | 10 +- luaui/Widgets/gui_mapmarks_fx.lua | 8 +- luaui/Widgets/gui_messages.lua | 12 +- luaui/Widgets/gui_metalspots.lua | 36 +- luaui/Widgets/gui_minimap.lua | 70 +- luaui/Widgets/gui_mouse_fx.lua | 8 +- luaui/Widgets/gui_options.lua | 1290 ++++++++--------- luaui/Widgets/gui_ordermenu.lua | 40 +- luaui/Widgets/gui_overview_cam_tab_hold.lua | 12 +- .../gui_overview_keep_camera_position.lua | 12 +- luaui/Widgets/gui_pausescreen.lua | 10 +- luaui/Widgets/gui_pip.lua | 870 +++++------ luaui/Widgets/gui_point_tracker.lua | 14 +- luaui/Widgets/gui_pregame_build.lua | 160 +- luaui/Widgets/gui_pregameui.lua | 62 +- luaui/Widgets/gui_pregameui_draft.lua | 108 +- luaui/Widgets/gui_projectile_target_aoe.lua | 24 +- luaui/Widgets/gui_prospector.lua | 14 +- luaui/Widgets/gui_rank_icons_gl4.lua | 28 +- luaui/Widgets/gui_raptorStatsPanel.lua | 42 +- luaui/Widgets/gui_reclaim_field_highlight.lua | 44 +- luaui/Widgets/gui_reclaiminfo.lua | 24 +- luaui/Widgets/gui_rejoinprogress.lua | 10 +- luaui/Widgets/gui_replaybuttons.lua | 20 +- luaui/Widgets/gui_resurrection_halos_gl4.lua | 8 +- luaui/Widgets/gui_savegame.lua | 42 +- luaui/Widgets/gui_scavStatsPanel.lua | 42 +- luaui/Widgets/gui_scavenger_info.lua | 10 +- luaui/Widgets/gui_screen_mode_info.lua | 10 +- .../Widgets/gui_scrolldown_toggleoverview.lua | 10 +- luaui/Widgets/gui_selectedunits_gl4.lua | 36 +- luaui/Widgets/gui_selectionbox.lua | 20 +- luaui/Widgets/gui_selfd_icons.lua | 20 +- luaui/Widgets/gui_sensor_ranges_jammer.lua | 24 +- luaui/Widgets/gui_sensor_ranges_los.lua | 20 +- luaui/Widgets/gui_sensor_ranges_radar.lua | 24 +- .../gui_sensor_ranges_radar_preview.lua | 14 +- luaui/Widgets/gui_sensor_ranges_sonar.lua | 26 +- luaui/Widgets/gui_show_orders.lua | 30 +- luaui/Widgets/gui_spec_next_alive_player.lua | 26 +- luaui/Widgets/gui_spectate_selected.lua | 12 +- luaui/Widgets/gui_spectatingstats.lua | 18 +- luaui/Widgets/gui_spectator_hud.lua | 82 +- luaui/Widgets/gui_team_platter.lua | 8 +- luaui/Widgets/gui_teamstats.lua | 44 +- luaui/Widgets/gui_tooltip.lua | 6 +- luaui/Widgets/gui_top_bar.lua | 100 +- luaui/Widgets/gui_transport_weight_limit.lua | 20 +- luaui/Widgets/gui_turret_trans_range.lua | 8 +- luaui/Widgets/gui_unit_energy_icons.lua | 24 +- luaui/Widgets/gui_unit_group_number.lua | 14 +- luaui/Widgets/gui_unit_idlebuilder_icons.lua | 20 +- luaui/Widgets/gui_unit_stats.lua | 68 +- luaui/Widgets/gui_unit_wait_icons.lua | 18 +- luaui/Widgets/gui_unitgroups.lua | 42 +- luaui/Widgets/gui_vote_interface.lua | 38 +- luaui/Widgets/log_unitdefids.lua | 2 +- luaui/Widgets/logo_adjuster.lua | 16 +- luaui/Widgets/map_auto_mapmark_eraser.lua | 4 +- luaui/Widgets/map_draw_blocker.lua | 6 +- luaui/Widgets/map_edge_extension2.lua | 26 +- luaui/Widgets/map_grass_gl4.lua | 46 +- luaui/Widgets/map_lighting_adjuster.lua | 12 +- .../map_start_position_suggestions.lua | 54 +- luaui/Widgets/map_startbox.lua | 102 +- luaui/Widgets/map_startpolygon_gl4.lua | 16 +- luaui/Widgets/minimap_rotation_manager.lua | 20 +- luaui/Widgets/shard_help_draw.lua | 24 +- luaui/Widgets/snd_mapmark_ping.lua | 4 +- luaui/Widgets/snd_notifications.lua | 76 +- .../snd_notifications_addon_ally_alerts.lua | 6 +- .../snd_notifications_addon_playerstatus.lua | 12 +- ...d_notifications_addon_scavraptorstatus.lua | 16 +- luaui/Widgets/snd_unit_finished.lua | 6 +- luaui/Widgets/snd_volume_osd.lua | 16 +- luaui/Widgets/stats_damage.lua | 2 +- luaui/Widgets/test_DPAT.lua | 14 +- luaui/Widgets/test_dpat_minimal_example.lua | 14 +- luaui/Widgets/tweakdefs_unit_translations.lua | 2 +- luaui/Widgets/unit_alt_set_target_type.lua | 30 +- luaui/Widgets/unit_area_reclaim_enemy.lua | 28 +- luaui/Widgets/unit_attackMoveNotification.lua | 20 +- luaui/Widgets/unit_auto_cloak.lua | 10 +- luaui/Widgets/unit_auto_group.lua | 32 +- luaui/Widgets/unit_autofirstbuildfacing.lua | 10 +- luaui/Widgets/unit_builder_priority.lua | 12 +- luaui/Widgets/unit_clean_builder_queue.lua | 16 +- luaui/Widgets/unit_cloak_firestate.lua | 10 +- .../unit_debug_alt_set_target_type.lua | 22 +- .../Widgets/unit_default_spy_move_cloaked.lua | 12 +- luaui/Widgets/unit_dgun_stall_assist.lua | 24 +- luaui/Widgets/unit_factory_assist_fix.lua | 16 +- luaui/Widgets/unit_factory_quota.lua | 16 +- luaui/Widgets/unit_ghostradar_gl4.lua | 12 +- luaui/Widgets/unit_ghostsite_gl4.lua | 26 +- luaui/Widgets/unit_hold_position.lua | 4 +- luaui/Widgets/unit_idle_guard.lua | 8 +- luaui/Widgets/unit_immobile_builder.lua | 18 +- luaui/Widgets/unit_load_own_moving.lua | 16 +- luaui/Widgets/unit_loop_select.lua | 16 +- luaui/Widgets/unit_only_fighters_patrol.lua | 10 +- luaui/Widgets/unit_set_fighters_fly.lua | 10 +- luaui/Widgets/unit_share_tracker.lua | 18 +- luaui/Widgets/unit_smart_area_reclaim.lua | 32 +- luaui/Widgets/unit_smart_select.lua | 36 +- luaui/Widgets/unit_stateprefs.lua | 18 +- luaui/Widgets/unit_transport_ai.lua | 28 +- luaui/Widgets/unit_waypoint_dragger_2.lua | 22 +- luaui/Widgets/widget_selector.lua | 66 +- luaui/barwidgets.lua | 104 +- .../DeferredLightsGL4WeaponsConfig.lua | 4 +- luaui/configs/DeferredLightsGL4config.lua | 4 +- luaui/configs/DistortionGL4Config.lua | 7 +- luaui/configs/DistortionGL4WeaponsConfig.lua | 6 +- luaui/configs/gridmenu_config.lua | 4 +- luaui/configs/gridmenu_layouts.lua | 6 +- luaui/configs/keyboard_layouts.lua | 2 +- luaui/debug.lua | 54 +- luaui/layout.lua | 2 +- luaui/main.lua | 6 +- luaui/rml_setup.lua | 6 +- luaui/system.lua | 2 +- luaui/utils.lua | 4 +- modelmaterials/001_units_s3o_assimp.lua | 14 +- modelmaterials/128_features_special.lua | 14 +- .../Templates/defaultMaterialTemplate.lua | 18 +- modelmaterials_gl4/001_units_s3o_assimp.lua | 14 +- modelmaterials_gl4/128_features_special.lua | 14 +- .../templates/defaultMaterialTemplate.lua | 24 +- modules/commands.lua | 2 +- modules/customcommands.lua | 6 +- modules/graphics/LuaShader.lua | 44 +- modules/graphics/instancevboidtable.lua | 74 +- modules/graphics/instancevbotable.lua | 98 +- modules/i18n/i18n.lua | 14 +- modules/i18n/i18nlib/i18n/init.lua | 10 +- modules/lava.lua | 28 +- scripts/Critters/critter_duck.lua | 3 +- scripts/Critters/critter_goldfish.lua | 3 +- scripts/Critters/critter_gull.lua | 3 +- scripts/Critters/critter_penguin.lua | 4 +- scripts/Units/armcom_lus.lua | 16 +- scripts/Units/armcomhilvl.lua | 28 +- scripts/Units/armdecom.lua | 6 +- scripts/Units/armmar_lus.lua | 6 +- scripts/Units/armmar_lus/setup.lua | 3 +- scripts/Units/corcom_lus.lua | 16 +- scripts/animation.lua | 6 +- scripts/bots_lus.lua | 4 +- scripts/headers/common_includes_lus.lua | 4 +- scripts/include/util.lua | 6 +- scripts/mines_lus.lua | 16 +- shaders/GLSL/infoLOS.lua | 4 +- shaders/GLSL/infoMetal.lua | 4 +- .../scenarios/scenarioscripts/Begin06.lua | 28 +- spec/builders/spring_synced_builder.lua | 4 +- spec/spec_helper.lua | 4 + units/Legion/Legion EvoCom/legcomlvl10.lua | 2 +- units/Legion/Legion EvoCom/legcomlvl2.lua | 2 +- units/Legion/Legion EvoCom/legcomlvl3.lua | 2 +- units/Legion/Legion EvoCom/legcomlvl4.lua | 2 +- units/Legion/Legion EvoCom/legcomlvl5.lua | 2 +- units/Legion/Legion EvoCom/legcomlvl6.lua | 2 +- units/Legion/Legion EvoCom/legcomlvl7.lua | 2 +- units/Legion/Legion EvoCom/legcomlvl8.lua | 2 +- units/Legion/Legion EvoCom/legcomlvl9.lua | 2 +- units/Scavengers/Boss/scavengerbossv4.lua | 2 +- units/armassistdrone.lua | 2 +- units/armassistdrone_land.lua | 2 +- units/armcomnew.lua | 2 +- units/corassistdrone.lua | 2 +- units/corassistdrone_land.lua | 2 +- units/legassistdrone.lua | 2 +- units/legassistdrone_land.lua | 2 +- units/other/armrespawn.lua | 4 +- units/other/correspawn.lua | 4 +- units/other/evocom/armcomlvl2.lua | 2 +- units/other/evocom/corcomlvl2.lua | 2 +- units/other/legnanotcbase.lua | 4 +- .../raptors/Queens/raptor_queen_easy.lua | 2 +- .../raptors/Queens/raptor_queen_epic.lua | 2 +- .../raptors/Queens/raptor_queen_hard.lua | 2 +- .../raptors/Queens/raptor_queen_normal.lua | 2 +- .../raptors/Queens/raptor_queen_veryeasy.lua | 2 +- .../raptors/Queens/raptor_queen_veryhard.lua | 2 +- 756 files changed, 9482 insertions(+), 9489 deletions(-) diff --git a/common/configs/unit_restrictions_config.lua b/common/configs/unit_restrictions_config.lua index eb62ba21a6a..cbba2d7509e 100644 --- a/common/configs/unit_restrictions_config.lua +++ b/common/configs/unit_restrictions_config.lua @@ -40,7 +40,7 @@ local function shouldShowWaterUnits() return false end - local debugCommands = Spring.GetModOption("debugcommands") + local debugCommands = SpringShared.GetModOption("debugcommands") -- terraform, done too late to read w/ get ground, and too hectic to even try and guess if debugCommands and debugCommands:len() > 1 then @@ -49,10 +49,10 @@ local function shouldShowWaterUnits() end end - local _, _, mapMinWater, _ = Spring.GetGroundExtremes() + local _, _, mapMinWater, _ = SpringShared.GetGroundExtremes() -- water level shifted, done too late by another gadget for this file to read w/ get ground - local moddedWaterLevel = Spring.GetModOption("map_waterlevel") or 0 + local moddedWaterLevel = SpringShared.GetModOption("map_waterlevel") or 0 mapMinWater = mapMinWater - moddedWaterLevel return mapMinWater <= -11 -- units.minWaterUnitDepth @@ -67,11 +67,11 @@ local function hasGeothermalFeatures() geoFeatureDefs[defID] = true end end - local features = Spring.GetAllFeatures() + local features = SpringShared.GetAllFeatures() for i = 1, #features do local featureID = features[i] - if geoFeatureDefs[Spring.GetFeatureDefID(featureID)] then - local _, y, _ = Spring.GetFeaturePosition(featureID) + if geoFeatureDefs[SpringShared.GetFeatureDefID(featureID)] then + local _, y, _ = SpringShared.GetFeaturePosition(featureID) if y < 0 then hasSeaGeo = true else diff --git a/common/holidays.lua b/common/holidays.lua index 2f900d586ca..bf890b552ca 100644 --- a/common/holidays.lua +++ b/common/holidays.lua @@ -1,12 +1,12 @@ -if not Spring.GetModOptions then +if not SpringShared.GetModOptions then return end -if not Spring.GetModOptions().holiday_events then +if not SpringShared.GetModOptions().holiday_events then return end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() local currentDay = modOptions.date_day local currentMonth = modOptions.date_month local currentYear = modOptions.date_year diff --git a/common/lib_startpoint_guesser.lua b/common/lib_startpoint_guesser.lua index 49e8c2d7b3b..9ae248a2c03 100644 --- a/common/lib_startpoint_guesser.lua +++ b/common/lib_startpoint_guesser.lua @@ -12,7 +12,7 @@ local mathSqrt = math.sqrt local mathFloor = math.floor local mathMax = math.max local mathClamp = math.clamp -local spGetGroundHeight = Spring.GetGroundHeight +local spGetGroundHeight = SpringShared.GetGroundHeight local mtta = mathAcos(1.0 - 0.41221) - 0.02 --http://springrts.com/wiki/Movedefs.lua#How_slope_is_determined & the -0.02 is for safety @@ -214,7 +214,7 @@ end function GuessTwo(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable) --TODO: make this more efficient, atm it akes 1-2 sec to run -- search over metal map and find a point with a reasonable amount of non-claimed metal near to it - local mmapx, mmapz = Spring.GetMetalMapSize() -- metal map cords * 16 = world coords + local mmapx, mmapz = SpringShared.GetMetalMapSize() -- metal map cords * 16 = world coords local xres = mathMax(1, mathFloor(mmapx / 16)) local zres = mathMax(1, mathFloor(mmapz / 16)) @@ -261,7 +261,7 @@ function GuessTwo(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable) --TOD end -- if it is, add this metal into points - local m = Spring.GetMetalAmount(x, z) + local m = SpringShared.GetMetalAmount(x, z) if isFree and m > 0.1 then local y = spGetGroundHeight(x * 16, z * 16) for _, p in ipairs(points) do diff --git a/common/springFunctions.lua b/common/springFunctions.lua index 837f74623c8..070851044c9 100644 --- a/common/springFunctions.lua +++ b/common/springFunctions.lua @@ -26,12 +26,12 @@ local utilities = { GetRaptorAllyTeamID = team.GetRaptorAllyTeamID, IsDevMode = function() - local devMode = Spring.GetGameRulesParam("isDevMode") + local devMode = SpringShared.GetGameRulesParam("isDevMode") return (devMode and devMode > 0) and true or false end, ShowDevUI = function() - local devUI = Spring.GetConfigInt("DevUI", 0) + local devUI = SpringUnsynced.GetConfigInt("DevUI", 0) return (devUI > 0) and true or false end, @@ -40,9 +40,9 @@ local utilities = { _devModeCache = nil, _devModeCacheFrame = -1, IsDevModeCached = function() - local frame = Spring.GetGameFrame() + local frame = SpringShared.GetGameFrame() if frame ~= utilities._devModeCacheFrame then - local devMode = Spring.GetGameRulesParam("isDevMode") + local devMode = SpringShared.GetGameRulesParam("isDevMode") utilities._devModeCache = (devMode and devMode > 0) and true or false utilities._devModeCacheFrame = frame end @@ -60,7 +60,7 @@ local utilities = { if cached then return cached end - local accountInfo = select(11, Spring.GetPlayerInfo(playerID)) + local accountInfo = select(11, SpringShared.GetPlayerInfo(playerID)) local accountID = (accountInfo and accountInfo.accountid) and tonumber(accountInfo.accountid) or -1 if accountID ~= -1 then accountIDCache[playerID] = accountID diff --git a/common/springOverrides.lua b/common/springOverrides.lua index e406f8019a7..9ff87b932ad 100644 --- a/common/springOverrides.lua +++ b/common/springOverrides.lua @@ -1,5 +1,5 @@ -if Spring.GetModOptions then - local modOptions = Spring.GetModOptions() +if SpringShared.GetModOptions then + local modOptions = SpringShared.GetModOptions() local modOptionsFile = VFS.Include("modoptions.lua") for _, modOption in ipairs(modOptionsFile) do @@ -31,7 +31,7 @@ if Spring.GetModOptions then end, }) - Spring.GetModOptions = function() + SpringShared.GetModOptions = function() return readOnlyModOptions end @@ -42,8 +42,8 @@ if Spring.GetModOptions then end end -if Spring.Echo then - local echo = Spring.Echo +if SpringShared.Echo then + local echo = SpringShared.Echo local printOptions = { pretty = true } local function multiEcho(...) @@ -81,5 +81,5 @@ if Spring.Echo then end end - Spring.Echo = multiEcho + SpringShared.Echo = multiEcho end diff --git a/common/springUtilities/debug.lua b/common/springUtilities/debug.lua index dd723e9f667..33f1ed59e7a 100644 --- a/common/springUtilities/debug.lua +++ b/common/springUtilities/debug.lua @@ -1,8 +1,8 @@ local function paramsEcho(...) local called_from = "Called from: " .. tostring(debug.getinfo(2).name) .. " args:" - Spring.Echo(called_from) + SpringShared.Echo(called_from) local args = { ... } - Spring.Echo(table.toString(args)) + SpringShared.Echo(table.toString(args)) return ... end @@ -45,7 +45,7 @@ local function traceEcho(...) arguments = arguments .. sep .. ((name and tostring(name)) or "name?") .. "=" .. tostring(value) end end - Spring.Echo(infostr .. functionstr .. " Args:(" .. arguments .. ")") + SpringShared.Echo(infostr .. functionstr .. " Args:(" .. arguments .. ")") end local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...) @@ -56,7 +56,7 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...) -- It will also try to print the source file+line of each function if debug then else - Spring.Echo("traceFullEcho needs debug to work, this seems to be missing or overwritten", debug) + SpringShared.Echo("traceFullEcho needs debug to work, this seems to be missing or overwritten", debug) return end local tracedebug = false -- to debug itself @@ -72,12 +72,12 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...) count = count + 1 if count < maxtableelements then if tracedebug then - Spring.Echo(count, k) + SpringShared.Echo(count, k) end if type(k) == "number" and type(v) == "function" then -- try to get function lists? local vinfo = debug.getinfo(v) if tracedebug then - Spring.Echo(k, v, vinfo, vinfo.name) + SpringShared.Echo(k, v, vinfo, vinfo.name) end --debug.getinfo(v).short_src)? res = res .. tostring(k) .. ":" .. ((vinfo and vinfo.name) or "") .. ", " else @@ -120,7 +120,7 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...) break end if tracedebug then - Spring.Echo(i, j, funcName, name) + SpringShared.Echo(i, j, funcName, name) end local sep = ((arguments == "") and "") or "; " if tostring(name) == "self" then @@ -144,7 +144,7 @@ local function traceFullEcho(maxdepth, maxwidth, maxtableelements, ...) break end end - Spring.Echo(infostr .. functionstr) + SpringShared.Echo(infostr .. functionstr) end return { diff --git a/common/springUtilities/image_tga.lua b/common/springUtilities/image_tga.lua index 9fb5640a277..3234efa1953 100644 --- a/common/springUtilities/image_tga.lua +++ b/common/springUtilities/image_tga.lua @@ -34,7 +34,7 @@ local function loadTGA(fileName) -- returns texture | nil, error on failure local data = string.sub(file, 19, texture.width * texture.height * texture.channels + 18) if string.len(data) ~= texture.width * texture.height * texture.channels then --WHY +1????? - Spring.Echo("Failed to load", fileName, string.len(data), texture.width, texture.height, texture.channels) + SpringShared.Echo("Failed to load", fileName, string.len(data), texture.width, texture.height, texture.channels) return nil, "Error loading file, size mismatch" end @@ -64,7 +64,7 @@ local function loadTGA(fileName) -- returns texture | nil, error on failure end local function saveTGA(texture, fileName) --return nil | error on failure - Spring.Echo("Saving", fileName) + SpringShared.Echo("Saving", fileName) local file = io.open(fileName, "wb") if file == nil then @@ -87,7 +87,7 @@ local function saveTGA(texture, fileName) --return nil | error on failure end end file:close() - Spring.Echo("Saved", fileName) + SpringShared.Echo("Saved", fileName) return nil end diff --git a/common/springUtilities/synced.lua b/common/springUtilities/synced.lua index 56b8ee6fe08..de8c301fd04 100644 --- a/common/springUtilities/synced.lua +++ b/common/springUtilities/synced.lua @@ -1,7 +1,7 @@ -- need this because SYNCED.tables are merely proxies, not real tables local function makeRealTable(proxy, debugTag) if proxy == nil then - Spring.Log("Table Utilities", LOG.ERROR, "Proxy table is nil: " .. (debugTag or "unknown table")) + SpringShared.Log("Table Utilities", LOG.ERROR, "Proxy table is nil: " .. (debugTag or "unknown table")) return end local proxyLocal = proxy diff --git a/common/springUtilities/tableFunctions.lua b/common/springUtilities/tableFunctions.lua index d3a5f089c83..0530fcb95b8 100644 --- a/common/springUtilities/tableFunctions.lua +++ b/common/springUtilities/tableFunctions.lua @@ -3,7 +3,7 @@ local function customKeyToUsefulTable(dataRaw) return end if not type(dataRaw) == "string" then - Spring.Echo("Customkey data error! type == " .. type(dataRaw)) + SpringShared.Echo("Customkey data error! type == " .. type(dataRaw)) else dataRaw = string.gsub(dataRaw, "_", "=") dataRaw = string.base64Decode(dataRaw) @@ -15,7 +15,7 @@ local function customKeyToUsefulTable(dataRaw) end end if err then - Spring.Echo("Customkey error", err) + SpringShared.Echo("Customkey error", err) end end end diff --git a/common/springUtilities/teamFunctions.lua b/common/springUtilities/teamFunctions.lua index 72861c728fd..d0b0b78bbcc 100644 --- a/common/springUtilities/teamFunctions.lua +++ b/common/springUtilities/teamFunctions.lua @@ -14,30 +14,30 @@ local function getSettings() local scavTeamID, scavAllyTeamID, raptorTeamID, raptorAllyTeamID local isHoliday = {} - local gaiaAllyTeamID = select(6, Spring.GetTeamInfo(Spring.GetGaiaTeamID(), false)) - local springAllyTeamList = Spring.GetAllyTeamList() + local gaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(SpringShared.GetGaiaTeamID(), false)) + local springAllyTeamList = SpringShared.GetAllyTeamList() local allyTeamList = {} local allyTeamSizes = {} local entirelyHumanAllyTeams = {} for _, allyTeamID in ipairs(springAllyTeamList) do - local teamList = Spring.GetTeamList(allyTeamID) or {} + local teamList = SpringShared.GetTeamList(allyTeamID) or {} local allyteamEntirelyHuman = true if #teamList > 0 and allyTeamID ~= gaiaAllyTeamID then local isAllyTeamValid = true for _, teamID in ipairs(teamList) do - if select(4, Spring.GetTeamInfo(teamID, false)) then + if select(4, SpringShared.GetTeamInfo(teamID, false)) then allyteamEntirelyHuman = false else - local teamPlayers = Spring.GetPlayerList(teamID) + local teamPlayers = SpringShared.GetPlayerList(teamID) for _, playerID in ipairs(teamPlayers) do playerCount = playerCount + 1 end end - local luaAI = Spring.GetTeamLuaAI(teamID) + local luaAI = SpringShared.GetTeamLuaAI(teamID) if luaAI then if luaAI:find("Raptors") then @@ -89,14 +89,14 @@ local function getSettings() is1v1 = true end - if #entirelyHumanAllyTeams == 1 and #Spring.GetTeamList(entirelyHumanAllyTeams[1]) > 1 then + if #entirelyHumanAllyTeams == 1 and #SpringShared.GetTeamList(entirelyHumanAllyTeams[1]) > 1 then isCoop = true end - if holidaysList and Spring.GetModOptions and Spring.GetModOptions().date_day then - local currentDay = Spring.GetModOptions().date_day - local currentMonth = Spring.GetModOptions().date_month - local currentYear = Spring.GetModOptions().date_year + if holidaysList and SpringShared.GetModOptions and SpringShared.GetModOptions().date_day then + local currentDay = SpringShared.GetModOptions().date_day + local currentMonth = SpringShared.GetModOptions().date_month + local currentYear = SpringShared.GetModOptions().date_year -- FIXME: This doesn't support events that start and end in different years. for holiday, dates in pairs(holidaysList) do diff --git a/common/tableFunctionsTests.lua b/common/tableFunctionsTests.lua index 360e347a316..a42d10ee6fa 100644 --- a/common/tableFunctionsTests.lua +++ b/common/tableFunctionsTests.lua @@ -1,5 +1,5 @@ local function testMergeInPlace(deep) - Spring.Echo(string.format("[test] [table.mergeInPlace(deep: %s)] start", tostring(deep))) + SpringShared.Echo(string.format("[test] [table.mergeInPlace(deep: %s)] start", tostring(deep))) local mergeTarget = { shouldBeOverriden = "no", shouldBeMerged = { @@ -24,7 +24,7 @@ local function testMergeInPlace(deep) } table.mergeInPlace(mergeTarget, mergeData, deep) - Spring.Echo(string.format("[test] [table.mergeInPlace(deep: %s)] %s", tostring(deep), table.toString(mergeTarget))) + SpringShared.Echo(string.format("[test] [table.mergeInPlace(deep: %s)] %s", tostring(deep), table.toString(mergeTarget))) local expectedYesCount = 12 local yesCount = 0 @@ -49,11 +49,11 @@ local function testMergeInPlace(deep) assert(mergeData.shouldBeMerged.shouldBeAdded == mergeTarget.shouldBeMerged.shouldBeAdded, "expected mergeData.shouldBeMerged.shouldBeAdded and mergeTarget.shouldBeMerged.shouldBeAdded to be same instance, due to non-deep merge") end - Spring.Echo(string.format("[test] [table.mergeInPlace(deep: %s)] success", tostring(deep))) + SpringShared.Echo(string.format("[test] [table.mergeInPlace(deep: %s)] success", tostring(deep))) end local function testTableRemoveIf() - Spring.Echo("[test] [table.removeIf] start") + SpringShared.Echo("[test] [table.removeIf] start") local t = { a = 1, b = 2, c = 3, d = 4, e = 5 } local tEven = table.copy(t) table.removeIf(tEven, function(v) @@ -64,8 +64,8 @@ local function testTableRemoveIf() return v % 2 == 0 end) - Spring.Echo(string.format("[test] [table.removeIf] tEven: %s", table.toString(tEven))) - Spring.Echo(string.format("[test] [table.removeIf] tOdd: %s", table.toString(tOdd))) + SpringShared.Echo(string.format("[test] [table.removeIf] tEven: %s", table.toString(tEven))) + SpringShared.Echo(string.format("[test] [table.removeIf] tOdd: %s", table.toString(tOdd))) local assertions = { tEven = { table.count(tEven), 2 }, @@ -75,19 +75,19 @@ local function testTableRemoveIf() for tbl, assertion in pairs(assertions) do assert(assertion[1] == assertion[2], string.format("expected %s to have %s values (actual: %s)", tbl, assertion[1], assertion[2])) end - Spring.Echo("[test] [table.removeIf] success") + SpringShared.Echo("[test] [table.removeIf] success") end local function testTableRemoveAll() - Spring.Echo("[test] [table.removeAll] start") + SpringShared.Echo("[test] [table.removeAll] start") local t = { a = 1, b = 2, c = 1, d = 2, e = 1 } local tOnes = table.copy(t) table.removeAll(tOnes, 2) local tTwos = table.copy(t) table.removeAll(tTwos, 1) - Spring.Echo(string.format("[test] [table.removeAll] tOnes: %s", table.toString(tOnes))) - Spring.Echo(string.format("[test] [table.removeAll] tTwos: %s", table.toString(tTwos))) + SpringShared.Echo(string.format("[test] [table.removeAll] tOnes: %s", table.toString(tOnes))) + SpringShared.Echo(string.format("[test] [table.removeAll] tTwos: %s", table.toString(tTwos))) local assertions = { tOnes = { table.count(tOnes), 3 }, @@ -97,11 +97,11 @@ local function testTableRemoveAll() for tbl, assertion in pairs(assertions) do assert(assertion[1] == assertion[2], string.format("expected %s to have %s values (actual: %s)", tbl, assertion[1], assertion[2])) end - Spring.Echo("[test] [table.removeAll] success") + SpringShared.Echo("[test] [table.removeAll] success") end local function testTableRemoveFirst() - Spring.Echo("[test] [table.removeFirst] start") + SpringShared.Echo("[test] [table.removeFirst] start") local tests = { sequence = { "a", "b", "c" }, -- indexes should be kept without any gaps for this one notASequence = { "a", "b", [4] = "c" }, @@ -109,10 +109,10 @@ local function testTableRemoveFirst() } for name, test in pairs(tests) do - Spring.Echo(string.format("[test] [table.removeFirst] %s: %s", name, table.toString(test))) + SpringShared.Echo(string.format("[test] [table.removeFirst] %s: %s", name, table.toString(test))) for _, value in pairs({ "b", "c", "a" }) do table.removeFirst(test, value) - Spring.Echo(string.format("[test] [table.removeFirst] %s: %s (removed: %s)", name, table.toString(test), value)) + SpringShared.Echo(string.format("[test] [table.removeFirst] %s: %s (removed: %s)", name, table.toString(test), value)) -- special case for sequence: check that indexes are kept without any gaps if name == "sequence" then local prev_i = 0 @@ -125,11 +125,11 @@ local function testTableRemoveFirst() end assert(table.count(test) == 0, string.format("expected table %s to be empty, but it's not", name)) end - Spring.Echo("[test] [table.removeFirst] success") + SpringShared.Echo("[test] [table.removeFirst] success") end local function testTableShuffle() - Spring.Echo("[test] [table.shuffle] start") + SpringShared.Echo("[test] [table.shuffle] start") local t = { "a", "b", "c" } local t0 = { [0] = "a", "b", "c" } local results = { abc = 0, acb = 0, bac = 0, bca = 0, cab = 0, cba = 0 } @@ -146,8 +146,8 @@ local function testTableShuffle() results0[r0] = results0[r0] + 1 end - Spring.Echo(string.format("[test] [table.shuffle] results : %s", table.toString(results))) - Spring.Echo(string.format("[test] [table.shuffle] results0: %s", table.toString(results0))) + SpringShared.Echo(string.format("[test] [table.shuffle] results : %s", table.toString(results))) + SpringShared.Echo(string.format("[test] [table.shuffle] results0: %s", table.toString(results0))) local function mean(tbl) local sum = 0 @@ -177,14 +177,14 @@ local function testTableShuffle() local standardDeviationResults = standardDeviation(results) local standardDeviationResults0 = standardDeviation(results0) - Spring.Echo(string.format("[test] [table.shuffle] [results ] standardDeviation: %s", standardDeviationResults)) - Spring.Echo(string.format("[test] [table.shuffle] [results0] standardDeviation: %s", standardDeviationResults0)) + SpringShared.Echo(string.format("[test] [table.shuffle] [results ] standardDeviation: %s", standardDeviationResults)) + SpringShared.Echo(string.format("[test] [table.shuffle] [results0] standardDeviation: %s", standardDeviationResults0)) local threshold = rounds * 0.005 -- this is not a p-norm but it'll be good enough assert(standardDeviationResults < threshold, string.format("expected results standard deviation to be below %s (actual: %s)", threshold, standardDeviationResults)) assert(standardDeviationResults0 < threshold, string.format("expected results0 standard deviation to be below %s (actual: %s)", threshold, standardDeviationResults0)) - Spring.Echo("[test] [table.shuffle] success") + SpringShared.Echo("[test] [table.shuffle] success") end testMergeInPlace(false) diff --git a/common/testing/test_extra_utils.lua b/common/testing/test_extra_utils.lua index 034a63d8b83..eadd4b2488a 100644 --- a/common/testing/test_extra_utils.lua +++ b/common/testing/test_extra_utils.lua @@ -6,7 +6,7 @@ local currentLevel = 0 local function setAutoHeightMap(enable) autoHeightMap = enable - Spring.Echo("Set autoheightmap", enable) + SpringShared.Echo("Set autoheightmap", enable) end local function levelHeightMap(level) @@ -19,8 +19,8 @@ local function levelHeightMap(level) end SyncedRun(function(locals) local level = locals.level - locals.prevLevel - Spring.LevelHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, level) - Spring.RebuildSmoothMesh(0, 0, Game.mapSizeX, Game.mapSizeZ) + SpringSynced.LevelHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, level) + SpringSynced.RebuildSmoothMesh(0, 0, Game.mapSizeX, Game.mapSizeZ) end, levelTimeout) currentLevel = level heightMapChanged = true @@ -31,8 +31,8 @@ local function restoreHeightMap(force) return end SyncedRun(function() - Spring.RevertHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, 1.0) - Spring.RebuildSmoothMesh(0, 0, Game.mapSizeX, Game.mapSizeZ) + SpringSynced.RevertHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, 1.0) + SpringSynced.RebuildSmoothMesh(0, 0, Game.mapSizeX, Game.mapSizeZ) end, levelTimeout) heightMapChanged = false currentLevel = 0 diff --git a/common/traversability_grid.lua b/common/traversability_grid.lua index ae168346abc..37cfbae4d90 100644 --- a/common/traversability_grid.lua +++ b/common/traversability_grid.lua @@ -2,7 +2,7 @@ -- Try to keep resolution as low as you can get away with and for small zones. -- Remember changes in terrain will invalidate the grid. Re-generations are expensive. -local spGetGroundNormal = Spring.GetGroundNormal +local spGetGroundNormal = SpringShared.GetGroundNormal local floor = math.floor local distance2dSquared = math.distance2dSquared diff --git a/common/upgets/api_resource_spot_finder.lua b/common/upgets/api_resource_spot_finder.lua index f5ea212e676..b2c0cbef9da 100644 --- a/common/upgets/api_resource_spot_finder.lua +++ b/common/upgets/api_resource_spot_finder.lua @@ -47,10 +47,10 @@ local floor, ceil = math.floor, math.ceil local sqrt = math.sqrt local huge = math.huge -local spGetGroundInfo = Spring.GetGroundInfo -local spGetGroundHeight = Spring.GetGroundHeight -local spTestBuildOrder = Spring.TestBuildOrder -local spSetGameRulesParam = Spring.SetGameRulesParam +local spGetGroundInfo = SpringShared.GetGroundInfo +local spGetGroundHeight = SpringShared.GetGroundHeight +local spTestBuildOrder = SpringShared.TestBuildOrder +local spSetGameRulesParam = SpringSynced.SetGameRulesParam local extractorRadius = Game.extractorRadius local extractorRadiusSqr = extractorRadius * extractorRadius @@ -95,11 +95,11 @@ local function GetSpotsGeo() end end local spots = {} - local features = Spring.GetAllFeatures() + local features = SpringShared.GetAllFeatures() local spotCount = 0 for i = 1, #features do - if geoFeatureDefs[Spring.GetFeatureDefID(features[i])] then - local x, y, z = Spring.GetFeaturePosition(features[i]) + if geoFeatureDefs[SpringShared.GetFeatureDefID(features[i])] then + local x, y, z = SpringShared.GetFeaturePosition(features[i]) spotCount = spotCount + 1 spots[spotCount] = { isGeo = true, @@ -217,7 +217,7 @@ local function setMexGameRules(spots) spSetGameRulesParam("mex_metal" .. i, mex.worth) end else - Spring.SetGameRulesParam("mex_count", -1) + SpringSynced.SetGameRulesParam("mex_count", -1) end end @@ -370,7 +370,7 @@ function upget:Initialize() -- base_extraction=0.001 is meant to say that T1 mex is baseline x1, and T2 is baseline x4 -- as opposed to T1 being x0.5 and T2 being x2. -- Unused now. - Spring.SetGameRulesParam("base_extraction", 1.0) + SpringSynced.SetGameRulesParam("base_extraction", 1.0) end if metalMaps[Game.mapName] then diff --git a/common/wav.lua b/common/wav.lua index 9c9bfa15c91..a5db5f195b8 100644 --- a/common/wav.lua +++ b/common/wav.lua @@ -9,7 +9,7 @@ function ReadWAV(fname) return wavCache[fname] end if not VFS.FileExists(fname) then - Spring.Echo("ReadWAV: File does not exist:", fname) + SpringShared.Echo("ReadWAV: File does not exist:", fname) return nil end local data = VFS.LoadFile(fname) @@ -32,7 +32,7 @@ function ReadWAV(fname) } return wavCache[fname] else - Spring.Echo("ReadWAV: File is not a RIFF .wav file:", fname) + SpringShared.Echo("ReadWAV: File is not a RIFF .wav file:", fname) end end diff --git a/gamedata/alldefs_post.lua b/gamedata/alldefs_post.lua index 4dcac632a46..82bc97945e2 100644 --- a/gamedata/alldefs_post.lua +++ b/gamedata/alldefs_post.lua @@ -73,7 +73,7 @@ end function UnitDef_Post(name, uDef) if not modOptions then - modOptions = Spring.GetModOptions() + modOptions = SpringShared.GetModOptions() end -- Cache holiday checks for performance @@ -1623,10 +1623,10 @@ function UnitDef_Post(name, uDef) if oldscript:find(".cob", nil, true) and (not oldscript:find("_clean.", nil, true)) then local newscript = string.sub(oldscript, 1, -5) .. "_clean.cob" if VFS.FileExists("scripts/" .. newscript) then - Spring.Echo("Using new script for", name, oldscript, "->", newscript) + SpringShared.Echo("Using new script for", name, oldscript, "->", newscript) uDef.script = newscript else - Spring.Echo("Unable to find new script for", name, oldscript, "->", newscript, "using old one") + SpringShared.Echo("Unable to find new script for", name, oldscript, "->", newscript, "using old one") end end end @@ -1636,7 +1636,7 @@ function UnitDef_Post(name, uDef) -- Remove invalid unit defs. for index, option in pairs(buildoptions) do if not UnitDefs[option] then - Spring.Log("AllDefs", LOG.INFO, "Removed buildoption (unit not loaded?): " .. tostring(option)) + SpringShared.Log("AllDefs", LOG.INFO, "Removed buildoption (unit not loaded?): " .. tostring(option)) buildoptions[index] = nil end end @@ -1687,7 +1687,7 @@ end -- process weapondef function WeaponDef_Post(name, wDef) if not modOptions then - modOptions = Spring.GetModOptions() + modOptions = SpringShared.GetModOptions() end if isXmas == nil then isXmas = Spring.Utilities.Gametype.GetCurrentHolidays()["xmas"] @@ -2013,8 +2013,7 @@ function WeaponDef_Post(name, wDef) end -- process effects -function ExplosionDef_Post(name, eDef) -end +function ExplosionDef_Post(name, eDef) end -------------------------- -- MODOPTIONS @@ -2024,13 +2023,13 @@ end function ModOptions_Post(UnitDefs, WeaponDefs) -- transporting enemy coms - if Spring.GetModOptions().transportenemy == "notcoms" then + if SpringShared.GetModOptions().transportenemy == "notcoms" then for name, ud in pairs(UnitDefs) do if ud.customparams.iscommander then ud.transportbyenemy = false end end - elseif Spring.GetModOptions().transportenemy == "none" then + elseif SpringShared.GetModOptions().transportenemy == "none" then for name, ud in pairs(UnitDefs) do ud.transportbyenemy = false end diff --git a/gamedata/defs.lua b/gamedata/defs.lua index 43f92b571bf..d47446f0b97 100644 --- a/gamedata/defs.lua +++ b/gamedata/defs.lua @@ -27,7 +27,7 @@ local function LoadDefs(name) local success, result = pcall(VFS.Include, filename, nil, VFS_MODES) if not success then - Spring.Log(section, LOG.ERROR, "Failed to load " .. name) + SpringShared.Log(section, LOG.ERROR, "Failed to load " .. name) error(result) end diff --git a/gamedata/featuredefs.lua b/gamedata/featuredefs.lua index 0a39c458de3..a79196434e2 100644 --- a/gamedata/featuredefs.lua +++ b/gamedata/featuredefs.lua @@ -53,9 +53,9 @@ for _, filename in ipairs(luaFiles) do local success, defs = pcall(VFS.Include, filename, featureDefsEnv, VFS_MODES) if not success then - Spring.Log(section, LOG.ERROR, "Error parsing " .. filename .. ": " .. tostring(defs)) + SpringShared.Log(section, LOG.ERROR, "Error parsing " .. filename .. ": " .. tostring(defs)) elseif defs == nil then - Spring.Log(section, LOG.ERROR, "Missing return table from: " .. filename) + SpringShared.Log(section, LOG.ERROR, "Missing return table from: " .. filename) else for featureDefName, featureDef in pairs(defs) do if (type(featureDefName) == "string") and (type(featureDef) == "table") then diff --git a/gamedata/featuredefs_post.lua b/gamedata/featuredefs_post.lua index c4df135263b..92e239f28e2 100644 --- a/gamedata/featuredefs_post.lua +++ b/gamedata/featuredefs_post.lua @@ -118,7 +118,7 @@ end for name, def in pairs(FeatureDefs) do if not isModelOK(def) then - Spring.Log("featuredefs_post.lua", LOG.WARNING, "Removing feature def", name, "for having invalid model that would crash the engine", def.object) + SpringShared.Log("featuredefs_post.lua", LOG.WARNING, "Removing feature def", name, "for having invalid model that would crash the engine", def.object) FeatureDefs[name] = nil end end diff --git a/gamedata/modrules.lua b/gamedata/modrules.lua index 59f37f2a252..5055e168c45 100644 --- a/gamedata/modrules.lua +++ b/gamedata/modrules.lua @@ -102,7 +102,7 @@ local modrules = { pfUpdateRateScale = 1, -- default: 1. Multiplier for the update rate pfRawMoveSpeedThreshold = 0, -- default: 0. Controls the speed modifier (which includes typemap boosts and up/down hill modifiers) under which units will never do raw move, regardless of distance etc. Defaults to 0, which means units will not try to raw-move into unpathable terrain (e.g. typemapped lava, cliffs, water). You can set it to some positive value to make them avoid pathable but very slow terrain (for example if you set it to 0.2 then they will not raw-move across terrain where they move at 20% speed or less, and will use normal pathing instead - which may still end up taking them through that path). pfHcostMult = 0.2, -- default: 0.2. A float value between 0 and 2. Controls how aggressively the pathing search prioritizes nodes going in the direction of the goal. Higher values mean pathing is cheaper, but can start producing degenerate paths where the unit goes straight at the goal and then has to hug a wall. - nativeExcessSharing = Spring.GetModOptions().easytax == false and Spring.GetModOptions().tax_resource_sharing_amount == 0, -- default: true. If true, the engine will handle resource overflow sharing between allied teams. If false, overflow sharing is disabled and we use Lua implementation in game_tax_resource_sharing.lua gadget. + nativeExcessSharing = SpringShared.GetModOptions().easytax == false and SpringShared.GetModOptions().tax_resource_sharing_amount == 0, -- default: true. If true, the engine will handle resource overflow sharing between allied teams. If false, overflow sharing is disabled and we use Lua implementation in game_tax_resource_sharing.lua gadget. }, transportability = { @@ -115,7 +115,7 @@ local modrules = { paralyze = { paralyzeOnMaxHealth = true, -- Are units paralyzed when the level of emp is greater than their current health or their maximum health? - paralyzeDeclineRate = Spring.GetModOptions().emprework == true and 20 or 40, -- default: 40. + paralyzeDeclineRate = SpringShared.GetModOptions().emprework == true and 20 or 40, -- default: 40. }, experience = { diff --git a/gamedata/post_save_to_customparams.lua b/gamedata/post_save_to_customparams.lua index 0cd021bd15d..1509cabc0b5 100644 --- a/gamedata/post_save_to_customparams.lua +++ b/gamedata/post_save_to_customparams.lua @@ -39,12 +39,12 @@ function SaveDefToCustomParams(defType, name, def) -- save def as a string def.customparams = def.customparams or {} def.customparams.__def = table.tostring(def) - Spring.Echo("saved " .. defType .. "." .. name .. " to customparams.__def as string") + SpringShared.Echo("saved " .. defType .. "." .. name .. " to customparams.__def as string") end function MarkDefOmittedInCustomParams(defType, name, def) -- mark that this def is saved elsewhere as part of another def def.customparams = def.customparams or {} def.customparams.__def = "omitted" - Spring.Echo("marked omitted " .. defType .. "." .. name .. " in customparams.__def") + SpringShared.Echo("marked omitted " .. defType .. "." .. name .. " in customparams.__def") end diff --git a/gamedata/unitdefs.lua b/gamedata/unitdefs.lua index 1fad9203888..64e719152e0 100644 --- a/gamedata/unitdefs.lua +++ b/gamedata/unitdefs.lua @@ -44,22 +44,22 @@ end local luaFiles = VFS.DirList("units/", "*.lua", nil, true) -local legionEnabled = Spring.GetModOptions().experimentallegionfaction +local legionEnabled = SpringShared.GetModOptions().experimentallegionfaction local scavengersEnabled = Spring.Utilities.Gametype.IsScavengers() local raptorsEnabled = Spring.Utilities.Gametype.IsRaptors() -if Spring.GetModOptions().ruins == "enabled" then +if SpringShared.GetModOptions().ruins == "enabled" then legionEnabled = true scavengersEnabled = true elseif scavengersEnabled then legionEnabled = true end -if Spring.GetModOptions().experimentalextraunits or Spring.GetModOptions().scavunitsforplayers then +if SpringShared.GetModOptions().experimentalextraunits or SpringShared.GetModOptions().scavunitsforplayers then scavengersEnabled = true end -if Spring.GetModOptions().forceallunits then +if SpringShared.GetModOptions().forceallunits then raptorsEnabled = true scavengersEnabled = true legionEnabled = true @@ -78,15 +78,15 @@ for _, filename in ipairs(luaFiles) do setmetatable(unitDefsEnv, { __index = system }) local success, defs = pcall(VFS.Include, filename, unitDefsEnv, VFS_MODES) if not success then - Spring.Log(section, LOG.ERROR, "Error parsing " .. filename .. ": " .. tostring(defs)) + SpringShared.Log(section, LOG.ERROR, "Error parsing " .. filename .. ": " .. tostring(defs)) elseif type(defs) ~= "table" then - Spring.Log(section, LOG.ERROR, "Bad return table from: " .. filename) + SpringShared.Log(section, LOG.ERROR, "Bad return table from: " .. filename) else for unitDefName, unitDef in pairs(defs) do if (type(unitDefName) == "string") and (type(unitDef) == "table") then unitDefs[unitDefName] = unitDef else - Spring.Log(section, LOG.ERROR, "Bad return table entry from: " .. filename) + SpringShared.Log(section, LOG.ERROR, "Bad return table entry from: " .. filename) end end end @@ -117,12 +117,12 @@ for name, def in pairs(unitDefs) do local model = def.objectname if model == nil then unitDefs[name] = nil - Spring.Log(section, LOG.ERROR, "removed " .. name .. " unitDef, missing objectname param") + SpringShared.Log(section, LOG.ERROR, "removed " .. name .. " unitDef, missing objectname param") else local objfile = "objects3d/" .. model if not VFS.FileExists(objfile) then unitDefs[name] = nil - Spring.Log(section, LOG.ERROR, "removed " .. name .. " unitDef, missing model file (" .. model .. ")") + SpringShared.Log(section, LOG.ERROR, "removed " .. name .. " unitDef, missing model file (" .. model .. ")") end end end diff --git a/gamedata/unitdefs_post.lua b/gamedata/unitdefs_post.lua index 77f82c3488a..57475ae2bb4 100644 --- a/gamedata/unitdefs_post.lua +++ b/gamedata/unitdefs_post.lua @@ -5,17 +5,17 @@ VFS.Include("gamedata/post_save_to_customparams.lua") local system = VFS.Include("gamedata/system.lua") local scavengersEnabled = false -if Spring.GetTeamList then - local teamList = Spring.GetTeamList() +if SpringShared.GetTeamList then + local teamList = SpringShared.GetTeamList() for _, teamID in ipairs(teamList) do - local luaAI = Spring.GetTeamLuaAI(teamID) + local luaAI = SpringShared.GetTeamLuaAI(teamID) if luaAI and luaAI:find("Scavengers") then scavengersEnabled = true end end end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() if modOptions.ruins == "enabled" or modOptions.forceallunits == true or modOptions.zombies ~= "disabled" or (GG and GG.Zombies and GG.Zombies.IdleMode == true) then scavengersEnabled = true end @@ -249,37 +249,37 @@ local function preProcessTweakOptions() if decodeSuccess then local postfunc, err = loadstring(postsFuncStr) if err then - Spring.Echo("Error parsing modoption", name, "from string", postsFuncStr, "Error: " .. err) + SpringShared.Echo("Error parsing modoption", name, "from string", postsFuncStr, "Error: " .. err) else - Spring.Echo("Loading " .. name .. " modoption") - Spring.Echo(postsFuncStr) + SpringShared.Echo("Loading " .. name .. " modoption") + SpringShared.Echo(postsFuncStr) if postfunc then local success, result = pcall(postfunc) if success then shouldNormalizeUnitDefs = true -- tweakdefs can add or denormalize units else - Spring.Echo("Error executing tweakdef", name, postsFuncStr, "Error :" .. result) + SpringShared.Echo("Error executing tweakdef", name, postsFuncStr, "Error :" .. result) end end end else - Spring.Echo("Error parsing and decoding tweakdef", name, modOptions[name], "Error :" .. postsFuncStr) + SpringShared.Echo("Error parsing and decoding tweakdef", name, modOptions[name], "Error :" .. postsFuncStr) end else local success, tweakunits = pcall(Spring.Utilities.CustomKeyToUsefulTable, modOptions[name]) if success then if type(tweakunits) == "table" then - Spring.Echo("Loading " .. name .. " modoption") + SpringShared.Echo("Loading " .. name .. " modoption") for unitName, ud in pairs(UnitDefs) do if tweakunits[unitName] then - Spring.Echo("Loading tweakunits for " .. unitName) + SpringShared.Echo("Loading tweakunits for " .. unitName) table.mergeInPlace(ud, system.lowerkeys(tweakunits[unitName]), true) normalizeUnitDef(ud) -- tweakunits can set required tables to nil end end end else - Spring.Echo("Failed to parse modoption", name, "with value", modOptions[name]) + SpringShared.Echo("Failed to parse modoption", name, "with value", modOptions[name]) end end end diff --git a/gamedata/weapondefs.lua b/gamedata/weapondefs.lua index 9ef75457031..aa49b1fa376 100644 --- a/gamedata/weapondefs.lua +++ b/gamedata/weapondefs.lua @@ -53,9 +53,9 @@ for _, filename in ipairs(luaFiles) do setmetatable(weaponDefsEnv, { __index = system }) local success, defs = pcall(VFS.Include, filename, weaponDefsEnv, VFS_MODES) if not success then - Spring.Log(section, LOG.ERROR, "Error parsing " .. filename .. ": " .. tostring(defs)) + SpringShared.Log(section, LOG.ERROR, "Error parsing " .. filename .. ": " .. tostring(defs)) elseif defs == nil then - Spring.Log(section, LOG.ERROR, "Missing return table from: " .. filename) + SpringShared.Log(section, LOG.ERROR, "Missing return table from: " .. filename) else for weaponDefName, weaponDef in pairs(defs) do if (type(weaponDefName) == "string") and (type(weaponDef) == "table") then @@ -91,7 +91,7 @@ for name, def in pairs(weaponDefs) do local modelFile = "objects3d/" .. model if (not VFS.FileExists(modelFile)) and (not VFS.FileExists(modelFile .. ".s3o")) then weaponDefs[name] = nil - Spring.Log(section, LOG.ERROR, "removed " .. name .. " weaponDef, missing model") + SpringShared.Log(section, LOG.ERROR, "removed " .. name .. " weaponDef, missing model") end end end diff --git a/luaintro/Addons/engine_taskbar_control.lua b/luaintro/Addons/engine_taskbar_control.lua index a00fd7b9c7a..1654e16a638 100644 --- a/luaintro/Addons/engine_taskbar_control.lua +++ b/luaintro/Addons/engine_taskbar_control.lua @@ -12,6 +12,6 @@ function addon:GetInfo() end function addon:Initialize() - Spring.SetWMIcon("bitmaps/logo.png", true) - Spring.SetWMCaption(Game.gameName .. " (Spring " .. ((Game and Game.version) or (Engine and Engine.version) or "") .. ")", Game.modName) + SpringUnsynced.SetWMIcon("bitmaps/logo.png", true) + SpringUnsynced.SetWMCaption(Game.gameName .. " (Spring " .. ((Game and Game.version) or (Engine and Engine.version) or "") .. ")", Game.modName) end diff --git a/luaintro/Addons/main.lua b/luaintro/Addons/main.lua index 860deaf417f..c8d9a116d09 100644 --- a/luaintro/Addons/main.lua +++ b/luaintro/Addons/main.lua @@ -69,9 +69,9 @@ end local loadscreens = {} local loadscreenPath = "bitmaps/loadpictures/" -local teamList = Spring.GetTeamList() +local teamList = SpringShared.GetTeamList() for _, teamID in ipairs(teamList) do - local luaAI = Spring.GetTeamLuaAI(teamID) + local luaAI = SpringShared.GetTeamLuaAI(teamID) if luaAI then if luaAI:find("Raptors") then loadscreens = VFS.DirList(loadscreenPath .. "manual/raptors/") @@ -96,7 +96,7 @@ if math.random(1, 15) == 1 then backgroundTexture = "bitmaps/loadpictures/manual/donations.jpg" end -local showTips = (Spring.GetConfigInt("loadscreen_tips", 1) == 1) +local showTips = (SpringUnsynced.GetConfigInt("loadscreen_tips", 1) == 1) if string.find(backgroundTexture, "guide") then showTips = false end @@ -212,11 +212,11 @@ local blurtex2 local stenciltex local guishaderRects = {} local guishaderDlists = {} -local vsx, vsy, vpx, vpy = Spring.GetViewGeometry() +local vsx, vsy, vpx, vpy = SpringUnsynced.GetViewGeometry() local ivsx, ivsy = vsx, vsy -local wsx, wsy, _, _ = Spring.GetWindowGeometry() -local ssx, ssy, _, _ = Spring.GetScreenGeometry() +local wsx, wsy, _, _ = SpringUnsynced.GetWindowGeometry() +local ssx, ssy, _, _ = SpringUnsynced.GetScreenGeometry() if wsx > ssx or wsy > ssy then end @@ -232,16 +232,16 @@ function lines(str) end local defaultFont = "Poppins-Regular.otf" -local fontfile = "fonts/" .. Spring.GetConfigString("bar_font", defaultFont) +local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font", defaultFont) if not VFS.FileExists(fontfile) then - Spring.SetConfigString("bar_font", defaultFont) + SpringUnsynced.SetConfigString("bar_font", defaultFont) fontfile = "fonts/" .. defaultFont end local defaultFont2 = "Exo2-SemiBold.otf" -local fontfile2 = "fonts/" .. Spring.GetConfigString("bar_font2", defaultFont2) +local fontfile2 = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", defaultFont2) if not VFS.FileExists(fontfile2) then - Spring.SetConfigString("bar_font2", defaultFont2) + SpringUnsynced.SetConfigString("bar_font2", defaultFont2) fontfile2 = "fonts/" .. defaultFont2 end @@ -452,7 +452,7 @@ function addon.DrawLoadScreen() aspectRatio = texInfo.xsize / texInfo.ysize end - vsx, vsy, vpx, vpy = Spring.GetViewGeometry() + vsx, vsy, vpx, vpy = SpringUnsynced.GetViewGeometry() -- Handle viewport resize: recalculate layout and recreate shader resources if vsx ~= ivsx or vsy ~= ivsy then @@ -492,7 +492,7 @@ function addon.DrawLoadScreen() -- background local scale = 1 - local ssx, ssy, spx, spy = Spring.GetScreenGeometry() + local ssx, ssy, spx, spy = SpringUnsynced.GetScreenGeometry() if ssx / vsx < 1 then -- adjust when window is larger than the screen resolution --scale = ssx / vsx --xDiv = xDiv * scale -- this doesnt work @@ -608,7 +608,7 @@ function addon.DrawLoadScreen() loadProgress = math.clamp(loadProgress, lastProgress[1], lastProgress[2]) end - vsx, vsy, vpx, vpy = Spring.GetViewGeometry() + vsx, vsy, vpx, vpy = SpringUnsynced.GetViewGeometry() local loadvalue = math.max(0, loadProgress) * (1 - posX - posX) loadvalue = math.floor((loadvalue * vsx) + 0.5) / vsx diff --git a/luaintro/Addons/music.lua b/luaintro/Addons/music.lua index f4fc695b112..bd95dc3f442 100644 --- a/luaintro/Addons/music.lua +++ b/luaintro/Addons/music.lua @@ -29,8 +29,8 @@ function addon.Initialize() --if Spring.GetConfigInt('music', 1) == 0 then -- return --end - local originalSoundtrackEnabled = Spring.GetConfigInt("UseSoundtrackNew", 1) - local customSoundtrackEnabled = Spring.GetConfigInt("UseSoundtrackCustom", 1) + local originalSoundtrackEnabled = SpringUnsynced.GetConfigInt("UseSoundtrackNew", 1) + local customSoundtrackEnabled = SpringUnsynced.GetConfigInt("UseSoundtrackCustom", 1) local allowedExtensions = "{*.ogg,*.mp3}" local musicPlaylist = {} local musicPlaylistEvent = {} @@ -44,50 +44,50 @@ function addon.Initialize() -- Raptors if Spring.Utilities.Gametype.IsRaptors() then table.append(musicPlaylistEvent, VFS.DirList(musicDirOriginal .. "/events/raptors/loading", allowedExtensions)) - elseif Spring.GetConfigInt("UseSoundtrackRaptors", 0) == 1 then + elseif SpringUnsynced.GetConfigInt("UseSoundtrackRaptors", 0) == 1 then table.append(musicPlaylist, VFS.DirList(musicDirOriginal .. "/events/raptors/loading", allowedExtensions)) end -- Scavengers if Spring.Utilities.Gametype.IsScavengers() then table.append(musicPlaylistEvent, VFS.DirList(musicDirOriginal .. "/events/scavengers/loading", allowedExtensions)) - elseif Spring.GetConfigInt("UseSoundtrackScavengers", 0) == 1 then + elseif SpringUnsynced.GetConfigInt("UseSoundtrackScavengers", 0) == 1 then table.append(musicPlaylist, VFS.DirList(musicDirOriginal .. "/events/scavengers/loading", allowedExtensions)) end -- April Fools ---- Day 1 - 100% chance - if Spring.GetConfigInt("UseSoundtrackAprilFools", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools_specialDay"] then + if SpringUnsynced.GetConfigInt("UseSoundtrackAprilFools", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools_specialDay"] then table.append(musicPlaylistEvent, VFS.DirList(musicDirOriginal .. "/events/aprilfools/loading", allowedExtensions)) ---- Day 2-7 - 50% chance - elseif Spring.GetConfigInt("UseSoundtrackAprilFools", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools"] and math.random() <= 0.5 then + elseif SpringUnsynced.GetConfigInt("UseSoundtrackAprilFools", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools"] and math.random() <= 0.5 then table.append(musicPlaylistEvent, VFS.DirList(musicDirOriginal .. "/events/aprilfools/loading", allowedExtensions)) ---- Post Event - Add to regular playlist - elseif Spring.GetConfigInt("UseSoundtrackAprilFoolsPostEvent", 0) == 1 and not Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools"] then + elseif SpringUnsynced.GetConfigInt("UseSoundtrackAprilFoolsPostEvent", 0) == 1 and not Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools"] then table.append(musicPlaylist, VFS.DirList(musicDirOriginal .. "/events/aprilfools/loading", allowedExtensions)) end -- Halloween ---- Halloween Day - 100% chance - if Spring.GetConfigInt("UseSoundtrackHalloween", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["halloween_specialDay"] then + if SpringUnsynced.GetConfigInt("UseSoundtrackHalloween", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["halloween_specialDay"] then table.append(musicPlaylistEvent, VFS.DirList(musicDirOriginal .. "/events/halloween/loading", allowedExtensions)) ---- 2 Weeks Before Halloween - 50% chance - elseif Spring.GetConfigInt("UseSoundtrackHalloween", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["halloween"] and math.random() <= 0.5 then + elseif SpringUnsynced.GetConfigInt("UseSoundtrackHalloween", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["halloween"] and math.random() <= 0.5 then table.append(musicPlaylistEvent, VFS.DirList(musicDirOriginal .. "/events/halloween/loading", allowedExtensions)) ---- Post Event - Add to regular playlist - elseif Spring.GetConfigInt("UseSoundtrackHalloweenPostEvent", 0) == 1 and not Spring.Utilities.Gametype.GetCurrentHolidays()["halloween_specialDay"] then + elseif SpringUnsynced.GetConfigInt("UseSoundtrackHalloweenPostEvent", 0) == 1 and not Spring.Utilities.Gametype.GetCurrentHolidays()["halloween_specialDay"] then table.append(musicPlaylist, VFS.DirList(musicDirOriginal .. "/events/halloween/loading", allowedExtensions)) end -- Xmas ---- Christmas Days - 100% chance - if Spring.GetConfigInt("UseSoundtrackXmas", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["xmas_specialDay"] then + if SpringUnsynced.GetConfigInt("UseSoundtrackXmas", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["xmas_specialDay"] then table.append(musicPlaylistEvent, VFS.DirList(musicDirOriginal .. "/events/xmas/loading", allowedExtensions)) ---- The Rest of the event - 50% chance - elseif Spring.GetConfigInt("UseSoundtrackXmas", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["xmas"] and math.random() <= 0.5 then + elseif SpringUnsynced.GetConfigInt("UseSoundtrackXmas", 1) == 1 and Spring.Utilities.Gametype.GetCurrentHolidays()["xmas"] and math.random() <= 0.5 then table.append(musicPlaylistEvent, VFS.DirList(musicDirOriginal .. "/events/xmas/loading", allowedExtensions)) ---- Post Event - Add to regular playlist - elseif Spring.GetConfigInt("UseSoundtrackXmasPostEvent", 0) == 1 and not Spring.Utilities.Gametype.GetCurrentHolidays()["xmas"] then + elseif SpringUnsynced.GetConfigInt("UseSoundtrackXmasPostEvent", 0) == 1 and not Spring.Utilities.Gametype.GetCurrentHolidays()["xmas"] then table.append(musicPlaylist, VFS.DirList(musicDirOriginal .. "/events/xmas/loading", allowedExtensions)) end @@ -114,16 +114,16 @@ function addon.Initialize() end end - local musicvolume = Spring.GetConfigInt("snd_volmusic", 50) * 0.01 + local musicvolume = SpringUnsynced.GetConfigInt("snd_volmusic", 50) * 0.01 if #musicPlaylistEvent > 0 then local pickedTrack = musicPlaylistEvent[math.random(1, #musicPlaylistEvent)] - Spring.PlaySoundStream(pickedTrack, 1) - Spring.SetSoundStreamVolume(musicvolume) - Spring.SetConfigString("music_loadscreen_track", pickedTrack) + SpringUnsynced.PlaySoundStream(pickedTrack, 1) + SpringUnsynced.SetSoundStreamVolume(musicvolume) + SpringUnsynced.SetConfigString("music_loadscreen_track", pickedTrack) elseif #musicPlaylist > 0 then local pickedTrack = musicPlaylist[math.random(1, #musicPlaylist)] - Spring.PlaySoundStream(pickedTrack, 1) - Spring.SetSoundStreamVolume(musicvolume) - Spring.SetConfigString("music_loadscreen_track", pickedTrack) + SpringUnsynced.PlaySoundStream(pickedTrack, 1) + SpringUnsynced.SetSoundStreamVolume(musicvolume) + SpringUnsynced.SetConfigString("music_loadscreen_track", pickedTrack) end end diff --git a/luaintro/config.lua b/luaintro/config.lua index eac3f59fbbf..eb9e8ac6618 100644 --- a/luaintro/config.lua +++ b/luaintro/config.lua @@ -41,7 +41,7 @@ if LUA_NAME == "LuaUI" then } --// Create the "LuaUI/Config" directory - Spring.CreateDir(LUAUI_DIRNAME .. "Config") + SpringUnsynced.CreateDir(LUAUI_DIRNAME .. "Config") handler:Load(LUAUI_DIRNAME .. "SystemWidgets/BlockUserWidgets.lua" --[[, VFS.ZIP]]) else diff --git a/luaintro/main.lua b/luaintro/main.lua index 4a76f8f7db7..2ba0371c2e5 100644 --- a/luaintro/main.lua +++ b/luaintro/main.lua @@ -27,15 +27,15 @@ VFS.DEF_MODE = VFS.RAW_FIRST -- Initialize the Lua LogSection (else messages with level "info" wouldn't been shown) -- -if Spring.SetLogSectionFilterLevel then - Spring.SetLogSectionFilterLevel(LUA_NAME, "info") +if SpringUnsynced.SetLogSectionFilterLevel then + SpringUnsynced.SetLogSectionFilterLevel(LUA_NAME, "info") else -- backward compability - local origSpringLog = Spring.Log + local origSpringLog = SpringShared.Log - Spring.Log = function(name, level, ...) + SpringShared.Log = function(name, level, ...) if (type(level) == "string") and (level == "info") then - Spring.Echo(("[%s]"):format(name), ...) + SpringShared.Echo(("[%s]"):format(name), ...) else origSpringLog(name, level, ...) end @@ -54,7 +54,7 @@ VFS.Include("LuaHandler/Utilities/utils.lua", nil, VFS.DEF_MODE) include("LuaHandler/handler.lua") --// print Lua & LuaUI version -Spring.Log(LUA_NAME, "info", LUA_VERSION .. " (" .. _VERSION .. ")") +SpringShared.Log(LUA_NAME, "info", LUA_VERSION .. " (" .. _VERSION .. ")") ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- diff --git a/luaintro/springconfig.lua b/luaintro/springconfig.lua index d2ea9f0896a..6dc70786677 100644 --- a/luaintro/springconfig.lua +++ b/luaintro/springconfig.lua @@ -2,186 +2,186 @@ --- set some spring settings before the game/engine is really loaded yet -------------------------------------------------------------------------------------------- -Spring.SetConfigString("SplashScreenDir", "./MenuLoadscreens") +SpringUnsynced.SetConfigString("SplashScreenDir", "./MenuLoadscreens") -- ghost icons dimming, override engine default but allow user setting -if Spring.GetConfigFloat("UnitGhostIconsDimming", 0.5) == 0.5 then - Spring.SetConfigFloat("UnitGhostIconsDimming", 0.75) +if SpringUnsynced.GetConfigFloat("UnitGhostIconsDimming", 0.5) == 0.5 then + SpringUnsynced.SetConfigFloat("UnitGhostIconsDimming", 0.75) end -- set default unit rendering vars -Spring.SetConfigFloat("tonemapA", 4.75) -Spring.SetConfigFloat("tonemapB", 0.75) -Spring.SetConfigFloat("tonemapC", 3.5) -Spring.SetConfigFloat("tonemapD", 0.85) -Spring.SetConfigFloat("tonemapE", 1.0) -Spring.SetConfigFloat("envAmbient", 0.25) -Spring.SetConfigFloat("unitSunMult", 1.0) -Spring.SetConfigFloat("unitExposureMult", 1.0) -Spring.SetConfigFloat("modelGamma", 1.0) +SpringUnsynced.SetConfigFloat("tonemapA", 4.75) +SpringUnsynced.SetConfigFloat("tonemapB", 0.75) +SpringUnsynced.SetConfigFloat("tonemapC", 3.5) +SpringUnsynced.SetConfigFloat("tonemapD", 0.85) +SpringUnsynced.SetConfigFloat("tonemapE", 1.0) +SpringUnsynced.SetConfigFloat("envAmbient", 0.25) +SpringUnsynced.SetConfigFloat("unitSunMult", 1.0) +SpringUnsynced.SetConfigFloat("unitExposureMult", 1.0) +SpringUnsynced.SetConfigFloat("modelGamma", 1.0) -- BAR requires higher textureatlas size for particles than the default of 2048x2048 local maxTextureAtlasSize = 8192 -Spring.SetConfigInt("MaxTextureAtlasSizeX", maxTextureAtlasSize) -Spring.SetConfigInt("MaxTextureAtlasSizeY", maxTextureAtlasSize) -if tonumber(Spring.GetConfigInt("MaxTextureAtlasSizeX", 2048) or 2048) < maxTextureAtlasSize then - Spring.SetConfigInt("MaxTextureAtlasSizeX", maxTextureAtlasSize) - Spring.SetConfigInt("MaxTextureAtlasSizeY", maxTextureAtlasSize) +SpringUnsynced.SetConfigInt("MaxTextureAtlasSizeX", maxTextureAtlasSize) +SpringUnsynced.SetConfigInt("MaxTextureAtlasSizeY", maxTextureAtlasSize) +if tonumber(SpringUnsynced.GetConfigInt("MaxTextureAtlasSizeX", 2048) or 2048) < maxTextureAtlasSize then + SpringUnsynced.SetConfigInt("MaxTextureAtlasSizeX", maxTextureAtlasSize) + SpringUnsynced.SetConfigInt("MaxTextureAtlasSizeY", maxTextureAtlasSize) end -- Sets necessary spring configuration parameters, so shaded units look the way they should (pbr gadget also does this) -Spring.SetConfigInt("CubeTexGenerateMipMaps", 1) -Spring.SetConfigInt("CubeTexSizeReflection", 1024) +SpringUnsynced.SetConfigInt("CubeTexGenerateMipMaps", 1) +SpringUnsynced.SetConfigInt("CubeTexSizeReflection", 1024) -Spring.SetConfigInt("AdvSky", 0) +SpringUnsynced.SetConfigInt("AdvSky", 0) -- disable grass -Spring.SetConfigInt("GrassDetail", 0) +SpringUnsynced.SetConfigInt("GrassDetail", 0) -- adv map shading --Spring.SetConfigInt("AdvMapShading", 1) -- make sure default/minimum ui opacity is set -if Spring.GetConfigFloat("ui_opacity", 0.6) < 0.3 then - Spring.SetConfigFloat("ui_opacity", 0.6) +if SpringUnsynced.GetConfigFloat("ui_opacity", 0.6) < 0.3 then + SpringUnsynced.SetConfigFloat("ui_opacity", 0.6) end -- set default bg tile settings -if Spring.GetConfigFloat("ui_tileopacity", 0.011) < 0 then - Spring.SetConfigFloat("ui_tileopacity", 0.011) +if SpringUnsynced.GetConfigFloat("ui_tileopacity", 0.011) < 0 then + SpringUnsynced.SetConfigFloat("ui_tileopacity", 0.011) end -if Spring.GetConfigFloat("ui_tilescale", 7) < 0 then - Spring.SetConfigFloat("ui_tilescale", 7) +if SpringUnsynced.GetConfigFloat("ui_tilescale", 7) < 0 then + SpringUnsynced.SetConfigFloat("ui_tilescale", 7) end -- disable ForceDisableShaders -if Spring.GetConfigInt("ForceDisableShaders", 0) == 1 then - Spring.SetConfigInt("ForceDisableShaders", 0) +if SpringUnsynced.GetConfigInt("ForceDisableShaders", 0) == 1 then + SpringUnsynced.SetConfigInt("ForceDisableShaders", 0) end -- enable lua shaders -if not tonumber(Spring.GetConfigInt("LuaShaders", 0) or 0) then - Spring.SetConfigInt("LuaShaders", 1) +if not tonumber(SpringUnsynced.GetConfigInt("LuaShaders", 0) or 0) then + SpringUnsynced.SetConfigInt("LuaShaders", 1) end -- Disable dynamic model lights -Spring.SetConfigInt("MaxDynamicModelLights", 0) +SpringUnsynced.SetConfigInt("MaxDynamicModelLights", 0) -- Enable deferred map/model rendering -Spring.SetConfigInt("AllowDeferredMapRendering", 1) -Spring.SetConfigInt("AllowDeferredModelRendering", 1) +SpringUnsynced.SetConfigInt("AllowDeferredMapRendering", 1) +SpringUnsynced.SetConfigInt("AllowDeferredModelRendering", 1) -- Enables the DrawGroundDeferred event, which is needed for deferred map edge rendering -Spring.SetConfigInt("AllowDrawMapDeferredEvents", 1) +SpringUnsynced.SetConfigInt("AllowDrawMapDeferredEvents", 1) -- Disable LoadingMT because: crashes on load, but fixed in 105.1.1-1422, redisable in 105.1.1-1432 --Spring.SetConfigInt("LoadingMT", 0) -- Chobby had this set to 100 before and it introduced latency of 4ms a sim-frame, having a 10%-15% penalty compared it the default -- This was set to 2 as of 2022.08.16, Beherith reduced it to 1 for even less GC probability -Spring.SetConfigInt("LuaGarbageCollectionMemLoadMult", 1) +SpringUnsynced.SetConfigInt("LuaGarbageCollectionMemLoadMult", 1) -- Reduce the max runtime of GC to 1 ms instead of 5 (2022.08.16) -Spring.SetConfigInt("LuaGarbageCollectionRunTimeMult", 1) +SpringUnsynced.SetConfigInt("LuaGarbageCollectionRunTimeMult", 1) -- we used 3 as default toggle, changing to 4 -if (Spring.GetConfigInt("GroundDecals", 3) or 3) >= 4 then - Spring.SetConfigInt("GroundDecals", 3) +if (SpringUnsynced.GetConfigInt("GroundDecals", 3) or 3) >= 4 then + SpringUnsynced.SetConfigInt("GroundDecals", 3) end -- ground mesh detail -Spring.SetConfigInt("ROAM", 1) -if tonumber(Spring.GetConfigInt("GroundDetail", 1) or 1) < 200 then - Spring.SetConfigInt("GroundDetail", 200) +SpringUnsynced.SetConfigInt("ROAM", 1) +if tonumber(SpringUnsynced.GetConfigInt("GroundDetail", 1) or 1) < 200 then + SpringUnsynced.SetConfigInt("GroundDetail", 200) end -- This makes between-simframe interpolation smoother in mid-late game situations -Spring.SetConfigInt("SmoothTimeOffset", 2) -- New in BAR engine +SpringUnsynced.SetConfigInt("SmoothTimeOffset", 2) -- New in BAR engine -- This is needed for better profiling info, and (theoretically better frame timing). -- Notably a decade ago windows had issues with this -Spring.SetConfigInt("UseHighResTimer", 1) -- Default off +SpringUnsynced.SetConfigInt("UseHighResTimer", 1) -- Default off -- This changes the sleep time of the game server thread to make it wake up every 1.999 ms instead of the default 5.999 ms -- This hopefully gets us less variance in issuing new sim frames -Spring.SetConfigInt("ServerSleepTime", 1) +SpringUnsynced.SetConfigInt("ServerSleepTime", 1) -- The default of 256 is just too tiny, at this size the VS load outpaces FS load anyway, makes for actually pretty reflections with CUS GL4 -Spring.SetConfigInt("BumpWaterTexSizeReflection", 1024) +SpringUnsynced.SetConfigInt("BumpWaterTexSizeReflection", 1024) -Spring.SetConfigFloat("CrossAlpha", 0) -- will be in effect next launch +SpringUnsynced.SetConfigFloat("CrossAlpha", 0) -- will be in effect next launch -if not Spring.GetConfigFloat("UnitIconFadeAmount") then - Spring.SetConfigFloat("UnitIconFadeAmount", 0.1) +if not SpringUnsynced.GetConfigFloat("UnitIconFadeAmount") then + SpringUnsynced.SetConfigFloat("UnitIconFadeAmount", 0.1) end -- equalize -Spring.SetConfigInt("UnitIconFadeVanish", Spring.GetConfigInt("UnitIconFadeStart", 3000)) +SpringUnsynced.SetConfigInt("UnitIconFadeVanish", SpringUnsynced.GetConfigInt("UnitIconFadeStart", 3000)) -- change some default value(s), upp the version and set what needs to be set local version = 3 -if Spring.GetConfigInt("version", 0) < version then - Spring.SetConfigInt("version", version) +if SpringUnsynced.GetConfigInt("version", 0) < version then + SpringUnsynced.SetConfigInt("version", version) -- set icon settings - Spring.SetConfigInt("UnitIconsAsUI", 1) - Spring.SetConfigFloat("UnitIconScaleUI", 1.05) - Spring.SetConfigInt("UnitIconFadeVanish", 3000) - Spring.SetConfigInt("UnitIconFadeStart", 3000) - Spring.SetConfigInt("UnitIconsHideWithUI", 1) - - if Spring.GetConfigInt("UnitIconFadeVanish", 2700) < 2700 then - Spring.SetConfigInt("UnitIconFadeVanish", 2700) + SpringUnsynced.SetConfigInt("UnitIconsAsUI", 1) + SpringUnsynced.SetConfigFloat("UnitIconScaleUI", 1.05) + SpringUnsynced.SetConfigInt("UnitIconFadeVanish", 3000) + SpringUnsynced.SetConfigInt("UnitIconFadeStart", 3000) + SpringUnsynced.SetConfigInt("UnitIconsHideWithUI", 1) + + if SpringUnsynced.GetConfigInt("UnitIconFadeVanish", 2700) < 2700 then + SpringUnsynced.SetConfigInt("UnitIconFadeVanish", 2700) end - if Spring.GetConfigInt("UnitIconFadeStart", 3000) < 3000 then - Spring.SetConfigInt("UnitIconFadeVanish", 3000) + if SpringUnsynced.GetConfigInt("UnitIconFadeStart", 3000) < 3000 then + SpringUnsynced.SetConfigInt("UnitIconFadeVanish", 3000) end - Spring.SetConfigInt("VSyncGame", -1) - Spring.SetConfigInt("CamMode", 3) + SpringUnsynced.SetConfigInt("VSyncGame", -1) + SpringUnsynced.SetConfigInt("CamMode", 3) end version = 4 -if Spring.GetConfigInt("version", 0) < version then - Spring.SetConfigInt("version", version) +if SpringUnsynced.GetConfigInt("version", 0) < version then + SpringUnsynced.SetConfigInt("version", version) - if Spring.GetConfigFloat("ui_scale", 1) == 1 then - Spring.SetConfigFloat("ui_scale", 0.94) + if SpringUnsynced.GetConfigFloat("ui_scale", 1) == 1 then + SpringUnsynced.SetConfigFloat("ui_scale", 0.94) end end version = 5 -if Spring.GetConfigInt("version", 0) < version then - Spring.SetConfigInt("version", version) +if SpringUnsynced.GetConfigInt("version", 0) < version then + SpringUnsynced.SetConfigInt("version", version) - Spring.SetConfigInt("CamSpringMinZoomDistance", 300) - Spring.SetConfigInt("OverheadMinZoomDistance", 300) + SpringUnsynced.SetConfigInt("CamSpringMinZoomDistance", 300) + SpringUnsynced.SetConfigInt("OverheadMinZoomDistance", 300) end version = 8 -if Spring.GetConfigInt("version", 0) < version then - Spring.SetConfigInt("version", version) +if SpringUnsynced.GetConfigInt("version", 0) < version then + SpringUnsynced.SetConfigInt("version", version) - local voiceset = Spring.GetConfigString("voiceset", "") + local voiceset = SpringUnsynced.GetConfigString("voiceset", "") if voiceset == "en/allison" then - Spring.SetConfigString("voiceset", "en/cephis") + SpringUnsynced.SetConfigString("voiceset", "en/cephis") end end -- apply the old pre-engine implementation stored camera minimum zoom level -local oldMinCamHeight = Spring.GetConfigInt("MinimumCameraHeight", -1) +local oldMinCamHeight = SpringUnsynced.GetConfigInt("MinimumCameraHeight", -1) if oldMinCamHeight ~= -1 then - Spring.SetConfigInt("MinimumCameraHeight", -1) - Spring.SetConfigInt("CamSpringMinZoomDistance", oldMinCamHeight) - Spring.SetConfigInt("OverheadMinZoomDistance", oldMinCamHeight) + SpringUnsynced.SetConfigInt("MinimumCameraHeight", -1) + SpringUnsynced.SetConfigInt("CamSpringMinZoomDistance", oldMinCamHeight) + SpringUnsynced.SetConfigInt("OverheadMinZoomDistance", oldMinCamHeight) end -- in case we forget to save it once again -Spring.SetConfigInt("version", version) +SpringUnsynced.SetConfigInt("version", version) -Spring.SetConfigInt("VSync", Spring.GetConfigInt("VSyncGame", -1)) +SpringUnsynced.SetConfigInt("VSync", SpringUnsynced.GetConfigInt("VSyncGame", -1)) -- Configure sane keychain settings, this is to provide a standard experience -- for users that is acceptable local springKeyChainTimeout = 750 -- expected engine default in ms local barKeyChainTimeout = 333 -- the setting we want to apply in ms -local userKeyChainTimeout = Spring.GetConfigInt("KeyChainTimeout") +local userKeyChainTimeout = SpringUnsynced.GetConfigInt("KeyChainTimeout") -- Apply BAR's default if current setting is equal to engine default OR BAR's default -- Reason is engine is unable to distinguish between: @@ -191,28 +191,28 @@ if userKeyChainTimeout == springKeyChainTimeout or userKeyChainTimeout == barKey -- Setting a standardized keychain timeout, 750ms is too long -- A side benefit of making it smaller is reduced complexity of actions handling -- since there are fewer complex and long chains between keystrokes - Spring.SetConfigInt("KeyChainTimeout", barKeyChainTimeout) + SpringUnsynced.SetConfigInt("KeyChainTimeout", barKeyChainTimeout) else -- If user has configured a custom KeyChainTimeout, restore this setting - Spring.SetConfigInt("KeyChainTimeout", userKeyChainTimeout) + SpringUnsynced.SetConfigInt("KeyChainTimeout", userKeyChainTimeout) end -- The default mouse drag threshold is set extremely low for engine by default, and fast clicking often results in a drag. -- This is bad for single unit commands, which turn into empty area commmands as a result of the small drag -local xresolution = math.max(Spring.GetConfigInt("XResolution", 1920), Spring.GetConfigInt("XResolutionWindowed", 1920)) -local yresolution = math.max(Spring.GetConfigInt("YResolution", 1080), Spring.GetConfigInt("YResolutionWindowed", 1080)) +local xresolution = math.max(SpringUnsynced.GetConfigInt("XResolution", 1920), SpringUnsynced.GetConfigInt("XResolutionWindowed", 1920)) +local yresolution = math.max(SpringUnsynced.GetConfigInt("YResolution", 1080), SpringUnsynced.GetConfigInt("YResolutionWindowed", 1080)) local baseDragThreshold = 16 baseDragThreshold = math.round(baseDragThreshold * (xresolution + yresolution) * (1 / 3000)) -- is 16 at 1080p baseDragThreshold = math.clamp(baseDragThreshold, 8, 40) -Spring.Echo(string.format("Setting Mouse Drag thresholds based on resolution (%dx%d) for Selection to %d, and Command to %d", xresolution, yresolution, baseDragThreshold, baseDragThreshold + 16)) -Spring.SetConfigInt("MouseDragSelectionThreshold", baseDragThreshold) -Spring.SetConfigInt("MouseDragCircleCommandThreshold", baseDragThreshold + 16) -Spring.SetConfigInt("MouseDragBoxCommandThreshold", baseDragThreshold + 16) -Spring.SetConfigInt("MouseDragFrontCommandThreshold", baseDragThreshold + 16) - -Spring.SetConfigInt("MaxFontTries", 5) -Spring.SetConfigInt("UseFontConfigLib", 1) +SpringShared.Echo(string.format("Setting Mouse Drag thresholds based on resolution (%dx%d) for Selection to %d, and Command to %d", xresolution, yresolution, baseDragThreshold, baseDragThreshold + 16)) +SpringUnsynced.SetConfigInt("MouseDragSelectionThreshold", baseDragThreshold) +SpringUnsynced.SetConfigInt("MouseDragCircleCommandThreshold", baseDragThreshold + 16) +SpringUnsynced.SetConfigInt("MouseDragBoxCommandThreshold", baseDragThreshold + 16) +SpringUnsynced.SetConfigInt("MouseDragFrontCommandThreshold", baseDragThreshold + 16) + +SpringUnsynced.SetConfigInt("MaxFontTries", 5) +SpringUnsynced.SetConfigInt("UseFontConfigLib", 1) --local language = Spring.GetConfigString("language", 'en') --if language ~= 'en' and language ~= 'fr' then diff --git a/luarules/Utilities/damgam_lib/nearby_capture.lua b/luarules/Utilities/damgam_lib/nearby_capture.lua index a9bc10aa52e..52056557cda 100644 --- a/luarules/Utilities/damgam_lib/nearby_capture.lua +++ b/luarules/Utilities/damgam_lib/nearby_capture.lua @@ -1,23 +1,23 @@ -- To be done -local GaiaTeamID = Spring.GetGaiaTeamID() -local GaiaAllyTeamID = select(6, Spring.GetTeamInfo(GaiaTeamID)) +local GaiaTeamID = SpringShared.GetGaiaTeamID() +local GaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(GaiaTeamID)) local function NearbyCapture(unitID, difficulty, range) difficulty = difficulty or 1 range = range or 256 - local unitAllyTeam = Spring.GetUnitAllyTeam(unitID) + local unitAllyTeam = SpringShared.GetUnitAllyTeam(unitID) - local x, y, z = Spring.GetUnitPosition(unitID) - local nearbyUnits = Spring.GetUnitsInCylinder(x, z, range) + local x, y, z = SpringShared.GetUnitPosition(unitID) + local nearbyUnits = SpringShared.GetUnitsInCylinder(x, z, range) local captureDamage = 0 for i = 1, #nearbyUnits do local attackerID = nearbyUnits[i] if attackerID ~= unitID then - if not Spring.GetUnitIsBeingBuilt(unitID) then - local attackerAllyTeamID = Spring.GetUnitAllyTeam(attackerID) - local attackerDefID = Spring.GetUnitDefID(attackerID) + if not SpringShared.GetUnitIsBeingBuilt(unitID) then + local attackerAllyTeamID = SpringShared.GetUnitAllyTeam(attackerID) + local attackerDefID = SpringShared.GetUnitDefID(attackerID) local attackerMetalCost = UnitDefs[attackerDefID].metalCost local capturePower = ((attackerMetalCost / 1000) * 0.01) / difficulty if attackerAllyTeamID == unitAllyTeam then @@ -30,23 +30,23 @@ local function NearbyCapture(unitID, difficulty, range) end if captureDamage ~= 0 then - local captureProgress = select(4, Spring.GetUnitHealth(unitID)) + local captureProgress = select(4, SpringShared.GetUnitHealth(unitID)) local newProgress = captureProgress + captureDamage if newProgress < 0 then - Spring.SetUnitHealth(unitID, { capture = 0 }) + SpringSynced.SetUnitHealth(unitID, { capture = 0 }) SendToUnsynced("unitCaptureFrame", unitID, 0) GG.addUnitToCaptureDecay(unitID) elseif newProgress >= 1 then - local nearestAttacker = Spring.GetUnitNearestEnemy(unitID, range * 2, false) + local nearestAttacker = SpringShared.GetUnitNearestEnemy(unitID, range * 2, false) if nearestAttacker then - local attackerTeamID = Spring.GetUnitTeam(nearestAttacker) - Spring.TransferUnit(unitID, attackerTeamID, false) - Spring.SetUnitHealth(unitID, { capture = 0.75 }) + local attackerTeamID = SpringShared.GetUnitTeam(nearestAttacker) + SpringSynced.TransferUnit(unitID, attackerTeamID, false) + SpringSynced.SetUnitHealth(unitID, { capture = 0.75 }) SendToUnsynced("unitCaptureFrame", unitID, 0.75) GG.addUnitToCaptureDecay(unitID) end else - Spring.SetUnitHealth(unitID, { capture = newProgress }) + SpringSynced.SetUnitHealth(unitID, { capture = newProgress }) SendToUnsynced("unitCaptureFrame", unitID, newProgress) GG.addUnitToCaptureDecay(unitID) end diff --git a/luarules/Utilities/damgam_lib/position_checks.lua b/luarules/Utilities/damgam_lib/position_checks.lua index ac63def00c4..9e3d166bf2a 100644 --- a/luarules/Utilities/damgam_lib/position_checks.lua +++ b/luarules/Utilities/damgam_lib/position_checks.lua @@ -4,13 +4,13 @@ -- Fog of War check needed for some functions local noFogOfWar = false -if Spring.GetModOptions().disable_fogofwar then +if SpringShared.GetModOptions().disable_fogofwar then noFogOfWar = true end -- GaiaTeamID and GaiaAllyTeamID -local GaiaTeamID = Spring.GetGaiaTeamID() -local GaiaAllyTeamID = select(6, Spring.GetTeamInfo(GaiaTeamID)) +local GaiaTeamID = SpringShared.GetGaiaTeamID() +local GaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(GaiaTeamID)) -- Map size local mapSizeX = Game.mapSizeX @@ -22,9 +22,9 @@ local scavengerAllyTeamID = Spring.Utilities.GetScavAllyTeamID() -- Team Startboxes local AllyTeamStartboxes = {} -for _, testAllyTeamID in ipairs(Spring.GetAllyTeamList()) do +for _, testAllyTeamID in ipairs(SpringShared.GetAllyTeamList()) do local allyTeamHasStartbox = true - local xMin, zMin, xMax, zMax = Spring.GetAllyTeamStartBox(testAllyTeamID) + local xMin, zMin, xMax, zMax = SpringShared.GetAllyTeamStartBox(testAllyTeamID) if xMin == 0 and zMin == 0 and xMax == mapSizeX and zMax == mapSizeZ then allyTeamHasStartbox = false end @@ -46,7 +46,7 @@ local function FlatAreaCheck(posx, posy, posz, posradius, heightTollerance, chec posradius = posradius or 1000 heightTollerance = heightTollerance or 30 local deathwater = Game.waterDamage - local lavaLevel = Spring.GetGameRulesParam("lavaLevel") + local lavaLevel = SpringShared.GetGameRulesParam("lavaLevel") -- Pre-compute coordinate offsets local xPlus = posx + posradius @@ -55,14 +55,14 @@ local function FlatAreaCheck(posx, posy, posz, posradius, heightTollerance, chec local zMinus = posz - posradius -- Check height of test points in all 8 directions. - local testpos1 = Spring.GetGroundHeight(xPlus, zPlus) - local testpos2 = Spring.GetGroundHeight(xPlus, zMinus) - local testpos3 = Spring.GetGroundHeight(xMinus, zPlus) - local testpos4 = Spring.GetGroundHeight(xMinus, zMinus) - local testpos5 = Spring.GetGroundHeight(xPlus, posz) - local testpos6 = Spring.GetGroundHeight(posx, zPlus) - local testpos7 = Spring.GetGroundHeight(xMinus, posz) - local testpos8 = Spring.GetGroundHeight(posx, zMinus) + local testpos1 = SpringShared.GetGroundHeight(xPlus, zPlus) + local testpos2 = SpringShared.GetGroundHeight(xPlus, zMinus) + local testpos3 = SpringShared.GetGroundHeight(xMinus, zPlus) + local testpos4 = SpringShared.GetGroundHeight(xMinus, zMinus) + local testpos5 = SpringShared.GetGroundHeight(xPlus, posz) + local testpos6 = SpringShared.GetGroundHeight(posx, zPlus) + local testpos7 = SpringShared.GetGroundHeight(xMinus, posz) + local testpos8 = SpringShared.GetGroundHeight(posx, zMinus) -- Compare with original height if (not checkWater) and (not deathwater or deathwater == 0) and posy <= 0 then @@ -108,7 +108,7 @@ end local function LandOrSeaCheck(posx, posy, posz, posradius) -- returns string, "land", "sea", "mixed", "death" posradius = posradius or 1000 local deathwater = Game.waterDamage - local lavaLevel = Spring.GetGameRulesParam("lavaLevel") + local lavaLevel = SpringShared.GetGameRulesParam("lavaLevel") -- Pre-compute coordinate offsets local xPlus = posx + posradius @@ -117,14 +117,14 @@ local function LandOrSeaCheck(posx, posy, posz, posradius) -- returns string, "l local zMinus = posz - posradius -- Check height of test points in all 8 directions. - local testpos1 = Spring.GetGroundHeight(xPlus, zPlus) - local testpos2 = Spring.GetGroundHeight(xPlus, zMinus) - local testpos3 = Spring.GetGroundHeight(xMinus, zPlus) - local testpos4 = Spring.GetGroundHeight(xMinus, zMinus) - local testpos5 = Spring.GetGroundHeight(xPlus, posz) - local testpos6 = Spring.GetGroundHeight(posx, zPlus) - local testpos7 = Spring.GetGroundHeight(xMinus, posz) - local testpos8 = Spring.GetGroundHeight(posx, zMinus) + local testpos1 = SpringShared.GetGroundHeight(xPlus, zPlus) + local testpos2 = SpringShared.GetGroundHeight(xPlus, zMinus) + local testpos3 = SpringShared.GetGroundHeight(xMinus, zPlus) + local testpos4 = SpringShared.GetGroundHeight(xMinus, zMinus) + local testpos5 = SpringShared.GetGroundHeight(xPlus, posz) + local testpos6 = SpringShared.GetGroundHeight(posx, zPlus) + local testpos7 = SpringShared.GetGroundHeight(xMinus, posz) + local testpos8 = SpringShared.GetGroundHeight(posx, zMinus) local minimumheight = math.min(testpos1, testpos2, testpos3, testpos4, testpos5, testpos6, testpos7, testpos8) local maximumheight = math.max(testpos1, testpos2, testpos3, testpos4, testpos5, testpos6, testpos7, testpos8) @@ -148,7 +148,7 @@ end local function OccupancyCheck(posx, posy, posz, posradius) -- Returns true if there are no units in the spawn area local posradius = posradius or 1000 - local unitcount = #Spring.GetUnitsInRectangle(posx - posradius, posz - posradius, posx + posradius, posz + posradius) + local unitcount = #SpringShared.GetUnitsInRectangle(posx - posradius, posz - posradius, posx + posradius, posz + posradius) if unitcount > 0 then return false else @@ -191,15 +191,15 @@ local function VisibilityCheck(posx, posy, posz, posradius, allyTeamID, checkLoS local zPlus = posz + posradius local zMinus = posz - posradius - if checkLoS and (Spring.IsPosInLos(posx, posy, posz, allyTeamID) == true or Spring.IsPosInLos(xPlus, posy, zPlus, allyTeamID) == true or Spring.IsPosInLos(xPlus, posy, zMinus, allyTeamID) == true or Spring.IsPosInLos(xMinus, posy, zPlus, allyTeamID) == true or Spring.IsPosInLos(xMinus, posy, zMinus, allyTeamID) == true) then + if checkLoS and (SpringShared.IsPosInLos(posx, posy, posz, allyTeamID) == true or SpringShared.IsPosInLos(xPlus, posy, zPlus, allyTeamID) == true or SpringShared.IsPosInLos(xPlus, posy, zMinus, allyTeamID) == true or SpringShared.IsPosInLos(xMinus, posy, zPlus, allyTeamID) == true or SpringShared.IsPosInLos(xMinus, posy, zMinus, allyTeamID) == true) then return false end - if checkRadar and (Spring.IsPosInRadar(posx, posy, posz, allyTeamID) == true or Spring.IsPosInRadar(xPlus, posy, zPlus, allyTeamID) == true or Spring.IsPosInRadar(xPlus, posy, zMinus, allyTeamID) == true or Spring.IsPosInRadar(xMinus, posy, zPlus, allyTeamID) == true or Spring.IsPosInRadar(xMinus, posy, zMinus, allyTeamID) == true) then + if checkRadar and (SpringShared.IsPosInRadar(posx, posy, posz, allyTeamID) == true or SpringShared.IsPosInRadar(xPlus, posy, zPlus, allyTeamID) == true or SpringShared.IsPosInRadar(xPlus, posy, zMinus, allyTeamID) == true or SpringShared.IsPosInRadar(xMinus, posy, zPlus, allyTeamID) == true or SpringShared.IsPosInRadar(xMinus, posy, zMinus, allyTeamID) == true) then return false end - if checkAirLos and (Spring.IsPosInAirLos(posx, posy, posz, allyTeamID) == true or Spring.IsPosInAirLos(xPlus, posy, zPlus, allyTeamID) == true or Spring.IsPosInAirLos(xPlus, posy, zMinus, allyTeamID) == true or Spring.IsPosInAirLos(xMinus, posy, zPlus, allyTeamID) == true or Spring.IsPosInAirLos(xMinus, posy, zMinus, allyTeamID) == true) then + if checkAirLos and (SpringShared.IsPosInAirLos(posx, posy, posz, allyTeamID) == true or SpringShared.IsPosInAirLos(xPlus, posy, zPlus, allyTeamID) == true or SpringShared.IsPosInAirLos(xPlus, posy, zMinus, allyTeamID) == true or SpringShared.IsPosInAirLos(xMinus, posy, zPlus, allyTeamID) == true or SpringShared.IsPosInAirLos(xMinus, posy, zMinus, allyTeamID) == true) then return false end @@ -207,7 +207,7 @@ local function VisibilityCheck(posx, posy, posz, posradius, allyTeamID, checkLoS end local function VisibilityCheckEnemy(posx, posy, posz, posradius, allyTeamID, checkLoS, checkAirLos, checkRadar) -- Return True when position is not in sensor ranges of all enemies of specified allyTeam. - for _, testAllyTeamID in ipairs(Spring.GetAllyTeamList()) do + for _, testAllyTeamID in ipairs(SpringShared.GetAllyTeamList()) do local posCheck = true if testAllyTeamID ~= allyTeamID and testAllyTeamID ~= GaiaAllyTeamID then posCheck = VisibilityCheck(posx, posy, posz, posradius, testAllyTeamID, checkLoS, checkAirLos, checkRadar) @@ -262,17 +262,17 @@ local function SurfaceCheck(posx, posy, posz, posradius, sea) -- if true then po local zPlus = posz + posradius local zMinus = posz - posradius - local testpos0 = Spring.GetGroundHeight(posx, posz) - local testpos1 = Spring.GetGroundHeight(xPlus, zPlus) - local testpos2 = Spring.GetGroundHeight(xPlus, zMinus) - local testpos3 = Spring.GetGroundHeight(xMinus, zPlus) - local testpos4 = Spring.GetGroundHeight(xMinus, zMinus) - local testpos5 = Spring.GetGroundHeight(xPlus, posz) - local testpos6 = Spring.GetGroundHeight(posx, zPlus) - local testpos7 = Spring.GetGroundHeight(xMinus, posz) - local testpos8 = Spring.GetGroundHeight(posx, zMinus) + local testpos0 = SpringShared.GetGroundHeight(posx, posz) + local testpos1 = SpringShared.GetGroundHeight(xPlus, zPlus) + local testpos2 = SpringShared.GetGroundHeight(xPlus, zMinus) + local testpos3 = SpringShared.GetGroundHeight(xMinus, zPlus) + local testpos4 = SpringShared.GetGroundHeight(xMinus, zMinus) + local testpos5 = SpringShared.GetGroundHeight(xPlus, posz) + local testpos6 = SpringShared.GetGroundHeight(posx, zPlus) + local testpos7 = SpringShared.GetGroundHeight(xMinus, posz) + local testpos8 = SpringShared.GetGroundHeight(posx, zMinus) local deathwater = Game.waterDamage - local lavaLevel = Spring.GetGameRulesParam("lavaLevel") + local lavaLevel = SpringShared.GetGameRulesParam("lavaLevel") if deathwater > 0 and posy <= 0 then return false @@ -345,9 +345,9 @@ end local function ScavengerSpawnAreaCheck(posx, posy, posz, posradius) -- if true then position is within Scavengers spawn area. local posradius = posradius or 1000 if scavengerAllyTeamID then - local scavTechPercentage = Spring.GetGameRulesParam("scavStatsTechPercentage") + local scavTechPercentage = SpringShared.GetGameRulesParam("scavStatsTechPercentage") if scavTechPercentage then - if Spring.GetModOptions().scavspawnarea == true then + if SpringShared.GetModOptions().scavspawnarea == true then if not AllyTeamStartboxes[scavengerAllyTeamID + 1].allyTeamHasStartbox then return true end -- Scavs do not have a startbox so we allow them to spawn anywhere @@ -397,7 +397,7 @@ end local function LavaCheck(posx, posy, posz, posradius) -- Returns false if area is in lava local posradius = posradius or 1000 - local lavaLevel = Spring.GetGameRulesParam("lavaLevel") + local lavaLevel = SpringShared.GetGameRulesParam("lavaLevel") if lavaLevel and posy <= lavaLevel then return false end -- Is lava @@ -414,7 +414,7 @@ local function MapIsLandOrSea() local seaNodes = 0 for i = 1, grid do if x <= mapSizeX then - y = Spring.GetGroundHeight(x, z) + y = SpringShared.GetGroundHeight(x, z) if y > -15 then landNodes = landNodes + 1 elseif y <= -15 then @@ -428,7 +428,7 @@ local function MapIsLandOrSea() break end - y = Spring.GetGroundHeight(x, z) + y = SpringShared.GetGroundHeight(x, z) if y > 0 then landNodes = landNodes + 1 elseif y <= 0 then diff --git a/luarules/Utilities/damgam_lib/spawn_queue.lua b/luarules/Utilities/damgam_lib/spawn_queue.lua index 9036a46ca77..c38c1fb6ad1 100644 --- a/luarules/Utilities/damgam_lib/spawn_queue.lua +++ b/luarules/Utilities/damgam_lib/spawn_queue.lua @@ -37,7 +37,7 @@ local function AddToSpawnQueue(unitName, posx, posy, posz, facing, team, frame, QueuedSpawnList[1] = QueueSpawnCommand end else - Spring.Echo("[Spawn Queue] Failed to queue " .. unitName .. ", invalid unitDefName") + SpringShared.Echo("[Spawn Queue] Failed to queue " .. unitName .. ", invalid unitDefName") end end @@ -48,13 +48,13 @@ local function SpawnUnitsFromQueue(n) -- Call this every frame in your gadget. for i = 1, QueuedSpawnsNumber do local item = QueuedSpawnList[1] if item and n >= item.frame then - local unitID = Spring.CreateUnit(item.unitName, item.posx, item.posy, item.posz, item.facing, item.team) + local unitID = SpringSynced.CreateUnit(item.unitName, item.posx, item.posy, item.posz, item.facing, item.team) if unitID and item.blocking == false then - Spring.SetUnitBlocking(unitID, false, false, true) + SpringSynced.SetUnitBlocking(unitID, false, false, true) end if unitID and item.resurrected == true then - Spring.SetUnitRulesParam(unitID, "resurrected", 1, { inlos = true }) - Spring.SetUnitHealth(unitID, 10) + SpringSynced.SetUnitRulesParam(unitID, "resurrected", 1, { inlos = true }) + SpringSynced.SetUnitHealth(unitID, 10) elseif unitID then GG.ScavengersSpawnEffectUnitID(unitID) end @@ -75,7 +75,7 @@ local function AddToDestroyQueue(unitID, selfd, reclaimed, frame) reclaimed = false end - if Spring.ValidUnitID(unitID) then + if SpringShared.ValidUnitID(unitID) then local QueueDestroyCommand = { unitID = unitID, frame = frame, @@ -108,7 +108,7 @@ local function DestroyUnitsFromQueue(n) -- Call this every frame in your gadget. for i = 1, QueuedDestroyNumber do local item = QueuedDestroyList[1] if item and n >= item.frame then - Spring.DestroyUnit(item.unitID, item.selfd, item.reclaimed) + SpringSynced.DestroyUnit(item.unitID, item.selfd, item.reclaimed) table.remove(QueuedDestroyList, 1) elseif not item then break diff --git a/luarules/Utilities/damgam_lib/unit_swap.lua b/luarules/Utilities/damgam_lib/unit_swap.lua index 2eb38118944..6a9b1bc4b54 100644 --- a/luarules/Utilities/damgam_lib/unit_swap.lua +++ b/luarules/Utilities/damgam_lib/unit_swap.lua @@ -1,29 +1,29 @@ local function SwapUnit(unitID, newUnitName) -- Collect info about unit - local unitDefID = Spring.GetUnitDefID(unitID) - local unitTeam = Spring.GetUnitTeam(unitID) - local unitHealth, unitMaxHealth, unitParalyze, unitCapture, unitBuildProgress = Spring.GetUnitHealth(unitID) - local unitExperience = Spring.GetUnitExperience(unitID) - local unitPosX, unitPosY, unitPosZ = Spring.GetUnitPosition(unitID) - local unitDirectionX, unitDirectionY, unitDirectionZ = Spring.GetUnitDirection(unitID) - local unitVelocityX, unitVelocityY, unitVelocityZ = Spring.GetUnitVelocity(unitID) - local unitResurrected = Spring.GetUnitRulesParam(unitID, "resurrected") + local unitDefID = SpringShared.GetUnitDefID(unitID) + local unitTeam = SpringShared.GetUnitTeam(unitID) + local unitHealth, unitMaxHealth, unitParalyze, unitCapture, unitBuildProgress = SpringShared.GetUnitHealth(unitID) + local unitExperience = SpringShared.GetUnitExperience(unitID) + local unitPosX, unitPosY, unitPosZ = SpringShared.GetUnitPosition(unitID) + local unitDirectionX, unitDirectionY, unitDirectionZ = SpringShared.GetUnitDirection(unitID) + local unitVelocityX, unitVelocityY, unitVelocityZ = SpringShared.GetUnitVelocity(unitID) + local unitResurrected = SpringShared.GetUnitRulesParam(unitID, "resurrected") -- Spawn new unit, and if successful, despawn old one. - local newUnitID = Spring.CreateUnit(newUnitName, unitPosX, unitPosY, unitPosZ, 0, unitTeam) + local newUnitID = SpringSynced.CreateUnit(newUnitName, unitPosX, unitPosY, unitPosZ, 0, unitTeam) if newUnitID then - Spring.DestroyUnit(unitID, false, true) + SpringSynced.DestroyUnit(unitID, false, true) GG.ScavengersSpawnEffectUnitID(newUnitID) -- Apply stats of old unit to new one - Spring.SetUnitExperience(newUnitID, unitExperience) - local newUnitMaxHealth = select(2, Spring.GetUnitHealth(newUnitID)) + SpringSynced.SetUnitExperience(newUnitID, unitExperience) + local newUnitMaxHealth = select(2, SpringShared.GetUnitHealth(newUnitID)) local newUnitHealth = (unitHealth / unitMaxHealth) * newUnitMaxHealth - Spring.SetUnitHealth(newUnitID, newUnitHealth, unitCapture, unitParalyze, unitBuildProgress) - Spring.SetUnitDirection(newUnitID, unitDirectionX, unitDirectionY, unitDirectionZ) - Spring.SetUnitVelocity(newUnitID, unitVelocityX, unitVelocityY, unitVelocityZ) + SpringSynced.SetUnitHealth(newUnitID, newUnitHealth, unitCapture, unitParalyze, unitBuildProgress) + SpringSynced.SetUnitDirection(newUnitID, unitDirectionX, unitDirectionY, unitDirectionZ) + SpringSynced.SetUnitVelocity(newUnitID, unitVelocityX, unitVelocityY, unitVelocityZ) if unitResurrected then - Spring.SetUnitRulesParam(newUnitID, "resurrected", 1, { inlos = true }) + SpringSynced.SetUnitRulesParam(newUnitID, "resurrected", 1, { inlos = true }) end end end diff --git a/luarules/Utilities/unitrendering.lua b/luarules/Utilities/unitrendering.lua index 7b31d355fc3..f1b544de995 100644 --- a/luarules/Utilities/unitrendering.lua +++ b/luarules/Utilities/unitrendering.lua @@ -18,16 +18,16 @@ local unitRendering = { lods = {}, curHighestLOD = 0, activeMats = {}, - spSetLODCount = Spring.UnitRendering.SetLODCount, - spSetMaterialLastLOD = Spring.UnitRendering.SetMaterialLastLOD, + spSetLODCount = SpringUnsynced.UnitRendering.SetLODCount, + spSetMaterialLastLOD = SpringUnsynced.UnitRendering.SetMaterialLastLOD, } local featureRendering = { lods = {}, curHighestLOD = 0, activeMats = {}, - spSetLODCount = Spring.FeatureRendering.SetLODCount, - spSetMaterialLastLOD = Spring.FeatureRendering.SetMaterialLastLOD, + spSetLODCount = SpringUnsynced.FeatureRendering.SetLODCount, + spSetMaterialLastLOD = SpringUnsynced.FeatureRendering.SetMaterialLastLOD, } local function SetLODCount(rendering, objectID, lod_count) diff --git a/luarules/configs/Atmosphereconfigs/acidicquarry.lua b/luarules/configs/Atmosphereconfigs/acidicquarry.lua index f78526981c4..6789fd81c25 100644 --- a/luarules/configs/Atmosphereconfigs/acidicquarry.lua +++ b/luarules/configs/Atmosphereconfigs/acidicquarry.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- ## Atmosphere Functions diff --git a/luarules/configs/Atmosphereconfigs/all that simmers.lua b/luarules/configs/Atmosphereconfigs/all that simmers.lua index aab7840b03f..2c39d4ea9cc 100644 --- a/luarules/configs/Atmosphereconfigs/all that simmers.lua +++ b/luarules/configs/Atmosphereconfigs/all that simmers.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- random sandclouds diff --git a/luarules/configs/Atmosphereconfigs/all that smolders.lua b/luarules/configs/Atmosphereconfigs/all that smolders.lua index 627fb05b950..a71d3fdbc2f 100644 --- a/luarules/configs/Atmosphereconfigs/all that smolders.lua +++ b/luarules/configs/Atmosphereconfigs/all that smolders.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- random sandclouds diff --git a/luarules/configs/Atmosphereconfigs/altored divide bar remake.lua b/luarules/configs/Atmosphereconfigs/altored divide bar remake.lua index dd9b8ebb809..46e6c620ad5 100644 --- a/luarules/configs/Atmosphereconfigs/altored divide bar remake.lua +++ b/luarules/configs/Atmosphereconfigs/altored divide bar remake.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- SND windy locations diff --git a/luarules/configs/Atmosphereconfigs/ascendancy.lua b/luarules/configs/Atmosphereconfigs/ascendancy.lua index c24cc6d6606..f0e3a58a374 100644 --- a/luarules/configs/Atmosphereconfigs/ascendancy.lua +++ b/luarules/configs/Atmosphereconfigs/ascendancy.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- SND windy locations diff --git a/luarules/configs/Atmosphereconfigs/centerrock remake dry.lua b/luarules/configs/Atmosphereconfigs/centerrock remake dry.lua index 01699fc5457..01943f72ce7 100644 --- a/luarules/configs/Atmosphereconfigs/centerrock remake dry.lua +++ b/luarules/configs/Atmosphereconfigs/centerrock remake dry.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- DayNight Cycle diff --git a/luarules/configs/Atmosphereconfigs/centerrock remake.lua b/luarules/configs/Atmosphereconfigs/centerrock remake.lua index 5fac7322ee3..b11a9b5ce70 100644 --- a/luarules/configs/Atmosphereconfigs/centerrock remake.lua +++ b/luarules/configs/Atmosphereconfigs/centerrock remake.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- if n%25600 < 12800 then diff --git a/luarules/configs/Atmosphereconfigs/colorado_v2.lua b/luarules/configs/Atmosphereconfigs/colorado_v2.lua index acfe43a5558..98a8d44b0f6 100644 --- a/luarules/configs/Atmosphereconfigs/colorado_v2.lua +++ b/luarules/configs/Atmosphereconfigs/colorado_v2.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- SND windy locations diff --git a/luarules/configs/Atmosphereconfigs/dsdr.lua b/luarules/configs/Atmosphereconfigs/dsdr.lua index 75be93e1569..4754ee0f984 100644 --- a/luarules/configs/Atmosphereconfigs/dsdr.lua +++ b/luarules/configs/Atmosphereconfigs/dsdr.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- ## Atmosphere Functions diff --git a/luarules/configs/Atmosphereconfigs/eye of horus.lua b/luarules/configs/Atmosphereconfigs/eye of horus.lua index a602f3cacfd..cf4bd61f428 100644 --- a/luarules/configs/Atmosphereconfigs/eye of horus.lua +++ b/luarules/configs/Atmosphereconfigs/eye of horus.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- SND windy locations diff --git a/luarules/configs/Atmosphereconfigs/folsomdamr.lua b/luarules/configs/Atmosphereconfigs/folsomdamr.lua index a3fdf3d0ea4..a1ffb890f29 100644 --- a/luarules/configs/Atmosphereconfigs/folsomdamr.lua +++ b/luarules/configs/Atmosphereconfigs/folsomdamr.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- SND windy locations diff --git a/luarules/configs/Atmosphereconfigs/forge.lua b/luarules/configs/Atmosphereconfigs/forge.lua index ffb1fef7ff2..c79e61acfa9 100644 --- a/luarules/configs/Atmosphereconfigs/forge.lua +++ b/luarules/configs/Atmosphereconfigs/forge.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- SND windy locations diff --git a/luarules/configs/Atmosphereconfigs/generic_config_setup.lua b/luarules/configs/Atmosphereconfigs/generic_config_setup.lua index 5bb1b8e1317..4e09571dfc8 100644 --- a/luarules/configs/Atmosphereconfigs/generic_config_setup.lua +++ b/luarules/configs/Atmosphereconfigs/generic_config_setup.lua @@ -1,4 +1,4 @@ -Spring.Echo("Enabled generic atmosphere config") +SpringShared.Echo("Enabled generic atmosphere config") local math_random = math.random diff --git a/luarules/configs/Atmosphereconfigs/koom valley 3.lua b/luarules/configs/Atmosphereconfigs/koom valley 3.lua index b343376c34e..f32c6bdd94b 100644 --- a/luarules/configs/Atmosphereconfigs/koom valley 3.lua +++ b/luarules/configs/Atmosphereconfigs/koom valley 3.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- SND windy locations diff --git a/luarules/configs/Atmosphereconfigs/koomvalleybar.lua b/luarules/configs/Atmosphereconfigs/koomvalleybar.lua index 687644958a0..125cb4f93b7 100644 --- a/luarules/configs/Atmosphereconfigs/koomvalleybar.lua +++ b/luarules/configs/Atmosphereconfigs/koomvalleybar.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- ## Atmosphere CEG Functions diff --git a/luarules/configs/Atmosphereconfigs/lv412.lua b/luarules/configs/Atmosphereconfigs/lv412.lua index 80d10fed4cb..73bb77db3ba 100644 --- a/luarules/configs/Atmosphereconfigs/lv412.lua +++ b/luarules/configs/Atmosphereconfigs/lv412.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- DayNight Cycle diff --git a/luarules/configs/Atmosphereconfigs/onyx cauldron.lua b/luarules/configs/Atmosphereconfigs/onyx cauldron.lua index e98135387f0..f8d624238a6 100644 --- a/luarules/configs/Atmosphereconfigs/onyx cauldron.lua +++ b/luarules/configs/Atmosphereconfigs/onyx cauldron.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- ## Atmosphere Functions diff --git a/luarules/configs/Atmosphereconfigs/quicksilver remake.lua b/luarules/configs/Atmosphereconfigs/quicksilver remake.lua index deead97e87f..a5c08422b97 100644 --- a/luarules/configs/Atmosphereconfigs/quicksilver remake.lua +++ b/luarules/configs/Atmosphereconfigs/quicksilver remake.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- SpawnCEGInAreaGround(cegname, midposx, groundOffset, midposz, radius, damage, paralyzedamage, damageradius, sound, soundvolume) diff --git a/luarules/configs/Atmosphereconfigs/red comet remake.lua b/luarules/configs/Atmosphereconfigs/red comet remake.lua index 50a3d2db671..ab0683420bf 100644 --- a/luarules/configs/Atmosphereconfigs/red comet remake.lua +++ b/luarules/configs/Atmosphereconfigs/red comet remake.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- random sandclouds diff --git a/luarules/configs/Atmosphereconfigs/riverdale remake.lua b/luarules/configs/Atmosphereconfigs/riverdale remake.lua index 35ff82789dd..cefeed59f1c 100644 --- a/luarules/configs/Atmosphereconfigs/riverdale remake.lua +++ b/luarules/configs/Atmosphereconfigs/riverdale remake.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- ## Atmosphere Functions diff --git a/luarules/configs/Atmosphereconfigs/seths ravine.lua b/luarules/configs/Atmosphereconfigs/seths ravine.lua index 691cc81d3e0..be62a8f9711 100644 --- a/luarules/configs/Atmosphereconfigs/seths ravine.lua +++ b/luarules/configs/Atmosphereconfigs/seths ravine.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- ## Atmosphere Functions diff --git a/luarules/configs/Atmosphereconfigs/tabula_remake.lua b/luarules/configs/Atmosphereconfigs/tabula_remake.lua index 51c708a3b5a..cb8429cfec0 100644 --- a/luarules/configs/Atmosphereconfigs/tabula_remake.lua +++ b/luarules/configs/Atmosphereconfigs/tabula_remake.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- SND windy locations diff --git a/luarules/configs/Atmosphereconfigs/tma20x.lua b/luarules/configs/Atmosphereconfigs/tma20x.lua index d5e51d45e29..036c2e95073 100644 --- a/luarules/configs/Atmosphereconfigs/tma20x.lua +++ b/luarules/configs/Atmosphereconfigs/tma20x.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- common foggy cliffs diff --git a/luarules/configs/Atmosphereconfigs/trefoil remake.lua b/luarules/configs/Atmosphereconfigs/trefoil remake.lua index 83b9bfa2207..e24457dda93 100644 --- a/luarules/configs/Atmosphereconfigs/trefoil remake.lua +++ b/luarules/configs/Atmosphereconfigs/trefoil remake.lua @@ -2,7 +2,7 @@ local gadget = gadget ---@type Gadget function gadget:GameFrame(n) if n == 31 then - Spring.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) + SpringShared.Echo("Loaded atmosphere CEGs config for map: " .. Game.mapName) end -- SND water ocean diff --git a/luarules/configs/icon_generator.lua b/luarules/configs/icon_generator.lua index a3720eda834..c8b230ab8ce 100644 --- a/luarules/configs/icon_generator.lua +++ b/luarules/configs/icon_generator.lua @@ -45,7 +45,7 @@ factionColors = function(faction) Blue = { 0, 0, 0 }, Red = { 1, 1, 1 }, } - Spring.Echo("Queried faction: " .. faction .. ", scheme: " .. scheme) + SpringShared.Echo("Queried faction: " .. faction .. ", scheme: " .. scheme) if color[faction] then return color[faction] diff --git a/luarules/configs/raptor_spawn_defs.lua b/luarules/configs/raptor_spawn_defs.lua index 47d8cc83d8e..8ef28158eb8 100644 --- a/luarules/configs/raptor_spawn_defs.lua +++ b/luarules/configs/raptor_spawn_defs.lua @@ -9,8 +9,8 @@ local difficulties = { --survival = 6, } -local difficulty = difficulties[Spring.GetModOptions().raptor_difficulty] -local economyScale = 1 * Spring.GetModOptions().multiplier_resourceincome * (0.67 + (Spring.GetModOptions().multiplier_metalextraction * 0.33)) * (0.67 + (Spring.GetModOptions().multiplier_energyconversion * 0.33)) * (0.67 + (Spring.GetModOptions().multiplier_energyproduction * 0.33)) * (((((Spring.GetModOptions().startmetal - 1000) / 9000) + 1) * 0.1) + 0.9) * (((((Spring.GetModOptions().startenergy - 1000) / 9000) + 1) * 0.1) + 0.9) +local difficulty = difficulties[SpringShared.GetModOptions().raptor_difficulty] +local economyScale = 1 * SpringShared.GetModOptions().multiplier_resourceincome * (0.67 + (SpringShared.GetModOptions().multiplier_metalextraction * 0.33)) * (0.67 + (SpringShared.GetModOptions().multiplier_energyconversion * 0.33)) * (0.67 + (SpringShared.GetModOptions().multiplier_energyproduction * 0.33)) * (((((SpringShared.GetModOptions().startmetal - 1000) / 9000) + 1) * 0.1) + 0.9) * (((((SpringShared.GetModOptions().startenergy - 1000) / 9000) + 1) * 0.1) + 0.9) economyScale = math.min(5, (economyScale * 0.33) + 0.67) @@ -27,17 +27,17 @@ raptorTurrets["raptor_turret_basic_t3_v1"] = { minQueenAnger = 30, spawnedPerWav raptorTurrets["raptor_turret_acid_t3_v1"] = { minQueenAnger = 45, spawnedPerWave = 0.25, maxExisting = 3, maxQueenAnger = 1000 } raptorTurrets["raptor_turret_emp_t3_v1"] = { minQueenAnger = 45, spawnedPerWave = 0.25, maxExisting = 3, maxQueenAnger = 1000 } -if not Spring.GetModOptions().unit_restrictions_nonukes then +if not SpringShared.GetModOptions().unit_restrictions_nonukes then raptorTurrets["raptor_turret_antinuke_t2_v1"] = { minQueenAnger = 15, spawnedPerWave = 0.25, maxExisting = 10, maxQueenAnger = 1000 } raptorTurrets["raptor_turret_antinuke_t3_v1"] = { minQueenAnger = 45, spawnedPerWave = 0.25, maxExisting = 3, maxQueenAnger = 1000 } raptorTurrets["raptor_turret_meteor_t4_v1"] = { minQueenAnger = 75, spawnedPerWave = 0.5, maxExisting = 6, maxQueenAnger = 1000 } end -if not Spring.GetModOptions().unit_restrictions_noair then +if not SpringShared.GetModOptions().unit_restrictions_noair then raptorTurrets["raptor_turret_antiair_t2_v1"] = { minQueenAnger = 0, spawnedPerWave = 0.5, maxExisting = 20, maxQueenAnger = 1000 } raptorTurrets["raptor_turret_antiair_t3_v1"] = { minQueenAnger = 30, spawnedPerWave = 0.5, maxExisting = 6, maxQueenAnger = 1000 } raptorTurrets["raptor_turret_antiair_t4_v1"] = { minQueenAnger = 60, spawnedPerWave = 0.25, maxExisting = 2, maxQueenAnger = 1000 } end -if not Spring.GetModOptions().unit_restrictions_nolrpc then +if not SpringShared.GetModOptions().unit_restrictions_nolrpc then raptorTurrets["raptor_turret_basic_t4_v1"] = { minQueenAnger = 60, spawnedPerWave = 0.25, maxExisting = 2, maxQueenAnger = 1000 } raptorTurrets["raptor_turret_emp_t4_v1"] = { minQueenAnger = 75, spawnedPerWave = 0.25, maxExisting = 1, maxQueenAnger = 1000 } raptorTurrets["raptor_turret_acid_t4_v1"] = { minQueenAnger = 75, spawnedPerWave = 0.25, maxExisting = 1, maxQueenAnger = 1000 } @@ -294,11 +294,11 @@ raptorBehaviours = { local optionValues = { [difficulties.veryeasy] = { - gracePeriod = 9 * Spring.GetModOptions().raptor_graceperiodmult * 60, - queenTime = 55 * Spring.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds - raptorSpawnRate = 120 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - burrowSpawnRate = 240 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - turretSpawnRate = 120 / Spring.GetModOptions().raptor_spawntimemult / economyScale, + gracePeriod = 9 * SpringShared.GetModOptions().raptor_graceperiodmult * 60, + queenTime = 55 * SpringShared.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds + raptorSpawnRate = 120 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + burrowSpawnRate = 240 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + turretSpawnRate = 120 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, queenSpawnMult = 1, angerBonus = 0.1, maxXP = 0.5 * economyScale, @@ -314,11 +314,11 @@ local optionValues = { }, [difficulties.easy] = { - gracePeriod = 8 * Spring.GetModOptions().raptor_graceperiodmult * 60, - queenTime = 50 * Spring.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds - raptorSpawnRate = 90 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - burrowSpawnRate = 210 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - turretSpawnRate = 100 / Spring.GetModOptions().raptor_spawntimemult / economyScale, + gracePeriod = 8 * SpringShared.GetModOptions().raptor_graceperiodmult * 60, + queenTime = 50 * SpringShared.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds + raptorSpawnRate = 90 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + burrowSpawnRate = 210 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + turretSpawnRate = 100 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, queenSpawnMult = 1, angerBonus = 0.15, maxXP = 1 * economyScale, @@ -333,11 +333,11 @@ local optionValues = { queenResistanceMult = 0.75 * economyScale, }, [difficulties.normal] = { - gracePeriod = 7 * Spring.GetModOptions().raptor_graceperiodmult * 60, - queenTime = 45 * Spring.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds - raptorSpawnRate = 60 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - burrowSpawnRate = 180 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - turretSpawnRate = 80 / Spring.GetModOptions().raptor_spawntimemult / economyScale, + gracePeriod = 7 * SpringShared.GetModOptions().raptor_graceperiodmult * 60, + queenTime = 45 * SpringShared.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds + raptorSpawnRate = 60 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + burrowSpawnRate = 180 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + turretSpawnRate = 80 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, queenSpawnMult = 3, angerBonus = 0.20, maxXP = 1.5 * economyScale, @@ -352,11 +352,11 @@ local optionValues = { queenResistanceMult = 1 * economyScale, }, [difficulties.hard] = { - gracePeriod = 6 * Spring.GetModOptions().raptor_graceperiodmult * 60, - queenTime = 40 * Spring.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds - raptorSpawnRate = 50 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - burrowSpawnRate = 150 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - turretSpawnRate = 60 / Spring.GetModOptions().raptor_spawntimemult / economyScale, + gracePeriod = 6 * SpringShared.GetModOptions().raptor_graceperiodmult * 60, + queenTime = 40 * SpringShared.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds + raptorSpawnRate = 50 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + burrowSpawnRate = 150 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + turretSpawnRate = 60 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, queenSpawnMult = 3, angerBonus = 0.25, maxXP = 2 * economyScale, @@ -371,11 +371,11 @@ local optionValues = { queenResistanceMult = 1.33 * economyScale, }, [difficulties.veryhard] = { - gracePeriod = 5 * Spring.GetModOptions().raptor_graceperiodmult * 60, - queenTime = 35 * Spring.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds - raptorSpawnRate = 40 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - burrowSpawnRate = 120 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - turretSpawnRate = 40 / Spring.GetModOptions().raptor_spawntimemult / economyScale, + gracePeriod = 5 * SpringShared.GetModOptions().raptor_graceperiodmult * 60, + queenTime = 35 * SpringShared.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds + raptorSpawnRate = 40 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + burrowSpawnRate = 120 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + turretSpawnRate = 40 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, queenSpawnMult = 3, angerBonus = 0.30, maxXP = 2.5 * economyScale, @@ -390,11 +390,11 @@ local optionValues = { queenResistanceMult = 1.67 * economyScale, }, [difficulties.epic] = { - gracePeriod = 4 * Spring.GetModOptions().raptor_graceperiodmult * 60, - queenTime = 30 * Spring.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds - raptorSpawnRate = 30 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - burrowSpawnRate = 90 / Spring.GetModOptions().raptor_spawntimemult / economyScale, - turretSpawnRate = 20 / Spring.GetModOptions().raptor_spawntimemult / economyScale, + gracePeriod = 4 * SpringShared.GetModOptions().raptor_graceperiodmult * 60, + queenTime = 30 * SpringShared.GetModOptions().raptor_queentimemult * 60, -- time at which the queen appears, seconds + raptorSpawnRate = 30 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + burrowSpawnRate = 90 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, + turretSpawnRate = 20 / SpringShared.GetModOptions().raptor_spawntimemult / economyScale, queenSpawnMult = 3, angerBonus = 0.35, maxXP = 3 * economyScale, @@ -2348,7 +2348,7 @@ end --------------------------------------------- local airStartAnger = 0 -- needed for air waves to work correctly. -if Spring.GetModOptions().unit_restrictions_noair then +if SpringShared.GetModOptions().unit_restrictions_noair then airStartAnger = 10000 end --Scouts------------------------------------------------------------------------------------------------------ @@ -3045,9 +3045,9 @@ local config = { -- Don't touch this! ------------------------------------------ raptorEggs = table.copy(raptorEggs), burrowName = burrowName, -- burrow unit name burrowDef = UnitDefNames[burrowName] and UnitDefNames[burrowName].id, - raptorSpawnMultiplier = Spring.GetModOptions().raptor_spawncountmult, - burrowSpawnType = Spring.GetModOptions().raptor_raptorstart, - swarmMode = Spring.GetModOptions().raptor_swarmmode, + raptorSpawnMultiplier = SpringShared.GetModOptions().raptor_spawncountmult, + burrowSpawnType = SpringShared.GetModOptions().raptor_raptorstart, + swarmMode = SpringShared.GetModOptions().raptor_swarmmode, spawnSquare = spawnSquare, spawnSquareIncrement = spawnSquareIncrement, raptorTurrets = table.copy(raptorTurrets), diff --git a/luarules/configs/scav_spawn_defs.lua b/luarules/configs/scav_spawn_defs.lua index cb44f924fe9..577ee1f12dc 100644 --- a/luarules/configs/scav_spawn_defs.lua +++ b/luarules/configs/scav_spawn_defs.lua @@ -8,17 +8,17 @@ local difficulties = { --survival = 6, } -local difficulty = difficulties[Spring.GetModOptions().scav_difficulty] -local economyScale = 1 * Spring.GetModOptions().multiplier_resourceincome * (0.67 + (Spring.GetModOptions().multiplier_metalextraction * 0.33)) * (0.67 + (Spring.GetModOptions().multiplier_energyconversion * 0.33)) * (0.67 + (Spring.GetModOptions().multiplier_energyproduction * 0.33)) * (((((Spring.GetModOptions().startmetal - 1000) / 9000) + 1) * 0.1) + 0.9) * (((((Spring.GetModOptions().startenergy - 1000) / 9000) + 1) * 0.1) + 0.9) +local difficulty = difficulties[SpringShared.GetModOptions().scav_difficulty] +local economyScale = 1 * SpringShared.GetModOptions().multiplier_resourceincome * (0.67 + (SpringShared.GetModOptions().multiplier_metalextraction * 0.33)) * (0.67 + (SpringShared.GetModOptions().multiplier_energyconversion * 0.33)) * (0.67 + (SpringShared.GetModOptions().multiplier_energyproduction * 0.33)) * (((((SpringShared.GetModOptions().startmetal - 1000) / 9000) + 1) * 0.1) + 0.9) * (((((SpringShared.GetModOptions().startenergy - 1000) / 9000) + 1) * 0.1) + 0.9) economyScale = math.min(5, (economyScale * 0.33) + 0.67) -local teams = Spring.GetTeamList() +local teams = SpringShared.GetTeamList() local humanTeamCount = -1 -- starts at -1 to disregard gaia local scavTeamCount local scavTeamID for _, teamID in ipairs(teams) do - local teamLuaAI = Spring.GetTeamLuaAI(teamID) + local teamLuaAI = SpringShared.GetTeamLuaAI(teamID) if not (teamLuaAI and string.find(teamLuaAI, "ScavengersAI")) then humanTeamCount = humanTeamCount + 1 end @@ -27,11 +27,11 @@ end local difficultyParameters = { [difficulties.veryeasy] = { - gracePeriod = 360 * Spring.GetModOptions().scav_graceperiodmult, - bossTime = 65 * Spring.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds - scavSpawnRate = 240 / Spring.GetModOptions().scav_spawntimemult / economyScale, - burrowSpawnRate = 240 / Spring.GetModOptions().scav_spawntimemult / economyScale, - turretSpawnRate = 500 / Spring.GetModOptions().scav_spawntimemult / economyScale, + gracePeriod = 360 * SpringShared.GetModOptions().scav_graceperiodmult, + bossTime = 65 * SpringShared.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds + scavSpawnRate = 240 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + burrowSpawnRate = 240 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + turretSpawnRate = 500 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, bossSpawnMult = 1, angerBonus = 0.1, maxXP = 0.1 * economyScale, @@ -47,11 +47,11 @@ local difficultyParameters = { }, [difficulties.easy] = { - gracePeriod = 240 * Spring.GetModOptions().scav_graceperiodmult, - bossTime = 60 * Spring.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds - scavSpawnRate = 200 / Spring.GetModOptions().scav_spawntimemult / economyScale, - burrowSpawnRate = 210 / Spring.GetModOptions().scav_spawntimemult / economyScale, - turretSpawnRate = 420 / Spring.GetModOptions().scav_spawntimemult / economyScale, + gracePeriod = 240 * SpringShared.GetModOptions().scav_graceperiodmult, + bossTime = 60 * SpringShared.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds + scavSpawnRate = 200 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + burrowSpawnRate = 210 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + turretSpawnRate = 420 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, bossSpawnMult = 1, angerBonus = 0.15, maxXP = 0.2 * economyScale, @@ -66,11 +66,11 @@ local difficultyParameters = { bossResistanceMult = 1.5 * economyScale, }, [difficulties.normal] = { - gracePeriod = 180 * Spring.GetModOptions().scav_graceperiodmult, - bossTime = 55 * Spring.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds - scavSpawnRate = 180 / Spring.GetModOptions().scav_spawntimemult / economyScale, - burrowSpawnRate = 180 / Spring.GetModOptions().scav_spawntimemult / economyScale, - turretSpawnRate = 380 / Spring.GetModOptions().scav_spawntimemult / economyScale, + gracePeriod = 180 * SpringShared.GetModOptions().scav_graceperiodmult, + bossTime = 55 * SpringShared.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds + scavSpawnRate = 180 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + burrowSpawnRate = 180 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + turretSpawnRate = 380 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, bossSpawnMult = 3, angerBonus = 0.2, maxXP = 0.3 * economyScale, @@ -85,11 +85,11 @@ local difficultyParameters = { bossResistanceMult = 2 * economyScale, }, [difficulties.hard] = { - gracePeriod = 160 * Spring.GetModOptions().scav_graceperiodmult, - bossTime = 50 * Spring.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds - scavSpawnRate = 160 / Spring.GetModOptions().scav_spawntimemult / economyScale, - burrowSpawnRate = 150 / Spring.GetModOptions().scav_spawntimemult / economyScale, - turretSpawnRate = 340 / Spring.GetModOptions().scav_spawntimemult / economyScale, + gracePeriod = 160 * SpringShared.GetModOptions().scav_graceperiodmult, + bossTime = 50 * SpringShared.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds + scavSpawnRate = 160 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + burrowSpawnRate = 150 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + turretSpawnRate = 340 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, bossSpawnMult = 3, angerBonus = 0.25, maxXP = 0.4 * economyScale, @@ -104,11 +104,11 @@ local difficultyParameters = { bossResistanceMult = 2.5 * economyScale, }, [difficulties.veryhard] = { - gracePeriod = 140 * Spring.GetModOptions().scav_graceperiodmult, - bossTime = 45 * Spring.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds - scavSpawnRate = 140 / Spring.GetModOptions().scav_spawntimemult / economyScale, - burrowSpawnRate = 120 / Spring.GetModOptions().scav_spawntimemult / economyScale, - turretSpawnRate = 320 / Spring.GetModOptions().scav_spawntimemult / economyScale, + gracePeriod = 140 * SpringShared.GetModOptions().scav_graceperiodmult, + bossTime = 45 * SpringShared.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds + scavSpawnRate = 140 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + burrowSpawnRate = 120 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + turretSpawnRate = 320 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, bossSpawnMult = 3, angerBonus = 0.30, maxXP = 0.5 * economyScale, @@ -123,11 +123,11 @@ local difficultyParameters = { bossResistanceMult = 3 * economyScale, }, [difficulties.epic] = { - gracePeriod = 120 * Spring.GetModOptions().scav_graceperiodmult, - bossTime = 40 * Spring.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds - scavSpawnRate = 120 / Spring.GetModOptions().scav_spawntimemult / economyScale, - burrowSpawnRate = 90 / Spring.GetModOptions().scav_spawntimemult / economyScale, - turretSpawnRate = 260 / Spring.GetModOptions().scav_spawntimemult / economyScale, + gracePeriod = 120 * SpringShared.GetModOptions().scav_graceperiodmult, + bossTime = 40 * SpringShared.GetModOptions().scav_bosstimemult * 60, -- time at which the boss appears, seconds + scavSpawnRate = 120 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + burrowSpawnRate = 90 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, + turretSpawnRate = 260 / SpringShared.GetModOptions().scav_spawntimemult / economyScale, bossSpawnMult = 3, angerBonus = 0.35, maxXP = 0.6 * economyScale, @@ -933,7 +933,7 @@ local SeaUnitsList = { ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- -if not Spring.GetModOptions().unit_restrictions_noair then +if not SpringShared.GetModOptions().unit_restrictions_noair then local t1landairconstructors = { ["armca_scav"] = 2, ["corca_scav"] = 2, @@ -1393,7 +1393,7 @@ local scavTurrets = {} -- Turrets table creation loop for tier, _ in pairs(Turrets) do for turret, turretInfo in pairs(Turrets[tier]) do - if (not scavTurrets[turret]) and not (Spring.GetModOptions().unit_restrictions_noair and turretInfo.type == "antiair") and not (Spring.GetModOptions().unit_restrictions_nonukes and turretInfo.type == "nuke") and not (Spring.GetModOptions().unit_restrictions_nolrpc and turretInfo.type == "lrpc") then + if (not scavTurrets[turret]) and not (SpringShared.GetModOptions().unit_restrictions_noair and turretInfo.type == "antiair") and not (SpringShared.GetModOptions().unit_restrictions_nonukes and turretInfo.type == "nuke") and not (SpringShared.GetModOptions().unit_restrictions_nolrpc and turretInfo.type == "lrpc") then scavTurrets[turret] = { minBossAnger = tierConfiguration[tier].minAnger, spawnedPerWave = turretInfo.spawnedPerWave or 1, @@ -2727,7 +2727,7 @@ end -- Settings -- Adjust these ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- local airStartAnger = 0 -- needed for air waves to work correctly. -if Spring.GetModOptions().unit_restrictions_noair then -- Disable air waves when No Air restriction is enabled +if SpringShared.GetModOptions().unit_restrictions_noair then -- Disable air waves when No Air restriction is enabled airStartAnger = 10000 end local useScum = true -- Use scum as space where turrets can spawn (requires scum gadget from Beyond All Reason) @@ -2819,7 +2819,7 @@ local highValueTargetsNames = { -- Priority targets for Scav. Must be immobile t local highValueTargets = {} for unitName, params in pairs(highValueTargetsNames) do if not UnitDefNames[unitName] then - Spring.Log(gadget:GetInfo().name, LOG.ERROR, "couldnt find unit name: " .. unitName) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, "couldnt find unit name: " .. unitName) else highValueTargets[UnitDefNames[unitName].id] = params end @@ -2833,9 +2833,9 @@ local config = { -- Don't touch this! ------------------------------------------ difficulty = difficulty, difficulties = difficulties, burrowUnitsList = BurrowUnitsList, -- burrow unit name - scavSpawnMultiplier = Spring.GetModOptions().scav_spawncountmult, - burrowSpawnType = Spring.GetModOptions().scav_scavstart, - swarmMode = Spring.GetModOptions().scav_swarmmode, + scavSpawnMultiplier = SpringShared.GetModOptions().scav_spawncountmult, + burrowSpawnType = SpringShared.GetModOptions().scav_scavstart, + swarmMode = SpringShared.GetModOptions().scav_swarmmode, spawnSquare = spawnSquare, spawnSquareIncrement = spawnSquareIncrement, scavTurrets = table.copy(scavTurrets), diff --git a/luarules/configs/timeslow_defs.lua b/luarules/configs/timeslow_defs.lua index 87f7479b020..e4aa3e13218 100644 --- a/luarules/configs/timeslow_defs.lua +++ b/luarules/configs/timeslow_defs.lua @@ -1,7 +1,7 @@ ------------------------ -- Config -if Spring.GetModOptions().emprework == true then +if SpringShared.GetModOptions().emprework == true then local MAX_SLOW_FACTOR = 0.9 -- Max slow damage on a unit = MAX_SLOW_FACTOR * current health diff --git a/luarules/gadgets.lua b/luarules/gadgets.lua index 0fd2527527f..62e1e1811bf 100644 --- a/luarules/gadgets.lua +++ b/luarules/gadgets.lua @@ -18,7 +18,7 @@ -------------------------------------------------------------------------------- local VFSMODE = VFS.ZIP_ONLY -- FIXME: ZIP_FIRST ? -if Spring.IsDevLuaEnabled() then +if SpringShared.IsDevLuaEnabled() then VFSMODE = VFS.RAW_FIRST end @@ -49,7 +49,7 @@ end if IsSyncedCode() then local devModeEnabled = string.find(string.upper(Game.gameVersion), "$VERSION", 1, true) - Spring.SetGameRulesParam("isDevMode", devModeEnabled) + SpringSynced.SetGameRulesParam("isDevMode", devModeEnabled) end -------------------------------------------------------------------------------- @@ -313,7 +313,7 @@ function gadgetHandler:Initialize() -- for k,gf in ipairs(gadgetFiles) do -- Spring.Echo('gf1 = ' .. gf) -- FIXME -- end - local doMoreYield = (Spring.Yield ~= nil) + local doMoreYield = (SpringUnsynced.Yield ~= nil) -- stuff the gadgets into unsortedGadgets for k, gf in ipairs(gadgetFiles) do -- Spring.Echo('gf2 = ' .. gf) -- FIXME @@ -321,7 +321,7 @@ function gadgetHandler:Initialize() if gadget then table.insert(unsortedGadgets, gadget) if not IsSyncedCode() and doMoreYield then - doMoreYield = Spring.Yield() + doMoreYield = SpringUnsynced.Yield() if doMoreYield == false then --GetThreadSafety == false --Spring.Echo("GadgetHandler Yield: entering critical section") end @@ -355,7 +355,7 @@ function gadgetHandler:Initialize() local gname = g.ghInfo.name local gbasename = g.ghInfo.basename - Spring.Log(LOG_SECTION, LOG.INFO, string.format("Loaded %s gadget: %-18s <%s>", gtype, gname, gbasename)) + SpringShared.Log(LOG_SECTION, LOG.INFO, string.format("Loaded %s gadget: %-18s <%s>", gtype, gname, gbasename)) end -- Since Initialize is run out of the normal callin wrapper, we -- need to reorder explicitly here. @@ -373,12 +373,12 @@ function gadgetHandler:LoadGadget(filename, overridevfsmode) local basename = Basename(filename) local text = VFS.LoadFile(filename, overridevfsmode or VFSMODE) if text == nil then - Spring.Log(LOG_SECTION, LOG.ERROR, "Failed to load: " .. filename) + SpringShared.Log(LOG_SECTION, LOG.ERROR, "Failed to load: " .. filename) return nil end local chunk, err = loadstring(text, filename) if chunk == nil then - Spring.Log(LOG_SECTION, LOG.ERROR, "Failed to load: " .. basename .. " (" .. err .. ")") + SpringShared.Log(LOG_SECTION, LOG.ERROR, "Failed to load: " .. basename .. " (" .. err .. ")") return nil end @@ -387,7 +387,7 @@ function gadgetHandler:LoadGadget(filename, overridevfsmode) setfenv(chunk, gadget) local success, err = pcall(chunk) if not success then - Spring.Log(LOG_SECTION, LOG.ERROR, "Failed to load: " .. basename .. " (" .. err .. ")") + SpringShared.Log(LOG_SECTION, LOG.ERROR, "Failed to load: " .. basename .. " (" .. err .. ")") return nil end if err == false then -- note that all "normal" gadgets return `nil` implicitly at EOF, so don't do "if not err" @@ -395,7 +395,7 @@ function gadgetHandler:LoadGadget(filename, overridevfsmode) end if gadget.GetInfo and (Platform and not Platform.check(gadget.GetInfo().depends)) then - Spring.Echo("Missing capabilities: " .. gadget:GetInfo().name .. ". Disabling.") + SpringShared.Echo("Missing capabilities: " .. gadget:GetInfo().name .. ". Disabling.") return nil end @@ -409,14 +409,14 @@ function gadgetHandler:LoadGadget(filename, overridevfsmode) err = self:ValidateGadget(gadget) if err then - Spring.Log(LOG_SECTION, LOG.ERROR, "Failed to load: " .. basename .. " (" .. err .. ")") + SpringShared.Log(LOG_SECTION, LOG.ERROR, "Failed to load: " .. basename .. " (" .. err .. ")") return nil end local knownInfo = self.knownGadgets[name] if knownInfo then if knownInfo.active then - Spring.Log(LOG_SECTION, LOG.ERROR, "Failed to load: " .. basename .. " (duplicate name)") + SpringShared.Log(LOG_SECTION, LOG.ERROR, "Failed to load: " .. basename .. " (duplicate name)") return nil end else @@ -450,7 +450,7 @@ function gadgetHandler:LoadGadget(filename, overridevfsmode) if kbytes then collectgarbage("collect") -- mark collectgarbage("collect") -- sweep - Spring.Echo("LoadGadget", filename, "delta=", collectgarbage("count") - kbytes, "total=", collectgarbage("count"), "KB, synced =", IsSyncedCode()) + SpringShared.Echo("LoadGadget", filename, "delta=", collectgarbage("count") - kbytes, "total=", collectgarbage("count"), "KB, synced =", IsSyncedCode()) end return gadget end @@ -598,11 +598,11 @@ local function SafeWrap(func, funcName) if funcName ~= "Shutdown" then gadgetHandler:RemoveGadget(g) else - Spring.Log(LOG_SECTION, LOG.ERROR, "Error in Shutdown") + SpringShared.Log(LOG_SECTION, LOG.ERROR, "Error in Shutdown") end local name = g.ghInfo.name - Spring.Log(LOG_SECTION, LOG.INFO, r1) - Spring.Log(LOG_SECTION, LOG.INFO, "Removed gadget: " .. name) + SpringShared.Log(LOG_SECTION, LOG.INFO, r1) + SpringShared.Log(LOG_SECTION, LOG.INFO, "Removed gadget: " .. name) return nil end end @@ -613,7 +613,7 @@ local function SafeWrapGadget(gadget) return elseif SAFEWRAP == 1 then if gadget.GetInfo and gadget.GetInfo().unsafe then - Spring.Log(LOG_SECTION, LOG.ERROR, "LuaUI: loaded unsafe gadget: " .. gadget.ghInfo.name) + SpringShared.Log(LOG_SECTION, LOG.ERROR, "LuaUI: loaded unsafe gadget: " .. gadget.ghInfo.name) return end end @@ -739,14 +739,14 @@ function gadgetHandler:InsertGadgetRaw(gadget) self:UpdateCallIns() if gadget.AllowCommand and not self:HasAllowCommands(gadget) then - Spring.Log("AllowCommand", LOG.WARNING, "<" .. gadget.ghInfo.basename .. "> AllowCommand defined but didn't register any commands. Autoregistering for all commands!") + SpringShared.Log("AllowCommand", LOG.WARNING, "<" .. gadget.ghInfo.basename .. "> AllowCommand defined but didn't register any commands. Autoregistering for all commands!") self:RegisterAllowCommand(gadget, CMD.ANY) end if kbytes then collectgarbage("collect") collectgarbage("collect") - Spring.Echo("Initialize", gadget.ghInfo.name, "delta=", collectgarbage("count") - kbytes, "total=", collectgarbage("count"), "KB, synced =", IsSyncedCode()) + SpringShared.Echo("Initialize", gadget.ghInfo.name, "delta=", collectgarbage("count") - kbytes, "total=", collectgarbage("count"), "KB, synced =", IsSyncedCode()) end end @@ -804,7 +804,7 @@ function gadgetHandler:UpdateCallIn(name) return res1, res2 end else - Spring.Log(LOG_SECTION, LOG.ERROR, "UpdateCallIn: " .. name .. " is not implemented") + SpringShared.Log(LOG_SECTION, LOG.ERROR, "UpdateCallIn: " .. name .. " is not implemented") end end @@ -823,7 +823,7 @@ function gadgetHandler:UpdateGadgetCallInRaw(name, g) end self:UpdateCallIn(name) else - Spring.Log(LOG_SECTION, LOG.ERROR, "UpdateGadgetCallIn: bad name: " .. name) + SpringShared.Log(LOG_SECTION, LOG.ERROR, "UpdateGadgetCallIn: bad name: " .. name) end end @@ -834,7 +834,7 @@ function gadgetHandler:RemoveGadgetCallInRaw(name, g) ArrayRemove(ciList, g) self:UpdateCallIn(name) else - Spring.Log(LOG_SECTION, LOG.ERROR, "RemoveGadgetCallIn: bad name: " .. name) + SpringShared.Log(LOG_SECTION, LOG.ERROR, "RemoveGadgetCallIn: bad name: " .. name) end end @@ -850,11 +850,11 @@ end function gadgetHandler:EnableGadgetRaw(name) local ki = self.knownGadgets[name] if not ki then - Spring.Log(LOG_SECTION, LOG.ERROR, "EnableGadget(), could not find gadget: " .. tostring(name)) + SpringShared.Log(LOG_SECTION, LOG.ERROR, "EnableGadget(), could not find gadget: " .. tostring(name)) return false end if not ki.active then - Spring.Log(LOG_SECTION, LOG.INFO, "Loading: " .. ki.filename) + SpringShared.Log(LOG_SECTION, LOG.INFO, "Loading: " .. ki.filename) local order = gadgetHandler.orderList[name] if not order or order <= 0 then self.orderList[name] = 1 @@ -871,7 +871,7 @@ end function gadgetHandler:DisableGadgetRaw(name) local ki = self.knownGadgets[name] if not ki then - Spring.Log(LOG_SECTION, LOG.ERROR, "DisableGadget(), could not find gadget: " .. tostring(name)) + SpringShared.Log(LOG_SECTION, LOG.ERROR, "DisableGadget(), could not find gadget: " .. tostring(name)) return false end if ki.active then @@ -879,7 +879,7 @@ function gadgetHandler:DisableGadgetRaw(name) if not w then return false end - Spring.Log(LOG_SECTION, LOG.INFO, "Removed: " .. ki.filename) + SpringShared.Log(LOG_SECTION, LOG.INFO, "Removed: " .. ki.filename) self:RemoveGadgetRaw(w) -- deactivate self.orderList[name] = 0 -- disable end @@ -889,7 +889,7 @@ end function gadgetHandler:ToggleGadget(name) local ki = self.knownGadgets[name] if not ki then - Spring.Log(LOG_SECTION, LOG.ERROR, "ToggleGadget(), could not find gadget: " .. tostring(name)) + SpringShared.Log(LOG_SECTION, LOG.ERROR, "ToggleGadget(), could not find gadget: " .. tostring(name)) return end if ki.active then @@ -1067,12 +1067,12 @@ end function gadgetHandler:RegisterCMDID(gadget, id) if id <= 1000 then - Spring.Log(LOG_SECTION, LOG.ERROR, "Gadget (" .. gadget.ghInfo.name .. ") " .. "tried to register a reserved CMD_ID") + SpringShared.Log(LOG_SECTION, LOG.ERROR, "Gadget (" .. gadget.ghInfo.name .. ") " .. "tried to register a reserved CMD_ID") Script.Kill("Reserved CMD_ID code: " .. id) end if self.CMDIDs[id] ~= nil then - Spring.Log(LOG_SECTION, LOG.ERROR, "Gadget (" .. gadget.ghInfo.name .. ") " .. "tried to register a duplicated CMD_ID") + SpringShared.Log(LOG_SECTION, LOG.ERROR, "Gadget (" .. gadget.ghInfo.name .. ") " .. "tried to register a duplicated CMD_ID") Script.Kill("Duplicate CMD_ID code: " .. id) end @@ -1169,7 +1169,7 @@ function gadgetHandler:RecvFromSynced(...) end function gadgetHandler:GotChatMsg(msg, player) - if player == 0 and Spring.IsCheatingEnabled() then + if player == 0 and SpringShared.IsCheatingEnabled() then local sp = "^%s*" -- start pattern local ep = "%s+(.*)" -- end pattern local s, e, match @@ -1350,14 +1350,14 @@ end function gadgetHandler:RegisterAllowCommand(gadget, cmdID) -- cmdID accepts CMD.ANY and CMD.NIL in addition to usual cmdIDs -- CMD.ANY subscribes to any command - Spring.Log("AllowCommand", LOG.INFO, "<" .. gadget.ghInfo.basename .. "> Register " .. tostring(cmdID)) + SpringShared.Log("AllowCommand", LOG.INFO, "<" .. gadget.ghInfo.basename .. "> Register " .. tostring(cmdID)) if cmdID == nil then -- use CMD.NIL instead - Spring.Log("AllowCommand", LOG.ERROR, "<" .. gadget.ghInfo.basename .. "> Invalid cmdID " .. tostring(cmdID)) + SpringShared.Log("AllowCommand", LOG.ERROR, "<" .. gadget.ghInfo.basename .. "> Invalid cmdID " .. tostring(cmdID)) return end if not gadget.AllowCommand then - Spring.Log("AllowCommand", LOG.ERROR, "<" .. gadget.ghInfo.basename .. "> No callin method") + SpringShared.Log("AllowCommand", LOG.ERROR, "<" .. gadget.ghInfo.basename .. "> No callin method") return end local cmdList = allowCommandList[cmdID] @@ -2102,7 +2102,7 @@ function gadgetHandler:SunChanged() end function gadgetHandler:Update() - local deltaTime = Spring.GetLastUpdateSeconds() + local deltaTime = SpringUnsynced.GetLastUpdateSeconds() tracy.ZoneBeginN("G:Update") for _, g in ipairs(self.UpdateList) do tracy.ZoneBeginN("G:Update:" .. g.ghInfo.name) @@ -2333,7 +2333,7 @@ end function gadgetHandler:MouseRelease(x, y, button) tracy.ZoneBeginN("G:MouseRelease") local mo = self.mouseOwner - local mx, my, lmb, mmb, rmb = Spring.GetMouseState() + local mx, my, lmb, mmb, rmb = SpringUnsynced.GetMouseState() if not (lmb or mmb or rmb) then self.mouseOwner = nil end diff --git a/luarules/gadgets/AILoader.lua b/luarules/gadgets/AILoader.lua index 93545ad4e74..2049ec05c07 100644 --- a/luarules/gadgets/AILoader.lua +++ b/luarules/gadgets/AILoader.lua @@ -11,22 +11,22 @@ function gadget:GetInfo() end -- localization -local spEcho = Spring.Echo -local spGetTeamInfo = Spring.GetTeamInfo -local spGetTeamLuaAI = Spring.GetTeamLuaAI -local spAreTeamsAllied = Spring.AreTeamsAllied -local spGetTeamStartPosition = Spring.GetTeamStartPosition -local spGetAllUnits = Spring.GetAllUnits -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetGaiaTeamID = Spring.GetGaiaTeamID() -local spGiveOrderTounit = Spring.GiveOrderToUnit -local spGiveOrderArrayTounit = Spring.GiveOrderArrayToUnit -local spGiveOrderTounitArray = Spring.GiveOrderToUnitArray -local spGiveOrderArrayTounitArray = Spring.GiveOrderArrayToUnitArray -local spGetUnitDefID = Spring.GetUnitDefID -local spGetGameFrame = Spring.GetGameFrame -local teamList = Spring.GetTeamList() +local spEcho = SpringShared.Echo +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetTeamLuaAI = SpringShared.GetTeamLuaAI +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spGetTeamStartPosition = SpringShared.GetTeamStartPosition +local spGetAllUnits = SpringShared.GetAllUnits +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetGaiaTeamID = SpringShared.GetGaiaTeamID() +local spGiveOrderTounit = SpringSynced.GiveOrderToUnit +local spGiveOrderArrayTounit = SpringSynced.GiveOrderArrayToUnit +local spGiveOrderTounitArray = SpringSynced.GiveOrderToUnitArray +local spGiveOrderArrayTounitArray = SpringSynced.GiveOrderArrayToUnitArray +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetGameFrame = SpringShared.GetGameFrame +local teamList = SpringShared.GetTeamList() local syncTables = {} local cmdCounter = { ii = 0, zi = 0, iz = 0, zz = 0, old = 0 } local string_sub = string.sub diff --git a/luarules/gadgets/activity_broadcast.lua b/luarules/gadgets/activity_broadcast.lua index 302319ca560..cddcd34ebb5 100644 --- a/luarules/gadgets/activity_broadcast.lua +++ b/luarules/gadgets/activity_broadcast.lua @@ -38,10 +38,10 @@ else -- unsynced -------------------------------------------------------------------------------- - local GetMouseState = Spring.GetMouseState - local GetLastUpdateSeconds = Spring.GetLastUpdateSeconds - local SendLuaRulesMsg = Spring.SendLuaRulesMsg - local GetCameraState = Spring.GetCameraState + local GetMouseState = SpringUnsynced.GetMouseState + local GetLastUpdateSeconds = SpringUnsynced.GetLastUpdateSeconds + local SendLuaRulesMsg = SpringUnsynced.SendLuaRulesMsg + local GetCameraState = SpringUnsynced.GetCameraState local activity = false local old_mx, old_my = 0, 0 diff --git a/luarules/gadgets/ai/STAI/ai.lua b/luarules/gadgets/ai/STAI/ai.lua index befd4fb953c..c3986140583 100644 --- a/luarules/gadgets/ai/STAI/ai.lua +++ b/luarules/gadgets/ai/STAI/ai.lua @@ -10,6 +10,6 @@ end function STAI:test() for i, v in pairs(STAI) do - Spring.Echo("H.I.V.E. ST AI module:", i, v) + SpringShared.Echo("H.I.V.E. ST AI module:", i, v) end end diff --git a/luarules/gadgets/ai/STAI/buildingshst.lua b/luarules/gadgets/ai/STAI/buildingshst.lua index 5878e2d797b..57cb732d0ec 100644 --- a/luarules/gadgets/ai/STAI/buildingshst.lua +++ b/luarules/gadgets/ai/STAI/buildingshst.lua @@ -220,8 +220,8 @@ function BuildingsHST:FindClosestBuildSite(unittype, bx, by, bz, minDist, maxDis end function BuildingsHST:CanBuildHere(unittype, x, y, z) -- returns boolean - local newX, newY, newZ = Spring.Pos2BuildPos(unittype:ID(), x, y, z) - local buildable = Spring.TestBuildOrder(unittype:ID(), newX, newY, newZ, 1) --TODO check if it really necessary + local newX, newY, newZ = SpringShared.Pos2BuildPos(unittype:ID(), x, y, z) + local buildable = SpringShared.TestBuildOrder(unittype:ID(), newX, newY, newZ, 1) --TODO check if it really necessary self:EchoDebug("canbuildhere", unittype:Name(), newX, newY, newZ, buildable) if buildable == 0 then diff --git a/luarules/gadgets/ai/STAI/damagehst.lua b/luarules/gadgets/ai/STAI/damagehst.lua index f86a5a847b7..45231537ada 100644 --- a/luarules/gadgets/ai/STAI/damagehst.lua +++ b/luarules/gadgets/ai/STAI/damagehst.lua @@ -158,8 +158,8 @@ function DamageHST:VisualDBG() local pos1, pos2 = api.Position(), api.Position() --z,api.Position(),api.Position(),api.Position() pos1.x, pos1.z = p.x - cellElmosHalf, p.z - cellElmosHalf pos2.x, pos2.z = p.x + cellElmosHalf, p.z + cellElmosHalf - pos1.y = Spring.GetGroundHeight(pos1.x, pos1.z) - pos2.y = Spring.GetGroundHeight(pos2.x, pos2.z) + pos1.y = SpringShared.GetGroundHeight(pos1.x, pos1.z) + pos2.y = SpringShared.GetGroundHeight(pos2.x, pos2.z) map:DrawRectangle(p, pos2, colours.blue, cell.defenderThreat, false, ch) map:DrawRectangle(pos1, p, colours.red, cell.attackerThreat, false, ch) map:DrawPoint(p, colours.black, cell.X .. ":" .. cell.Z .. "=" .. cell.nodeCostIndex, ch) diff --git a/luarules/gadgets/ai/STAI/ecohst.lua b/luarules/gadgets/ai/STAI/ecohst.lua index aabad930617..028417e1369 100644 --- a/luarules/gadgets/ai/STAI/ecohst.lua +++ b/luarules/gadgets/ai/STAI/ecohst.lua @@ -16,8 +16,8 @@ function EcoHST:Init() self.samples = {} self.Index = 1 - local McurrentLevel, Mstorage, Mpull, Mincome, Mexpense, Mshare, Msent, Mreceived = Spring.GetTeamResources(self.ai.id, "metal") - local EcurrentLevel, Estorage, Epull, Eincome, Eexpense, Eshare, Esent, Ereceived = Spring.GetTeamResources(self.ai.id, "energy") + local McurrentLevel, Mstorage, Mpull, Mincome, Mexpense, Mshare, Msent, Mreceived = SpringShared.GetTeamResources(self.ai.id, "metal") + local EcurrentLevel, Estorage, Epull, Eincome, Eexpense, Eshare, Esent, Ereceived = SpringShared.GetTeamResources(self.ai.id, "energy") for i = 1, average do for idx, name in pairs(self.resourceNames) do self.samples[i] = {} @@ -56,7 +56,7 @@ function EcoHST:Update() return end local currentSample = self.samples[self.Index] - local currentLevel, storage, pull, income, expense, share, sent, received = Spring.GetTeamResources(self.ai.id, "metal") + local currentLevel, storage, pull, income, expense, share, sent, received = SpringShared.GetTeamResources(self.ai.id, "metal") local M = currentSample.Metal M.reserves = currentLevel M.capacity = storage @@ -67,7 +67,7 @@ function EcoHST:Update() M.sent = sent M.received = received - currentLevel, storage, pull, income, expense, share, sent, received = Spring.GetTeamResources(self.ai.id, "energy") + currentLevel, storage, pull, income, expense, share, sent, received = SpringShared.GetTeamResources(self.ai.id, "energy") local E = currentSample.Energy E.reserves = currentLevel E.capacity = storage diff --git a/luarules/gadgets/ai/STAI/labsbst.lua b/luarules/gadgets/ai/STAI/labsbst.lua index b2b3b3d0e7c..84e6fdfd3e1 100644 --- a/luarules/gadgets/ai/STAI/labsbst.lua +++ b/luarules/gadgets/ai/STAI/labsbst.lua @@ -45,7 +45,7 @@ end function LabsBST:ExitCheck() for i, v in pairs(self.ai.armyhst.unitTable[self.name].unitsCanBuild) do - if not Spring.TestMoveOrder(self.ai.armyhst.unitTable[v].defId, self.position.x, self.position.y, self.position.z) then + if not SpringShared.TestMoveOrder(self.ai.armyhst.unitTable[v].defId, self.position.x, self.position.y, self.position.z) then self:EchoDebug("exitcheck failed", self.name) self.ai.cleanhst.cleanableByID[self.id] = self.id self.exitClosed = true @@ -116,7 +116,7 @@ function LabsBST:Update() end local f = self.game:Frame() self:preFilter() -- work or no resource?? - if Spring.GetFactoryCommandCount(self.id) > 1 then + if SpringShared.GetFactoryCommandCount(self.id) > 1 then return end -- factory already work self:GetAmpOrGroundWeapon() -- need more amph to attack in this map? diff --git a/luarules/gadgets/ai/STAI/loshst.lua b/luarules/gadgets/ai/STAI/loshst.lua index b2733b1e9d1..663ebbd93ca 100644 --- a/luarules/gadgets/ai/STAI/loshst.lua +++ b/luarules/gadgets/ai/STAI/loshst.lua @@ -194,8 +194,8 @@ function LosHST:cleanEnemy(id) end function LosHST:viewPos(upos) - local LosOrRadar, inLos, inRadar, jammed = Spring.GetPositionLosState(upos.x, upos.y, upos.z, self.ai.allyId) - if Spring.IsPosInAirLos(upos.x, upos.y, upos.z, self.ai.allyId) then + local LosOrRadar, inLos, inRadar, jammed = SpringShared.GetPositionLosState(upos.x, upos.y, upos.z, self.ai.allyId) + if SpringShared.IsPosInAirLos(upos.x, upos.y, upos.z, self.ai.allyId) then return 1 end if inLos and upos.y < 0 then @@ -225,7 +225,7 @@ function LosHST:setPosLayer(unitName, Pos) if (ut.mtype == "sub" or ut.mtype == "amp") and Pos.y < -5 then return -1 end - if Spring.GetGroundHeight(Pos.x, Pos.z) < 0 then --TEST WARNING + if SpringShared.GetGroundHeight(Pos.x, Pos.z) < 0 then --TEST WARNING floating = true end return 0, floating @@ -241,7 +241,7 @@ function LosHST:setPosLayer2(unitName, x, y, z) if (ut.mtype == "sub" or ut.mtype == "amp") and y < -5 then return -1 end - if Spring.GetGroundHeight(x, z) < 0 then --TEST WARNING + if SpringShared.GetGroundHeight(x, z) < 0 then --TEST WARNING floating = true end return 0, floating @@ -371,7 +371,7 @@ function LosHST:setCellRadar(grid, unit, X, Z) CELL.metal = CELL.metal + CELL.metalMedia local M = CELL.metalMedia --local uPos = unit:GetPosition() - local speedX, speedY, speedZ, SPEED = Spring.GetUnitVelocity(unit:ID()) + local speedX, speedY, speedZ, SPEED = SpringShared.GetUnitVelocity(unit:ID()) --local target = {x = uPos.x+( speedX*100),y = uPos.y,z = uPos.z + (speedZ*100)} -- NEVER USED! CELL.SPEED = CELL.SPEED + SPEED @@ -443,7 +443,7 @@ function LosHST:setCellLos(grid, unit, X, Z) local M = ut.metalCost local mobile = ut.speed > 0 local layer = self:setPosLayer2(ut.name, x, y, z) - local speedX, speedY, speedZ, SPEED = Spring.GetUnitVelocity(unit:ID()) + local speedX, speedY, speedZ, SPEED = SpringShared.GetUnitVelocity(unit:ID()) --local target = {x = uPos.x+( speedX*100),y = uPos.y,z = uPos.z + (speedZ*100)} -- NEVER USED CELL.SPEED = CELL.SPEED + SPEED CELL.metal = CELL.metal + M @@ -561,8 +561,8 @@ function LosHST:Draw() local pos1, pos2 = api.Position(), api.Position() --z,api.Position(),api.Position(),api.Position() pos1.x, pos1.z = p.x - cellElmosHalf, p.z - cellElmosHalf pos2.x, pos2.z = p.x + cellElmosHalf, p.z + cellElmosHalf - pos1.y = Spring.GetGroundHeight(pos1.x, pos1.z) - pos2.y = Spring.GetGroundHeight(pos2.x, pos2.z) + pos1.y = SpringShared.GetGroundHeight(pos1.x, pos1.z) + pos2.y = SpringShared.GetGroundHeight(pos2.x, pos2.z) self:EchoDebug("drawing", pos1.x, pos1.z, pos2.x, pos2.z) if cell.ENEMY_BALANCE > 0 then map:DrawRectangle(pos1, pos2, colours.balance, cell.ENEMY_BALANCE, false, ch) @@ -593,8 +593,8 @@ function LosHST:Draw() local pos1, pos2 = api.Position(), api.Position() --z,api.Position(),api.Position(),api.Position() pos1.x, pos1.z = p.x - cellElmosHalf, p.z - cellElmosHalf pos2.x, pos2.z = p.x + cellElmosHalf, p.z + cellElmosHalf - pos1.y = Spring.GetGroundHeight(pos1.x, pos1.z) - pos2.y = Spring.GetGroundHeight(pos2.x, pos2.z) + pos1.y = SpringShared.GetGroundHeight(pos1.x, pos1.z) + pos2.y = SpringShared.GetGroundHeight(pos2.x, pos2.z) self:EchoDebug("drawing", pos1.x, pos1.z, pos2.x, pos2.z) if cell.ENEMY_BALANCE > 0 then map:DrawRectangle(pos1, pos2, colours.p, cell.ENEMY_BALANCE, false, ch) diff --git a/luarules/gadgets/ai/STAI/maphst.lua b/luarules/gadgets/ai/STAI/maphst.lua index 74f8ff2666b..10b735c971e 100644 --- a/luarules/gadgets/ai/STAI/maphst.lua +++ b/luarules/gadgets/ai/STAI/maphst.lua @@ -13,7 +13,7 @@ local pathGraphs = {} local mCeil = math.ceil function MapHST:Init() - local rules_param_mex_count = Spring.GetGameRulesParam("mex_count") + local rules_param_mex_count = SpringShared.GetGameRulesParam("mex_count") self:EchoDebug("games rules param mex_count:", rules_param_mex_count) self.DebugEnabled = false @@ -124,7 +124,7 @@ function MapHST:InitPathCost() self.heightMapZ = (self.elmoMapSizeZ / 512) -- self:EchoDebug('self.heightMapX',self.heightMapX,'self.heightMapZ',self.heightMapZ) -- self:EchoDebug(Spring.GetPathNodeCosts(id)) - self:EchoDebug("INIT new array node cost", Spring.InitPathNodeCostsArray(game:GetTeamID(), self.heightMapX, self.heightMapZ)) + self:EchoDebug("INIT new array node cost", SpringShared.InitPathNodeCostsArray(game:GetTeamID(), self.heightMapX, self.heightMapZ)) local cost = 0 local index = 1 local heightpow = self.heightMapX * self.heightMapZ @@ -135,13 +135,13 @@ function MapHST:InitPathCost() for j = 1, self.heightMapZ do cost = (cost + math.abs(index + (heightpow / 2) - heightpow) * -1) + heightpow / 2 - Spring.SetPathNodeCost(game:GetTeamID(), index, cost) + SpringShared.SetPathNodeCost(game:GetTeamID(), index, cost) --self:EchoDebug('init path node cost',i,j,Spring.GetPathNodeCost(id,i,j)) cost = 0 index = index + 1 end end - self:EchoDebug("SET new array node layer non sync", Spring.SetPathNodeCosts(game:GetTeamID())) + self:EchoDebug("SET new array node layer non sync", SpringShared.SetPathNodeCosts(game:GetTeamID())) -- self:EchoDebug(#Spring.GetPathNodeCosts(game:GetTeamID())) -- self:EchoDebug(Spring.SetPathNodeCost(game:GetTeamID(),0,123)) -- self:EchoDebug(Spring.SetPathNodeCost(game:GetTeamID(),1,111)) @@ -267,7 +267,7 @@ function MapHST:NewCell(gx, gz) local z = (gz * self.gridSize) - self.gridSizeHalf local cellPos = {} cellPos.x, cellPos.z = x, z - cellPos.y = Spring.GetGroundHeight(x, z) + cellPos.y = SpringShared.GetGroundHeight(x, z) self:isInMap(cellPos) --move here ,is in map!! local cell = {} cell.POS = cellPos --the cell position @@ -341,7 +341,7 @@ function MapHST:moveLayerTest(pos) --check where units can stay or not if not self.topology[layer] then self.topology[layer] = {} end - if Spring.TestMoveOrder(self.ai.armyhst.unitTable[unitName].defId, pos.x, pos.y, pos.z, nil, nil, nil, true, false, true) then + if SpringShared.TestMoveOrder(self.ai.armyhst.unitTable[unitName].defId, pos.x, pos.y, pos.z, nil, nil, nil, true, false, true) then layers[layer] = 0 else layers[layer] = false @@ -493,7 +493,7 @@ function MapHST:hotSpotter() end x = x / items z = z / items - y = Spring.GetGroundHeight(x, z) + y = SpringShared.GetGroundHeight(x, z) table.insert(self.hotSpots, { x = x, y = y, z = z, weight = items }) --Spring.MarkerAddPoint(x,y,z,'hot ' ..items ) end @@ -1057,7 +1057,7 @@ function MapHST:GetPathGraph(mtype, targetNodeSize) position.x = bestX position.z = bestZ end - position.y = Spring.GetGroundHeight(x, z) + position.y = SpringShared.GetGroundHeight(x, z) local nodeX = mCeil(cx / cellsPerNodeSide) local nodeY = mCeil(cz / cellsPerNodeSide) local node = { x = nodeX, y = nodeY, id = id, position = position } diff --git a/luarules/gadgets/ai/STAI/reclaimbst.lua b/luarules/gadgets/ai/STAI/reclaimbst.lua index 1e40aa2cd1a..fad6be3b1e2 100644 --- a/luarules/gadgets/ai/STAI/reclaimbst.lua +++ b/luarules/gadgets/ai/STAI/reclaimbst.lua @@ -11,7 +11,7 @@ end function ReclaimBST:Act() local timearea = 10000 if self.unit:Internal():CurrentCommand() ~= CMD.RECLAIM then - if #Spring.GetFeaturesInCylinder(self.position.x, self.position.z, 10000) > 0 then + if #SpringShared.GetFeaturesInCylinder(self.position.x, self.position.z, 10000) > 0 then self.ai.tool:GiveOrder(self.unit:Internal():ID(), CMD.RECLAIM, { self.position.x, self.position.y, self.position.z, timearea }, 0, "1-1") end diff --git a/luarules/gadgets/ai/STAI/schedulerHST.lua b/luarules/gadgets/ai/STAI/schedulerHST.lua index 7bd63d05e83..c1b267d9388 100644 --- a/luarules/gadgets/ai/STAI/schedulerHST.lua +++ b/luarules/gadgets/ai/STAI/schedulerHST.lua @@ -11,9 +11,9 @@ end function SchedulerHST:Init() self.DebugEnabled = false self.AIs = {} - local teams = Spring.GetTeamList() + local teams = SpringShared.GetTeamList() for index, id in pairs(teams) do - local luaAI = Spring.GetTeamLuaAI(id) + local luaAI = SpringShared.GetTeamLuaAI(id) if luaAI == "STAI" then table.insert(self.AIs, id) end diff --git a/luarules/gadgets/ai/STAI/scoutbst.lua b/luarules/gadgets/ai/STAI/scoutbst.lua index 96eb70c2c92..821afee2ab6 100644 --- a/luarules/gadgets/ai/STAI/scoutbst.lua +++ b/luarules/gadgets/ai/STAI/scoutbst.lua @@ -152,7 +152,7 @@ function ScoutBST:Scouting() end function ScoutBST:ImmediateEnemy() - local nearestEnemy = Spring.GetUnitNearestEnemy(self.id, self.ai.armyhst.unitTable[self.name].sightDistance, true) + local nearestEnemy = SpringShared.GetUnitNearestEnemy(self.id, self.ai.armyhst.unitTable[self.name].sightDistance, true) if nearestEnemy then local enemyPos = game:GetUnitByID(nearestEnemy):GetPosition() diff --git a/luarules/gadgets/ai/Shard/unithandler.lua b/luarules/gadgets/ai/Shard/unithandler.lua index 15e63c47ebc..b5a1f863e9a 100644 --- a/luarules/gadgets/ai/Shard/unithandler.lua +++ b/luarules/gadgets/ai/Shard/unithandler.lua @@ -165,7 +165,7 @@ end function UnitHandler:Update() for k, v in pairs(self.myActiveUnits) do if ShardSpringLua then - local ux, uy, uz = Spring.GetUnitPosition(v:Internal():ID()) + local ux, uy, uz = SpringShared.GetUnitPosition(v:Internal():ID()) if not ux then -- game:SendToConsole(self.ai.id, "nil unit position", v:Internal():ID(), v:Internal():Name(), k) self.myActiveUnits[k] = nil diff --git a/luarules/gadgets/ai/shard_runtime/aibase.lua b/luarules/gadgets/ai/shard_runtime/aibase.lua index ba3a8dbdd5d..fa792fb063a 100644 --- a/luarules/gadgets/ai/shard_runtime/aibase.lua +++ b/luarules/gadgets/ai/shard_runtime/aibase.lua @@ -84,7 +84,7 @@ function AIBase:EchoDebug(...) end if tracy then - Spring.Echo("Enabled Tracy support for AIBase") + SpringShared.Echo("Enabled Tracy support for AIBase") AIBase.lastGCinfo = 0 local logRAM = true --local function tracyZoneBeginMem() return end diff --git a/luarules/gadgets/ai/shard_runtime/shardai.lua b/luarules/gadgets/ai/shard_runtime/shardai.lua index b8a236dfa80..d6c2590d3d8 100644 --- a/luarules/gadgets/ai/shard_runtime/shardai.lua +++ b/luarules/gadgets/ai/shard_runtime/shardai.lua @@ -10,7 +10,7 @@ local function tracyZoneEndMem() end if tracy then - Spring.Echo("Enabled Tracy support for STAI") + SpringShared.Echo("Enabled Tracy support for STAI") tracyZoneBeginMem = function(fname) if logRAM then lastGCinfo = gcinfo() diff --git a/luarules/gadgets/ai/shard_runtime/spring_lua/boot.lua b/luarules/gadgets/ai/shard_runtime/spring_lua/boot.lua index 1ceb354831d..2eff2e7aa58 100644 --- a/luarules/gadgets/ai/shard_runtime/spring_lua/boot.lua +++ b/luarules/gadgets/ai/shard_runtime/spring_lua/boot.lua @@ -33,9 +33,9 @@ function shard_generate_include_func(runtime_path, ai_path) return VFS.Include(file) end end - Spring.Echo("Failed to load " .. file .. " we attempted to load the first of the following:") + SpringShared.Echo("Failed to load " .. file .. " we attempted to load the first of the following:") for index, file in ipairs(candidates) do - Spring.Echo(index .. ": " .. file) + SpringShared.Echo(index .. ": " .. file) end return nil end @@ -50,7 +50,7 @@ function shard_include(file) if VFS.FileExists(runtime_file) then return VFS.Include(runtime_file) end - Spring.Echo("Failed to load " .. runtime_file) + SpringShared.Echo("Failed to load " .. runtime_file) return end diff --git a/luarules/gadgets/ai/shard_runtime/spring_lua/damage.lua b/luarules/gadgets/ai/shard_runtime/spring_lua/damage.lua index 8288cd40528..9a70dd615a8 100644 --- a/luarules/gadgets/ai/shard_runtime/spring_lua/damage.lua +++ b/luarules/gadgets/ai/shard_runtime/spring_lua/damage.lua @@ -2,8 +2,8 @@ ShardSpringDamage = class(function(a) -- end) -local spGetGameFrame = Spring.GetGameFrame -local spGetProjectileDirection = Spring.GetProjectileDirection +local spGetGameFrame = SpringShared.GetGameFrame +local spGetProjectileDirection = SpringShared.GetProjectileDirection function ShardSpringDamage:Init(damage, weaponDefID, paralyzer, projectileID, engineAttacker) self.damage = damage diff --git a/luarules/gadgets/ai/shard_runtime/spring_lua/feature.lua b/luarules/gadgets/ai/shard_runtime/spring_lua/feature.lua index 405a9bd7b2b..2d004f73b77 100644 --- a/luarules/gadgets/ai/shard_runtime/spring_lua/feature.lua +++ b/luarules/gadgets/ai/shard_runtime/spring_lua/feature.lua @@ -5,7 +5,7 @@ end) function ShardSpringFeature:Init(id) self.id = id - self.defID = Spring.GetFeatureDefID(id) + self.defID = SpringShared.GetFeatureDefID(id) self.def = FeatureDefs[self.defID] self.name = self.def.name end @@ -19,6 +19,6 @@ function ShardSpringFeature:Name() end function ShardSpringFeature:GetPosition() - local x, y, z = Spring.GetFeaturePosition(self.id) + local x, y, z = SpringShared.GetFeaturePosition(self.id) return { x = x, y = y, z = z } end diff --git a/luarules/gadgets/ai/shard_runtime/spring_lua/game.lua b/luarules/gadgets/ai/shard_runtime/spring_lua/game.lua index 68bdf8eb8ce..c82496451b1 100644 --- a/luarules/gadgets/ai/shard_runtime/spring_lua/game.lua +++ b/luarules/gadgets/ai/shard_runtime/spring_lua/game.lua @@ -3,27 +3,27 @@ local game = {} -- prints 'message' to ingame chat console function game:SendToConsole(...) - Spring.Echo(...) + SpringShared.Echo(...) return true end function game:Frame() -- returns int/game frame number - return Spring.GetGameFrame() -- Spring Gadget API + return SpringShared.GetGameFrame() -- Spring Gadget API end function game:Test() -- debug - Spring.Echo("Testing API") + SpringShared.Echo("Testing API") return true end function game:IsPaused() -- if the game is paused, returns true - local _, _, paused = Spring.GetGameSpeed() + local _, _, paused = SpringUnsynced.GetGameSpeed() return paused end function game:GetTypeByName(typename) -- returns unittype if not UnitDefNames[typename] then - Spring.Echo('shard: debug: could not find "' .. typename .. '" in UnitDefNames') + SpringShared.Echo('shard: debug: could not find "' .. typename .. '" in UnitDefNames') return nil end local def = UnitDefNames[typename] @@ -32,7 +32,7 @@ end function game:GetUnitLos(id, bitmask) bitmask = bitmask or true - return Spring.GetUnitLosState(id, self.ai.allyId, bitmask) + return SpringShared.GetUnitLosState(id, self.ai.allyId, bitmask) end @@ -59,19 +59,19 @@ function game:GetAllyTeamID() end function game:getUnitsInCylinder(pos, range) - return Spring.GetUnitsInCylinder(pos.x, pos.z, range, team) + return SpringShared.GetUnitsInCylinder(pos.x, pos.z, range, team) end function game:GetTeamUnitDefCount(team, unitDef) - return Spring.GetTeamUnitDefCount(team, unitDef) + return SpringShared.GetTeamUnitDefCount(team, unitDef) end function game:GetTeamUnitsByDefs(team, unitDef) - return Spring.GetTeamUnitsByDefs(team, unitDef) + return SpringShared.GetTeamUnitsByDefs(team, unitDef) end function game:GetUnitSeparation(Id1, Id2, d2d, surface) - return Spring.GetUnitSeparation(Id1, Id2, d2d, surface) + return SpringShared.GetUnitSeparation(Id1, Id2, d2d, surface) end function game:GetEnemies() @@ -121,7 +121,7 @@ function game:GameName() -- returns the shortname of this game end function game:AddMarker(position, label) -- adds a marker - Spring.MarkerAddPoint(position.x, position.y, position.z, label) + SpringUnsynced.MarkerAddPoint(position.x, position.y, position.z, label) return true end -- gadgetHandler:AddSyncAction('ShardDrawDisplay', sdDisplay) @@ -154,7 +154,7 @@ function game:SendToContent(stringvar) -- returns a string passed from any lua g end function game:GetResource(idx) -- returns a Resource object - local currentLevel, storage, pull, income, expense, share, sent, received = Spring.GetTeamResources(self.ai.id, Shard.resourceIds[idx]) + local currentLevel, storage, pull, income, expense, share, sent, received = SpringShared.GetTeamResources(self.ai.id, Shard.resourceIds[idx]) return Shard:shardify_resource({ currentLevel = currentLevel, storage = storage, pull = pull, income = income, expense = expense, share = share, sent = sent, received = received }) end @@ -164,7 +164,7 @@ end function game:GetResourceByName(name) -- returns a Resource object, takes the name of the resource name = string.lower(name) - local currentLevel, storage, pull, income, expense, share, sent, received = Spring.GetTeamResources(self.ai.id, name) + local currentLevel, storage, pull, income, expense, share, sent, received = SpringShared.GetTeamResources(self.ai.id, name) return Shard:shardify_resource({ currentLevel = currentLevel, storage = storage, pull = pull, income = income, expense = expense, share = share, sent = sent, received = received }) end @@ -179,11 +179,11 @@ end function game:SendLuaRulesMessage(message) -- sends a message to the engine to give an order message = "@Shard" .. message .. "Shard@" - Spring.SendLuaRulesMsg(message) + SpringUnsynced.SendLuaRulesMsg(message) end function game:Pause() -- pauses the game - Spring.SendCommands("pause") + SpringUnsynced.SendCommands("pause") end function game:GetResources() -- returns a table of Resource objects, takes the name of the resource diff --git a/luarules/gadgets/ai/shard_runtime/spring_lua/geo.lua b/luarules/gadgets/ai/shard_runtime/spring_lua/geo.lua index 70431ca966e..01158f3e7a1 100644 --- a/luarules/gadgets/ai/shard_runtime/spring_lua/geo.lua +++ b/luarules/gadgets/ai/shard_runtime/spring_lua/geo.lua @@ -1,13 +1,13 @@ local function GetGeos() local geos = {} local i = 1 - local features = Spring.GetAllFeatures() + local features = SpringShared.GetAllFeatures() for ct = 1, #features do local featureID = features[ct] - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if FeatureDefs[featureDefID].geoThermal == true then - local x, y, z = Spring.GetFeaturePosition(featureID) - local spot = { x = x, z = z, y = Spring.GetGroundHeight(x, z) } + local x, y, z = SpringShared.GetFeaturePosition(featureID) + local spot = { x = x, z = z, y = SpringShared.GetGroundHeight(x, z) } geos[i] = spot i = i + 1 end diff --git a/luarules/gadgets/ai/shard_runtime/spring_lua/map.lua b/luarules/gadgets/ai/shard_runtime/spring_lua/map.lua index 43007fbb149..f583b8a2def 100644 --- a/luarules/gadgets/ai/shard_runtime/spring_lua/map.lua +++ b/luarules/gadgets/ai/shard_runtime/spring_lua/map.lua @@ -7,7 +7,7 @@ local math_sin = math.sin local math_random = math.random local math_sqrt = math.sqrt local math_pi = math.pi -local Spring_GetGroundHeight = Spring.GetGroundHeight +local Spring_GetGroundHeight = SpringShared.GetGroundHeight -- function map:FindClosestBuildSite(unittype,builderpos, searchradius, minimumdistance) -- function map:CanBuildHere(unittype,position) -- function map:GetMapFeatures() @@ -77,14 +77,14 @@ function map:FindClosestBuildSite(unittype, builderpos, searchradius, minimumdis end function map:CanBuildHere(unittype, position) -- returns boolean - local newX, newY, newZ = Spring.Pos2BuildPos(unittype:ID(), position.x, position.y, position.z) - local blocked = Spring.TestBuildOrder(unittype:ID(), newX, newY, newZ, 1) == 0 + local newX, newY, newZ = SpringShared.Pos2BuildPos(unittype:ID(), position.x, position.y, position.z) + local blocked = SpringShared.TestBuildOrder(unittype:ID(), newX, newY, newZ, 1) == 0 -- Spring.Echo(unittype:Name(), newX, newY, newZ, blocked) return not blocked, { x = newX, y = newY, z = newZ } end function map:TestMoveOrder(UnitDefID, p) -- returns boolean - return Spring.TestMoveOrder(UnitDefID, p.x, p.z, p.y) + return SpringShared.TestMoveOrder(UnitDefID, p.x, p.z, p.y) end function map:RequestPath(moveClass, POS1, POS2, radius) -- returns a path @@ -98,7 +98,7 @@ function map:RequestPath(moveClass, POS1, POS2, radius) -- returns a path --Spring.Echo('RequestPath receive a nil POS1',POS1,POS2) return end - local metapath = Spring.RequestPath(moveClass, POS1.x, POS1.y, POS1.z, POS2.x, POS2.y, POS2.z, radius) + local metapath = SpringShared.RequestPath(moveClass, POS1.x, POS1.y, POS1.z, POS2.x, POS2.y, POS2.z, radius) if not metapath then --Spring.Echo(unitName,'no path found',POS1.x,POS1.z,POS2.x,POS2.z) return @@ -121,7 +121,7 @@ function map:GetPathObject(moveID, start_x, start_y, start_z, end_x, end_y, end_ return end radius = radius or 8 - return Spring.RequestPath(moveID, start_x, start_y, start_z, end_x, end_y, end_z, radius) + return SpringShared.RequestPath(moveID, start_x, start_y, start_z, end_x, end_y, end_z, radius) end function map:TestPath(moveID, start_x, start_y, start_z, end_x, end_y, end_z, radius, uname) @@ -191,7 +191,7 @@ function map:TestPath(moveID, start_x, start_y, start_z, end_x, end_y, end_z, ra end]] local wp = self:GetPathWaypoints(pathObject) wp = wp[#wp] - wp[2] = Spring.GetGroundHeight(wp[1], wp[3]) + wp[2] = SpringShared.GetGroundHeight(wp[1], wp[3]) local x = end_x - wp[1] local y = end_y - wp[2] local z = end_z - wp[3] @@ -215,7 +215,7 @@ function map:PathTest(moveID, start_x, start_y, start_z, end_x, end_y, end_z, ra return end radius = radius or 8 - if Spring.RequestPath(moveID, start_x, start_y, start_z, end_x, end_y, end_z, radius) then + if SpringShared.RequestPath(moveID, start_x, start_y, start_z, end_x, end_y, end_z, radius) then return true end end @@ -227,7 +227,7 @@ function map:GetPathWaypoints(pathObject) return pathObject:GetPathWayPoints() end function map:GetMapFeatures() - local fv = Spring.GetAllFeatures() + local fv = SpringShared.GetAllFeatures() if not fv then return {} end @@ -239,7 +239,7 @@ function map:GetMapFeatures() end function map:GetMapFeaturesAt(position, radius) - local fv = Spring.GetFeaturesInSphere(position.x, position.y, position.z, radius) + local fv = SpringShared.GetFeaturesInSphere(position.x, position.y, position.z, radius) if not fv then return {} end @@ -305,7 +305,7 @@ function map:MapName() -- returns the name of this map end function map:GetWind() - local _, _, _, strenght = Spring.GetWind() + local _, _, _, strenght = SpringShared.GetWind() return strenght end @@ -323,17 +323,17 @@ function map:MaximumWindSpeed() -- returns maximum wind speed end function map:MaximumHeight() -- returns maximum map height - local minHeight, maxHeight = Spring.GetGroundExtremes() + local minHeight, maxHeight = SpringShared.GetGroundExtremes() return maxHeight end function map:MinimumHeight() -- returns minimum map height - local minHeight, maxHeight = Spring.GetGroundExtremes() + local minHeight, maxHeight = SpringShared.GetGroundExtremes() return minHeight end function map:GetGroundHeight(x, z) - return Spring.GetGroundHeight(x, z) + return SpringShared.GetGroundHeight(x, z) end function map:TidalStrength() -- returns tidal strength diff --git a/luarules/gadgets/ai/shard_runtime/spring_lua/metal.lua b/luarules/gadgets/ai/shard_runtime/spring_lua/metal.lua index 2595c171326..22d294a02ec 100644 --- a/luarules/gadgets/ai/shard_runtime/spring_lua/metal.lua +++ b/luarules/gadgets/ai/shard_runtime/spring_lua/metal.lua @@ -8,12 +8,12 @@ local sqRootThree = math.sqrt(3) local halfHexHeight = math.ceil((sqRootThree * extractorRadiusMetal) / 2) local halfExtractorRadiusMetal = math.ceil(extractorRadiusMetal / 2) -Spring.Echo("STAI metal map", metalmapSizeX, metalmapSizeZ, metalmapSizeX * metalmapSizeZ, extractorRadiusMetal, maxSpotArea, minSpotArea, halfHexHeight, halfExtractorRadiusMetal) +SpringShared.Echo("STAI metal map", metalmapSizeX, metalmapSizeZ, metalmapSizeX * metalmapSizeZ, extractorRadiusMetal, maxSpotArea, minSpotArea, halfHexHeight, halfExtractorRadiusMetal) local mCeil = math.ceil -local spGetMetalAmount = Spring.GetMetalAmount -local spGetGroundHeight = Spring.GetGroundHeight +local spGetMetalAmount = SpringShared.GetMetalAmount +local spGetGroundHeight = SpringShared.GetGroundHeight local isInBlob = {} local blobs = {} @@ -233,7 +233,7 @@ local function GetSpots() end end end - Spring.Echo(#blobs, "blobs spots") + SpringShared.Echo(#blobs, "blobs spots") -- isInBlob = {} local spots = {} local spotsCount = 0 @@ -260,7 +260,7 @@ local function GetSpots() z = mCeil(z) CirclePack(x, z, id) local blobSpots = spotsInBlob[id] - Spring.Echo(#blobSpots, "spots in blob", id) + SpringShared.Echo(#blobSpots, "spots in blob", id) for i = 1, #blobSpots do local spot = blobSpots[i] spotsCount = spotsCount + 1 @@ -272,7 +272,7 @@ local function GetSpots() for i = 1, #spots do local spot = spots[i] if not spot.y then - Spring.MarkerAddPoint(spot.x, spGetGroundHeight(spot.x, spot.z), spot.z, "bad spot") + SpringUnsynced.MarkerAddPoint(spot.x, spGetGroundHeight(spot.x, spot.z), spot.z, "bad spot") end end return spots diff --git a/luarules/gadgets/ai/shard_runtime/spring_lua/shard.lua b/luarules/gadgets/ai/shard_runtime/spring_lua/shard.lua index 7c6bf305e25..4574d7936e7 100644 --- a/luarules/gadgets/ai/shard_runtime/spring_lua/shard.lua +++ b/luarules/gadgets/ai/shard_runtime/spring_lua/shard.lua @@ -39,7 +39,7 @@ end function Shard:shardify_unittype(unitDefID) if not unitDefID then - Spring.Echo('shard: error: shardify_unittype recieved "' .. unitDefID .. '" of type "' .. type(unitDefID) .. '" ') + SpringShared.Echo('shard: error: shardify_unittype recieved "' .. unitDefID .. '" of type "' .. type(unitDefID) .. '" ') return nil end if not self.unittypesByID[unitDefID] then diff --git a/luarules/gadgets/ai/shard_runtime/spring_lua/unit.lua b/luarules/gadgets/ai/shard_runtime/spring_lua/unit.lua index 6ca159c411c..8843029067b 100644 --- a/luarules/gadgets/ai/shard_runtime/spring_lua/unit.lua +++ b/luarules/gadgets/ai/shard_runtime/spring_lua/unit.lua @@ -2,7 +2,7 @@ ShardUnit = class(function(a, id) a.id = id a.className = "unit" - local udefid = Spring.GetUnitDefID(id) + local udefid = SpringShared.GetUnitDefID(id) a.UnitDefID = udefid a.type = ShardUnitType(udefid) end) @@ -25,19 +25,19 @@ function ShardUnit:ID() end function ShardUnit:Team() - return Spring.GetUnitTeam(self.id) + return SpringShared.GetUnitTeam(self.id) end function ShardUnit:Radius() - return Spring.GetUnitRadius(self.id) + return SpringShared.GetUnitRadius(self.id) end function ShardUnit:AllyTeam() - return Spring.GetUnitAllyTeam(self.id) + return SpringShared.GetUnitAllyTeam(self.id) end function ShardUnit:isNeutral() - return Spring.GetUnitNeutral(self.id) + return SpringShared.GetUnitNeutral(self.id) end function ShardUnit:IsMine(myTeam) @@ -57,7 +57,7 @@ function ShardUnit:IsEnemy(myAllyTeam) end function ShardUnit:Stunned() - local stunned_or_inbuild, stunned, inbuild = Spring.GetUnitIsStunned(self.id) + local stunned_or_inbuild, stunned, inbuild = SpringShared.GetUnitIsStunned(self.id) return stunned end @@ -81,7 +81,7 @@ function ShardUnit:InList(unitTypeNames) end function ShardUnit:IsAlive() - if Spring.GetUnitIsDead(self.id) == false then + if SpringShared.GetUnitIsDead(self.id) == false then return true else return false -- cause return true for a short period and then nil @@ -90,7 +90,7 @@ end function ShardUnit:GetLos(bitmask) bitmask = bitmask or true - return Spring.GetUnitLosState(self.id, self:GetUnitAllyTeam(), bitmask) + return SpringShared.GetUnitLosState(self.id, self:GetUnitAllyTeam(), bitmask) end function ShardUnit:IsCloaked() @@ -98,23 +98,23 @@ function ShardUnit:IsCloaked() end function ShardUnit:Cloaked() - return Spring.GetUnitIsCloaked(self.id) + return SpringShared.GetUnitIsCloaked(self.id) end function ShardUnit:GetUnitIsBuilding() - return Spring.GetUnitIsBuilding(self.id) + return SpringShared.GetUnitIsBuilding(self.id) end function ShardUnit:GetCurrentBuildPower() - return Spring.GetUnitCurrentBuildPower(self.id) + return SpringShared.GetUnitCurrentBuildPower(self.id) end function ShardUnit:IsBlocking() - return Spring.GetUnitBlocking(self.unitid) + return SpringShared.GetUnitBlocking(self.unitid) end function ShardUnit:CurrentStockpile() - local numStockpiled, numStockpileQued, buildPercent = Spring.GetUnitStockpile(self.id) + local numStockpiled, numStockpileQued, buildPercent = SpringShared.GetUnitStockpile(self.id) return numStockpiled, numStockpileQued, buildPercent end @@ -135,7 +135,7 @@ function ShardUnit:CanMorph() end function ShardUnit:IsBeingBuilt() - return Spring.GetUnitIsBeingBuilt(self.id) + return SpringShared.GetUnitIsBeingBuilt(self.id) end function ShardUnit:IsMorphing() @@ -169,7 +169,7 @@ function ShardUnit:CanBuildWhenNotDeployed() end function ShardUnit:FactoryWait() - local topQueue = Spring.GetFactoryCommands(self.id, 1)[1] + local topQueue = SpringShared.GetFactoryCommands(self.id, 1)[1] if topQueue and topQueue.id ~= CMD.WAIT then local order = self:SyncOrder(self.id, CMD.WAIT, { 0 }, 0) --Spring.GiveOrderToUnit( self.id, CMD.WAIT, {}, 0 ) @@ -177,7 +177,7 @@ function ShardUnit:FactoryWait() end function ShardUnit:FactoryUnWait() - local topQueue = Spring.GetFactoryCommands(self.id, 1)[1] + local topQueue = SpringShared.GetFactoryCommands(self.id, 1)[1] if topQueue and topQueue.id == CMD.WAIT then local order = self:SyncOrder(self.id, CMD.WAIT, { 0 }, 0) --Spring.GiveOrderToUnit( self.id, CMD.WAIT, {}, 0 ) @@ -185,14 +185,14 @@ function ShardUnit:FactoryUnWait() end function ShardUnit:IsWaiting() - local topQueue = Spring.GetFactoryCommands(self.id, 1)[1] + local topQueue = SpringShared.GetFactoryCommands(self.id, 1)[1] if topQueue and topQueue.id == CMD.WAIT then return true end end function ShardUnit:getFactoryCommands() - return Spring.GetFactoryCommands(self.id, 1) + return SpringShared.GetFactoryCommands(self.id, 1) end --[[ @@ -216,12 +216,12 @@ end function ShardUnit:GetUnitCommands(count) if count == 0 then - Spring.Echo(self:Name(), self.id, "Get Unit Commands received 0 as parameter index") + SpringShared.Echo(self:Name(), self.id, "Get Unit Commands received 0 as parameter index") return {} -- FIXME: Why am I receiving 0 count? end count = count or 1 - local currentOrder = Spring.GetUnitCommands(self.id, count) + local currentOrder = SpringShared.GetUnitCommands(self.id, count) return currentOrder end @@ -455,12 +455,12 @@ function ShardUnit:IdleModeLand() end function ShardUnit:CurrentCommand() - return Spring.GetUnitCurrentCommand(self.id) + return SpringShared.GetUnitCurrentCommand(self.id) end function ShardUnit:GetPosition() - local bpx, bpy, bpz = Spring.GetUnitPosition(self.id) - local isDead = Spring.GetUnitIsDead(self.id) + local bpx, bpy, bpz = SpringShared.GetUnitPosition(self.id) + local isDead = SpringShared.GetUnitIsDead(self.id) if not bpx then --Spring.Echo(self:Name(), self.id, "Get Position return nil position") return @@ -477,37 +477,37 @@ function ShardUnit:GetPosition() end function ShardUnit:GetRawPos() - local bpx, bpy, bpz = Spring.GetUnitPosition(self.id) + local bpx, bpy, bpz = SpringShared.GetUnitPosition(self.id) return bpx, bpy, bpz end function ShardUnit:GetHealtsParams() - local health, maxHealth, paralyzeDamage, captureProgress, buildProgress = Spring.GetUnitHealth(self.id) + local health, maxHealth, paralyzeDamage, captureProgress, buildProgress = SpringShared.GetUnitHealth(self.id) return health, maxHealth, paralyzeDamage, captureProgress, buildProgress, health / maxHealth end function ShardUnit:GetHealth() - local health, maxHealth, paralyzeDamage, captureProgress, buildProgress = Spring.GetUnitHealth(self.id) + local health, maxHealth, paralyzeDamage, captureProgress, buildProgress = SpringShared.GetUnitHealth(self.id) return health end function ShardUnit:GetMaxHealth() - local health, maxHealth, paralyzeDamage, captureProgress, buildProgress = Spring.GetUnitHealth(self.id) + local health, maxHealth, paralyzeDamage, captureProgress, buildProgress = SpringShared.GetUnitHealth(self.id) return maxHealth end function ShardUnit:ParalysisDamage() - local health, maxHealth, paralyzeDamage, captureProgress, buildProgress = Spring.GetUnitHealth(self.id) + local health, maxHealth, paralyzeDamage, captureProgress, buildProgress = SpringShared.GetUnitHealth(self.id) return paralyzeDamage end function ShardUnit:CaptureProgress() - local health, maxHealth, paralyzeDamage, captureProgress, buildProgress = Spring.GetUnitHealth(self.id) + local health, maxHealth, paralyzeDamage, captureProgress, buildProgress = SpringShared.GetUnitHealth(self.id) return captureProgress end function ShardUnit:BuildProgress() - local isBuilding, buildProgress = Spring.GetUnitIsBeingBuilt(self.id) + local isBuilding, buildProgress = SpringShared.GetUnitIsBeingBuilt(self.id) return buildProgress end @@ -516,7 +516,7 @@ function ShardUnit:WeaponCount() end function ShardUnit:MaxWeaponsRange() - return Spring.GetUnitMaxRange(self.id) + return SpringShared.GetUnitMaxRange(self.id) end function ShardUnit:CanBuild(uType) @@ -527,7 +527,7 @@ function ShardUnit:CanBuild(uType) end function ShardUnit:GetFacing(id) - return Spring.GetUnitBuildFacing(id) + return SpringShared.GetUnitBuildFacing(id) -- 0, "s", "south" -- 1, "e", "east" -- 2, "n", "north" @@ -535,7 +535,7 @@ function ShardUnit:GetFacing(id) end function ShardUnit:GetResourceUsage(idx) - local metalMake, metalUse, energyMake, energyUse = Spring.GetUnitResources(self.id) + local metalMake, metalUse, energyMake, energyUse = SpringShared.GetUnitResources(self.id) local SResourceTransfer = { gameframe = Spring.GameFrame(), rate = 1 } if Shard.resourceIds[idx] == "metal" then SResourceTransfer.generation = metalMake @@ -548,7 +548,7 @@ function ShardUnit:GetResourceUsage(idx) end function ShardUnit:TestMoveOrder(p) - return Spring.TestMoveOrder(self.UnitDefID, p.x, p.y, p.z, nil, nil, nil, true, true, false) + return SpringShared.TestMoveOrder(self.UnitDefID, p.x, p.y, p.z, nil, nil, nil, true, true, false) end function ShardUnit:SyncOrder( diff --git a/luarules/gadgets/ai/shard_runtime/unit.lua b/luarules/gadgets/ai/shard_runtime/unit.lua index 6243a3f82ca..00a847cc748 100644 --- a/luarules/gadgets/ai/shard_runtime/unit.lua +++ b/luarules/gadgets/ai/shard_runtime/unit.lua @@ -12,7 +12,7 @@ local function tracyZoneEndMem() end if tracy and not tracy then - Spring.Echo("Enabled Tracy support for UNIT STAI") + SpringShared.Echo("Enabled Tracy support for UNIT STAI") tracyZoneBeginMem = function(fname) if logRAM then lastGCinfo = gcinfo() diff --git a/luarules/gadgets/ai_namer.lua b/luarules/gadgets/ai_namer.lua index 1f2d2323db8..debf04822f1 100644 --- a/luarules/gadgets/ai_namer.lua +++ b/luarules/gadgets/ai_namer.lua @@ -141,10 +141,10 @@ if gadgetHandler:IsSyncedCode() then end --function gadget:Initialize() - local t = Spring.GetTeamList() + local t = SpringShared.GetTeamList() for _, teamID in ipairs(t) do - if select(4, Spring.GetTeamInfo(teamID, false)) then -- is AI? - Spring.SetGameRulesParam("ainame_" .. teamID, getName(teamID, string.find(Spring.GetTeamLuaAI(teamID) or "", "Raptors"), string.find(Spring.GetTeamLuaAI(teamID) or "", "Scavenger"))) + if select(4, SpringShared.GetTeamInfo(teamID, false)) then -- is AI? + SpringSynced.SetGameRulesParam("ainame_" .. teamID, getName(teamID, string.find(SpringShared.GetTeamLuaAI(teamID) or "", "Raptors"), string.find(SpringShared.GetTeamLuaAI(teamID) or "", "Scavenger"))) end end gadgetHandler:RemoveGadget(self) diff --git a/luarules/gadgets/ai_ruin_blueprint_tester.lua b/luarules/gadgets/ai_ruin_blueprint_tester.lua index 36d00a3a727..c30ffe01225 100644 --- a/luarules/gadgets/ai_ruin_blueprint_tester.lua +++ b/luarules/gadgets/ai_ruin_blueprint_tester.lua @@ -56,7 +56,7 @@ if gadgetHandler:IsSyncedCode() then lastposX = lastposX + high_radius * 3 lastposZ = lastposZ end - Spring.MarkerAddPoint(blueprintpositions[i].posx, Spring.GetGroundHeight(blueprintpositions[i].posx, blueprintpositions[i].posz), blueprintpositions[i].posz, "#" .. i) + SpringUnsynced.MarkerAddPoint(blueprintpositions[i].posx, SpringShared.GetGroundHeight(blueprintpositions[i].posx, blueprintpositions[i].posz), blueprintpositions[i].posz, "#" .. i) end for i = 1, #blueprints do @@ -79,21 +79,21 @@ if gadgetHandler:IsSyncedCode() then if #queue > 0 then local unitDefID = queue[1].unitDefID if unitDefID then - Spring.Echo("UnitDefID: " .. unitDefID) + SpringShared.Echo("UnitDefID: " .. unitDefID) local basePosX = queue[1].basePosX - Spring.Echo("basePosX: " .. basePosX) + SpringShared.Echo("basePosX: " .. basePosX) local basePosZ = queue[1].basePosZ - Spring.Echo("basePosZ: " .. basePosZ) + SpringShared.Echo("basePosZ: " .. basePosZ) local xOffset = queue[1].xOffset - Spring.Echo("xOffset: " .. xOffset) + SpringShared.Echo("xOffset: " .. xOffset) local zOffset = queue[1].zOffset - Spring.Echo("zOffset: " .. zOffset) + SpringShared.Echo("zOffset: " .. zOffset) local direction = queue[1].direction - Spring.Echo("direction: " .. direction) + SpringShared.Echo("direction: " .. direction) local nonscavname = string.gsub(UnitDefs[unitDefID].name, "_scav", "") if UnitDefNames[nonscavname] then local nonscavDefID = UnitDefNames[nonscavname].id - Spring.CreateUnit(nonscavDefID, basePosX + xOffset, Spring.GetGroundHeight(basePosX + xOffset, basePosZ + zOffset), basePosZ + zOffset, direction, 0) + SpringSynced.CreateUnit(nonscavDefID, basePosX + xOffset, SpringShared.GetGroundHeight(basePosX + xOffset, basePosZ + zOffset), basePosZ + zOffset, direction, 0) end end table.remove(queue, 1) @@ -111,9 +111,9 @@ else function RequestScavTest(cmd, line, words, playerID) if words and #words == 1 then - Spring.SendLuaRulesMsg(cmdname .. " " .. words[1]) + SpringUnsynced.SendLuaRulesMsg(cmdname .. " " .. words[1]) else - Spring.SendMessageToPlayer(playerID, "Please specify which file you want to spawn (Enter the filename only without .lua)") + SpringUnsynced.SendMessageToPlayer(playerID, "Please specify which file you want to spawn (Enter the filename only without .lua)") end end diff --git a/luarules/gadgets/ai_ruins.lua b/luarules/gadgets/ai_ruins.lua index 7b3119be2de..006a7108660 100644 --- a/luarules/gadgets/ai_ruins.lua +++ b/luarules/gadgets/ai_ruins.lua @@ -1,5 +1,5 @@ -if not (Spring.GetModOptions().ruins == "enabled" or (Spring.GetModOptions().ruins == "scav_only" and Spring.Utilities.Gametype.IsScavengers())) then +if not (SpringShared.GetModOptions().ruins == "enabled" or (SpringShared.GetModOptions().ruins == "scav_only" and Spring.Utilities.Gametype.IsScavengers())) then return end @@ -24,10 +24,10 @@ end -- these are used in poschecks.lua so arent localized here local mapsizeX = Game.mapSizeX local mapsizeZ = Game.mapSizeZ -local GaiaTeamID = Spring.GetGaiaTeamID() -local GaiaAllyTeamID = select(6, Spring.GetTeamInfo(GaiaTeamID)) +local GaiaTeamID = SpringShared.GetGaiaTeamID() +local GaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(GaiaTeamID)) -local ruinDensity = Spring.GetModOptions().ruins_density +local ruinDensity = SpringShared.GetModOptions().ruins_density local ruinDensityMultiplier = 1 local ruinMexGeoChance = 0.33 if ruinDensity == "veryrare" then @@ -134,7 +134,7 @@ for i = 1, #scavConfig.unprocessedScavTurrets do unitName = string.sub(unitName, 1, -6) end -- convert scav unit into non-scav if not UnitDefNames[unitName] then - Spring.Echo("We got a fucked unit name here: " .. unitName) + SpringShared.Echo("We got a fucked unit name here: " .. unitName) end if defs.type ~= "nuke" and UnitDefNames[unitName] and not UnitDefNames[unitName].isFactory then -- we don't want nukes and factories in ruins if defs.surface == "land" then @@ -281,26 +281,26 @@ local function spawnRuin(ruin, posx, posy, posz, blueprintTierLevel) local nonscavname = string.gsub(name, "_scav", "") local r = math.random(1, 100) if r < 40 and UnitDefNames[nonscavname] then - local posy = Spring.GetGroundHeight(posx + (xOffset * flipX * mirrorX), posz + (zOffset * flipZ * mirrorZ)) - local unit = Spring.CreateUnit(UnitDefNames[nonscavname].id, posx + (xOffset * flipX * mirrorX), posy, posz + (zOffset * flipZ * mirrorZ), (building.direction + rotation + mirrorRotation) % 4, GaiaTeamID) + local posy = SpringShared.GetGroundHeight(posx + (xOffset * flipX * mirrorX), posz + (zOffset * flipZ * mirrorZ)) + local unit = SpringSynced.CreateUnit(UnitDefNames[nonscavname].id, posx + (xOffset * flipX * mirrorX), posy, posz + (zOffset * flipZ * mirrorZ), (building.direction + rotation + mirrorRotation) % 4, GaiaTeamID) if unit then local radarRange = UnitDefs[building.unitDefID].radarDistance local canMove = UnitDefs[building.unitDefID].canMove local speed = UnitDefs[building.unitDefID].speed - Spring.SetUnitNeutral(unit, true) - Spring.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) - Spring.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) + SpringSynced.SetUnitNeutral(unit, true) + SpringSynced.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) + SpringSynced.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) --Spring.SetUnitAlwaysVisible(unit, true) if building.patrol and canMove and speed > 0 then for i = 1, 6 do - Spring.GiveOrderToUnit(unit, CMD.PATROL, { posx + (math.random(-200, 200)), posy + 100, posz + (math.random(-200, 200)) }, { "shift", "alt", "ctrl" }) + SpringSynced.GiveOrderToUnit(unit, CMD.PATROL, { posx + (math.random(-200, 200)), posy + 100, posz + (math.random(-200, 200)) }, { "shift", "alt", "ctrl" }) end end if radarRange and radarRange > 1000 then - Spring.GiveOrderToUnit(unit, CMD.ONOFF, { 0 }, 0) + SpringSynced.GiveOrderToUnit(unit, CMD.ONOFF, { 0 }, 0) end end -- elseif r < 90 and FeatureDefNames[name .. "_dead"] then @@ -321,7 +321,7 @@ local function SpawnMexes(mexSpots) local spot = mexSpots[i] local posx = math.ceil(spot.x / 16) * 16 local posz = math.ceil(spot.z / 16) * 16 - local posy = Spring.GetGroundHeight(posx, posz) + local posy = SpringShared.GetGroundHeight(posx, posz) local mexesList if posy > 0 then mexesList = landMexesList @@ -340,11 +340,11 @@ local function SpawnMexes(mexSpots) if canBuildHere then local mex = mexesList[math.random(1, #mexesList)] - local unit = Spring.CreateUnit(UnitDefNames[mex].id, posx, posy, posz, math.random(0, 3), GaiaTeamID) + local unit = SpringSynced.CreateUnit(UnitDefNames[mex].id, posx, posy, posz, math.random(0, 3), GaiaTeamID) if unit then - Spring.SetUnitNeutral(unit, true) - Spring.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) - Spring.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) + SpringSynced.SetUnitNeutral(unit, true) + SpringSynced.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) + SpringSynced.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) SpawnedMexes[i] = math.random(1, 2) end end @@ -359,7 +359,7 @@ local function SpawnGeos(geoSpots) local spot = geoSpots[i] local posx = math.ceil(spot.x / 16) * 16 local posz = math.ceil(spot.z / 16) * 16 - local posy = Spring.GetGroundHeight(posx, posz) + local posy = SpringShared.GetGroundHeight(posx, posz) local geosList if posy > 0 then geosList = landGeosList @@ -378,11 +378,11 @@ local function SpawnGeos(geoSpots) if canBuildHere then local geo = geosList[math.random(1, #geosList)] - local unit = Spring.CreateUnit(UnitDefNames[geo].id, posx, posy, posz, math.random(0, 3), GaiaTeamID) + local unit = SpringSynced.CreateUnit(UnitDefNames[geo].id, posx, posy, posz, math.random(0, 3), GaiaTeamID) if unit then - Spring.SetUnitNeutral(unit, true) - Spring.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) - Spring.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) + SpringSynced.SetUnitNeutral(unit, true) + SpringSynced.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) + SpringSynced.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) SpawnedGeos[i] = math.random(2, 3) end end @@ -399,7 +399,7 @@ local function SpawnMexGeoRandomStructures() for j = 1, SpawnedMexes[i] do local posx2 = math.ceil((spot.x + math.random(-512, 512)) / 16) * 16 local posz2 = math.ceil((spot.z + math.random(-512, 512)) / 16) * 16 - local posy2 = Spring.GetGroundHeight(posx2, posz2) + local posy2 = SpringShared.GetGroundHeight(posx2, posz2) local defencesList if posy2 > 0 then defencesList = landDefences @@ -422,11 +422,11 @@ local function SpawnMexGeoRandomStructures() if canBuildHere then local defence = defencesList[math.random(1, #defencesList)] - local unit = Spring.CreateUnit(UnitDefNames[defence].id, posx2, posy2, posz2, math.random(0, 3), GaiaTeamID) + local unit = SpringSynced.CreateUnit(UnitDefNames[defence].id, posx2, posy2, posz2, math.random(0, 3), GaiaTeamID) if unit then - Spring.SetUnitNeutral(unit, true) - Spring.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) - Spring.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) + SpringSynced.SetUnitNeutral(unit, true) + SpringSynced.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) + SpringSynced.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) end end end @@ -442,7 +442,7 @@ local function SpawnMexGeoRandomStructures() for j = 1, SpawnedGeos[i] do local posx2 = math.ceil((spot.x + math.random(-1024, 1024)) / 16) * 16 local posz2 = math.ceil((spot.z + math.random(-1024, 1024)) / 16) * 16 - local posy2 = Spring.GetGroundHeight(posx2, posz2) + local posy2 = SpringShared.GetGroundHeight(posx2, posz2) local defencesList if posy2 > 0 then defencesList = landDefences @@ -465,11 +465,11 @@ local function SpawnMexGeoRandomStructures() if canBuildHere then local defence = defencesList[math.random(1, #defencesList)] - local unit = Spring.CreateUnit(UnitDefNames[defence].id, posx2, posy2, posz2, math.random(0, 3), GaiaTeamID) + local unit = SpringSynced.CreateUnit(UnitDefNames[defence].id, posx2, posy2, posz2, math.random(0, 3), GaiaTeamID) if unit then - Spring.SetUnitNeutral(unit, true) - Spring.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) - Spring.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) + SpringSynced.SetUnitNeutral(unit, true) + SpringSynced.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) + SpringSynced.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) end end end @@ -483,7 +483,7 @@ local function SpawnRandomStructures() for j = 1, math.ceil(10 * ruinDensityMultiplier) do local posx = math.ceil(math.random(196, Game.mapSizeX - 196) / 16) * 16 local posz = math.ceil(math.random(196, Game.mapSizeZ - 196) / 16) * 16 - local posy = Spring.GetGroundHeight(posx, posz) + local posy = SpringShared.GetGroundHeight(posx, posz) local defencesList if posy > 0 then defencesList = landDefences @@ -506,11 +506,11 @@ local function SpawnRandomStructures() if canBuildHere then local defence = defencesList[math.random(1, #defencesList)] - local unit = Spring.CreateUnit(UnitDefNames[defence].id, posx, posy, posz, math.random(0, 3), GaiaTeamID) + local unit = SpringSynced.CreateUnit(UnitDefNames[defence].id, posx, posy, posz, math.random(0, 3), GaiaTeamID) if unit then - Spring.SetUnitNeutral(unit, true) - Spring.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) - Spring.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) + SpringSynced.SetUnitNeutral(unit, true) + SpringSynced.GiveOrderToUnit(unit, CMD.FIRE_STATE, { 1 }, 0) + SpringSynced.GiveOrderToUnit(unit, CMD.MOVE_STATE, { 0 }, 0) end break end @@ -551,7 +551,7 @@ function gadget:GameFrame(n) local ruin posx = math.random(0, Game.mapSizeX) posz = math.random(0, Game.mapSizeZ) - posy = Spring.GetGroundHeight(posx, posz) + posy = SpringShared.GetGroundHeight(posx, posz) seaRuinChance = math.random(1, 2) r = math.random(0, 100) -- replace 100 with 200 when we get civilians @@ -560,15 +560,15 @@ function gadget:GameFrame(n) -- landRuin = blueprintController.Ruin.GetRandomLandBlueprint() -- seaRuin = blueprintController.Ruin.GetRandomSeaBlueprint() -- blueprintTierLevel = -1 - if r > 98 and Spring.GetModOptions().ruins_only_t1 == false then -- elseif + if r > 98 and SpringShared.GetModOptions().ruins_only_t1 == false then -- elseif landRuin = blueprintController.GetRandomLandBlueprint(4) seaRuin = blueprintController.GetRandomSeaBlueprint(4) blueprintTierLevel = 4 - elseif r > 95 and Spring.GetModOptions().ruins_only_t1 == false then + elseif r > 95 and SpringShared.GetModOptions().ruins_only_t1 == false then landRuin = blueprintController.GetRandomLandBlueprint(3) seaRuin = blueprintController.GetRandomSeaBlueprint(3) blueprintTierLevel = 3 - elseif r > 85 and Spring.GetModOptions().ruins_only_t1 == false then + elseif r > 85 and SpringShared.GetModOptions().ruins_only_t1 == false then landRuin = blueprintController.GetRandomLandBlueprint(2) seaRuin = blueprintController.GetRandomSeaBlueprint(2) blueprintTierLevel = 2 diff --git a/luarules/gadgets/ai_simpleai.lua b/luarules/gadgets/ai_simpleai.lua index abe65782573..8705e5d62b0 100644 --- a/luarules/gadgets/ai_simpleai.lua +++ b/luarules/gadgets/ai_simpleai.lua @@ -5,10 +5,10 @@ local SimpleFactoriesCount = {} local SimpleFactories = {} local SimpleT1Mexes = {} local SimpleFactoryDelay = {} -local teams = Spring.GetTeamList() +local teams = SpringShared.GetTeamList() for i = 1, #teams do local teamID = teams[i] - local luaAI = Spring.GetTeamLuaAI(teamID) + local luaAI = SpringShared.GetTeamLuaAI(teamID) if luaAI and luaAI ~= "" and (string.sub(luaAI, 1, 8) == "SimpleAI" or string.sub(luaAI, 1, 15) == "SimpleCheaterAI" or string.sub(luaAI, 1, 16) == "SimpleDefenderAI" or string.sub(luaAI, 1, 19) == "SimpleConstructorAI") then enabled = true SimpleAITeamIDsCount = SimpleAITeamIDsCount + 1 @@ -174,26 +174,26 @@ for unitDefID, unitDef in pairs(UnitDefs) do end end -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitNearestEnemy = Spring.GetUnitNearestEnemy -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder -local spGetUnitsInRectangle = Spring.GetUnitsInRectangle -local spGetGroundHeight = Spring.GetGroundHeight -local spGetGroundInfo = Spring.GetGroundInfo -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spGetUnitHealth = Spring.GetUnitHealth -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetTeamResources = Spring.GetTeamResources -local spTestBuildOrder = Spring.TestBuildOrder -local spGetFullBuildQueue = Spring.GetFullBuildQueue -local spGetTeamUnits = Spring.GetTeamUnits -local spGetAllUnits = Spring.GetAllUnits -local spSetTeamResource = Spring.SetTeamResource -local spGetTeamInfo = Spring.GetTeamInfo -local spGetTeamLuaAI = Spring.GetTeamLuaAI +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitNearestEnemy = SpringShared.GetUnitNearestEnemy +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local spGetUnitsInRectangle = SpringShared.GetUnitsInRectangle +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetGroundInfo = SpringShared.GetGroundInfo +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetTeamResources = SpringShared.GetTeamResources +local spTestBuildOrder = SpringShared.TestBuildOrder +local spGetFullBuildQueue = SpringShared.GetFullBuildQueue +local spGetTeamUnits = SpringShared.GetTeamUnits +local spGetAllUnits = SpringShared.GetAllUnits +local spSetTeamResource = SpringSynced.SetTeamResource +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetTeamLuaAI = SpringShared.GetTeamLuaAI local spDgunCommand = CMD.DGUN local function SimpleGetClosestMexSpot(x, z) diff --git a/luarules/gadgets/api_build_blocking.lua b/luarules/gadgets/api_build_blocking.lua index 9c3b3d6f1cf..cd015d59a74 100644 --- a/luarules/gadgets/api_build_blocking.lua +++ b/luarules/gadgets/api_build_blocking.lua @@ -44,7 +44,7 @@ if gadgetHandler:IsSyncedCode() then local teamBlockedUnitDefs = {} -- data structure: unitDefID = {reasonKey = true, reasonKey = true, ...} - local teamsList = Spring.GetTeamList() + local teamsList = SpringShared.GetTeamList() local ignoredTeams = {} local scavTeamID, raptorTeamID = Spring.Utilities.GetScavTeamID(), Spring.Utilities.GetRaptorTeamID() @@ -73,7 +73,7 @@ if gadgetHandler:IsSyncedCode() then end local function isAuthorized(playerID) - if Spring.IsCheatingEnabled() then + if SpringShared.IsCheatingEnabled() then return true else local accountID = Spring.Utilities.GetAccountID(playerID) @@ -97,8 +97,8 @@ if gadgetHandler:IsSyncedCode() then return teams else local targetTeamID = tonumber(teamParam) - if not targetTeamID or not Spring.GetTeamInfo(targetTeamID) then - Spring.SendMessageToPlayer(playerID, "Invalid teamID: " .. tostring(teamParam) .. ". Use 'all' or a valid team number.") + if not targetTeamID or not SpringShared.GetTeamInfo(targetTeamID) then + SpringUnsynced.SendMessageToPlayer(playerID, "Invalid teamID: " .. tostring(teamParam) .. ". Use 'all' or a valid team number.") return nil end return { targetTeamID } @@ -139,15 +139,15 @@ if gadgetHandler:IsSyncedCode() then local function commandBuildBlock(cmd, line, words, playerID) if not isAuthorized(playerID) then if _G.isSinglePlayer then - Spring.SendMessageToPlayer(playerID, "You must enable /cheats in order to use buildblock commands") + SpringUnsynced.SendMessageToPlayer(playerID, "You must enable /cheats in order to use buildblock commands") else - Spring.SendMessageToPlayer(playerID, "You are not authorized to use buildblock commands") + SpringUnsynced.SendMessageToPlayer(playerID, "You are not authorized to use buildblock commands") end return end if #words < 3 then - Spring.SendMessageToPlayer(playerID, "Usage: /luarules buildblock ... or 'all'") + SpringUnsynced.SendMessageToPlayer(playerID, "Usage: /luarules buildblock ... or 'all'") return end @@ -175,27 +175,27 @@ if gadgetHandler:IsSyncedCode() then end blockedCount = blockedCount + 1 else - Spring.SendMessageToPlayer(playerID, "Invalid unitDefID or unitDefName: " .. tostring(words[i])) + SpringUnsynced.SendMessageToPlayer(playerID, "Invalid unitDefID or unitDefName: " .. tostring(words[i])) end end end local teamMsg = (teamParam == "all") and "all teams" or ("team " .. teamParam) - Spring.SendMessageToPlayer(playerID, "Blocked " .. blockedCount .. " unit(s) with reason '" .. reasonKey .. "' for " .. teamMsg) + SpringUnsynced.SendMessageToPlayer(playerID, "Blocked " .. blockedCount .. " unit(s) with reason '" .. reasonKey .. "' for " .. teamMsg) end local function commandBuildUnblock(cmd, line, words, playerID) if not isAuthorized(playerID) then if _G.isSinglePlayer then - Spring.SendMessageToPlayer(playerID, "You must enable /cheats in order to use buildunblock commands") + SpringUnsynced.SendMessageToPlayer(playerID, "You must enable /cheats in order to use buildunblock commands") else - Spring.SendMessageToPlayer(playerID, "You are not authorized to use buildunblock commands") + SpringUnsynced.SendMessageToPlayer(playerID, "You are not authorized to use buildunblock commands") end return end if #words < 3 then - Spring.SendMessageToPlayer(playerID, "Usage: /luarules buildunblock ... or 'all'") + SpringUnsynced.SendMessageToPlayer(playerID, "Usage: /luarules buildunblock ... or 'all'") return end @@ -233,13 +233,13 @@ if gadgetHandler:IsSyncedCode() then unblockedCount = unblockedCount + 1 end else - Spring.SendMessageToPlayer(playerID, "Invalid unitDefID or unitDefName: " .. tostring(words[i])) + SpringUnsynced.SendMessageToPlayer(playerID, "Invalid unitDefID or unitDefName: " .. tostring(words[i])) end end end local teamMsg = (teamParam == "all") and "all teams" or ("team " .. teamParam) - Spring.SendMessageToPlayer(playerID, "Unblocked " .. unblockedCount .. " unit(s) with reason '" .. reasonKey .. "' for " .. teamMsg) + SpringUnsynced.SendMessageToPlayer(playerID, "Unblocked " .. unblockedCount .. " unit(s) with reason '" .. reasonKey .. "' for " .. teamMsg) end function gadget:Initialize() @@ -289,7 +289,7 @@ if gadgetHandler:IsSyncedCode() then local unitReasons = blockedUnitDefs[unitDefID] unitReasons[reasonKey] = true local concatenatedReasons = reasonConcatenator(unitReasons) - Spring.SetTeamRulesParam(teamID, "unitdef_blocked_" .. unitDefID, concatenatedReasons) + SpringSynced.SetTeamRulesParam(teamID, "unitdef_blocked_" .. unitDefID, concatenatedReasons) notifyUnitBlocked(unitDefID, teamID, unitReasons) end @@ -307,9 +307,9 @@ if gadgetHandler:IsSyncedCode() then if next(unitReasons) then local concatenatedReasons = reasonConcatenator(unitReasons) - Spring.SetTeamRulesParam(teamID, "unitdef_blocked_" .. unitDefID, concatenatedReasons) + SpringSynced.SetTeamRulesParam(teamID, "unitdef_blocked_" .. unitDefID, concatenatedReasons) else - Spring.SetTeamRulesParam(teamID, "unitdef_blocked_" .. unitDefID, nil) + SpringSynced.SetTeamRulesParam(teamID, "unitdef_blocked_" .. unitDefID, nil) end notifyUnitBlocked(unitDefID, teamID, unitReasons) return true diff --git a/luarules/gadgets/api_damage_stats.lua b/luarules/gadgets/api_damage_stats.lua index baa8d6064ef..973469a12ff 100644 --- a/luarules/gadgets/api_damage_stats.lua +++ b/luarules/gadgets/api_damage_stats.lua @@ -28,7 +28,7 @@ local info = {} local gameType function gadget:Initialize() - local tList = Spring.GetTeamList() + local tList = SpringShared.GetTeamList() if Spring.Utilities.Gametype.IsFFA() then gameType = "free for all" @@ -39,10 +39,10 @@ function gadget:Initialize() local nAITeams = 0 local nRaptorTeams = 0 for _, teamID in pairs(tList) do - local luaAI = Spring.GetTeamLuaAI(teamID) or "" + local luaAI = SpringShared.GetTeamLuaAI(teamID) or "" local aiRaptor = (luaAI:find("Raptor") ~= nil) - local aiTeam = select(4, Spring.GetTeamInfo(teamID, false)) - local gaiaTeam = (teamID == Spring.GetGaiaTeamID()) + local aiTeam = select(4, SpringShared.GetTeamInfo(teamID, false)) + local gaiaTeam = (teamID == SpringShared.GetGaiaTeamID()) if aiRaptor then nRaptorTeams = nRaptorTeams + 1 end @@ -69,11 +69,11 @@ function gadget:Initialize() end function gadget:UnitCreated(unitID, unitDefID, teamID, builderID) - local pList = Spring.GetPlayerList(teamID) + local pList = SpringShared.GetPlayerList(teamID) local playerID = pList[1] local customtable = false if playerID then - customtable = select(11, Spring.GetPlayerInfo(playerID)) or {} + customtable = select(11, SpringShared.GetPlayerInfo(playerID)) or {} end local tsMu = customtable and customtable.skill or "" local mu = tsMu and tonumber(tsMu:match("%d+%.?%d*")) or 25 @@ -82,7 +82,7 @@ function gadget:UnitCreated(unitID, unitDefID, teamID, builderID) info[unitDefID].n = info[unitDefID].n + 1 info[unitDefID].ts = info[unitDefID].ts + mu - info[unitDefID].minutes = info[unitDefID].minutes + Spring.GetGameFrame() / (30 * 60) + info[unitDefID].minutes = info[unitDefID].minutes + SpringShared.GetGameFrame() / (30 * 60) end function gadget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam) @@ -98,10 +98,10 @@ function gadget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weap if not info[unitDefID] then return end - if Spring.AreTeamsAllied(unitTeam, attackerTeam) then + if SpringShared.AreTeamsAllied(unitTeam, attackerTeam) then return end - local h, _, _ = Spring.GetUnitHealth(unitID) + local h, _, _ = SpringShared.GetUnitHealth(unitID) if h > damage then damage = h end diff --git a/luarules/gadgets/api_enemyunitdestroyed.lua b/luarules/gadgets/api_enemyunitdestroyed.lua index 52d4125a2f8..88bb5495213 100644 --- a/luarules/gadgets/api_enemyunitdestroyed.lua +++ b/luarules/gadgets/api_enemyunitdestroyed.lua @@ -14,13 +14,13 @@ function gadget:GetInfo() end if not gadgetHandler:IsSyncedCode() then - local spGetUnitAllyTeam = Spring.GetUnitAllyTeam + local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam local myAllyTeamID = Spring.GetMyAllyTeamID() - local spec, fullView = Spring.GetSpectatingState() + local spec, fullView = SpringUnsynced.GetSpectatingState() function gadget:Initialize() myAllyTeamID = Spring.GetMyAllyTeamID() - spec, fullView = Spring.GetSpectatingState() + spec, fullView = SpringUnsynced.GetSpectatingState() end function gadget:PlayerChanged(playerID) @@ -30,7 +30,7 @@ if not gadgetHandler:IsSyncedCode() then function gadget:UnitDestroyed(unitID, unitDefID, teamID, attackerID, attackerDefID, attackerTeamID, weaponDefID) local allyTeam = spGetUnitAllyTeam(unitID) if (spec and fullview) or (allyTeam and allyTeam ~= myAllyTeamID) then - local losstate = Spring.GetUnitLosState(unitID, myAllyTeamID) + local losstate = SpringShared.GetUnitLosState(unitID, myAllyTeamID) if losstate and losstate["los"] and Script.LuaUI("EnemyUnitDestroyed") then Script.LuaUI.EnemyUnitDestroyed(unitID, unitDefID, teamID, attackerID, attackerDefID, attackerTeamID, weaponDefID) end diff --git a/luarules/gadgets/api_garbage_collector.lua b/luarules/gadgets/api_garbage_collector.lua index e985e5dff1e..853bfc89e78 100644 --- a/luarules/gadgets/api_garbage_collector.lua +++ b/luarules/gadgets/api_garbage_collector.lua @@ -25,7 +25,7 @@ if not gadgetHandler:IsSyncedCode() then collectgarbage("collect") local notgarbagemem = gcinfo() local newgarbagelimit = math.min(1200000, basememlimit + notgarbagemem) -- peak 1 GB - Spring.Echo(string.format("BAR using %d MB RAM > %d MB limit, performing garbage collection down to %d MB and adjusting limit to %d MB", math.floor(ramuse / 1000), math.floor(garbagelimit / 1000), math.floor(notgarbagemem / 1000), math.floor(newgarbagelimit / 1000))) + SpringShared.Echo(string.format("BAR using %d MB RAM > %d MB limit, performing garbage collection down to %d MB and adjusting limit to %d MB", math.floor(ramuse / 1000), math.floor(garbagelimit / 1000), math.floor(notgarbagemem / 1000), math.floor(newgarbagelimit / 1000))) garbagelimit = newgarbagelimit end end diff --git a/luarules/gadgets/api_missions.lua b/luarules/gadgets/api_missions.lua index 96cbfdc515d..cc30b615e1c 100644 --- a/luarules/gadgets/api_missions.lua +++ b/luarules/gadgets/api_missions.lua @@ -42,7 +42,7 @@ function gadget:Initialize() end GG["MissionAPI"] = {} - GG["MissionAPI"].Difficulty = Spring.GetModOptions().mission_difficulty --TODO: add mission difficulty modoption + GG["MissionAPI"].Difficulty = SpringShared.GetModOptions().mission_difficulty --TODO: add mission difficulty modoption local triggersSchema = VFS.Include("luarules/mission_api/triggers_schema.lua") local actionsSchema = VFS.Include("luarules/mission_api/actions_schema.lua") diff --git a/luarules/gadgets/api_pbr_enabler.lua b/luarules/gadgets/api_pbr_enabler.lua index 224422e6d03..8824cde1e3f 100644 --- a/luarules/gadgets/api_pbr_enabler.lua +++ b/luarules/gadgets/api_pbr_enabler.lua @@ -17,16 +17,16 @@ if not gadgetHandler:IsSyncedCode() then --unsynced gadget GG.GetEnvTexture = nil if gl.CreateShader == nil then - Spring.Echo("ERROR: PBR enabler: gl.CreateShader is nil") + SpringShared.Echo("ERROR: PBR enabler: gl.CreateShader is nil") return end if gl.CreateFBO == nil then - Spring.Echo("ERROR: PBR enabler: gl.CreateFBO is nil") + SpringShared.Echo("ERROR: PBR enabler: gl.CreateFBO is nil") return end - local headless = Spring.GetConfigInt("Headless", 0) > 0 + local headless = SpringUnsynced.GetConfigInt("Headless", 0) > 0 if headless then return end @@ -67,10 +67,10 @@ if not gadgetHandler:IsSyncedCode() then --unsynced gadget end function gadget:Initialize() - ENVLUT_SAMPLES = Spring.GetConfigInt("ENV_SMPL_NUM", 64) + ENVLUT_SAMPLES = SpringUnsynced.GetConfigInt("ENV_SMPL_NUM", 64) - Spring.SetConfigInt("CubeTexGenerateMipMaps", 1) - Spring.SetConfigInt("CubeTexSizeReflection", 1024) + SpringUnsynced.SetConfigInt("CubeTexGenerateMipMaps", 1) + SpringUnsynced.SetConfigInt("CubeTexSizeReflection", 1024) local brdfLutClass = VFS.Include("LuaRules/Gadgets/Include/GenBrdfLut.lua") if brdfLutClass then diff --git a/luarules/gadgets/api_permissions.lua b/luarules/gadgets/api_permissions.lua index c86b034424d..091c163da03 100644 --- a/luarules/gadgets/api_permissions.lua +++ b/luarules/gadgets/api_permissions.lua @@ -21,10 +21,10 @@ local isSinglePlayer = false local trustedNames = powerusers.trustedNames powerusers.trustedNames = nil if trustedNames then - for _, playerID in ipairs(Spring.GetPlayerList()) do + for _, playerID in ipairs(SpringShared.GetPlayerList()) do local accountID = Spring.Utilities.GetAccountID(playerID) - if not powerusers[accountID] and trustedNames[Spring.GetPlayerInfo(playerID)] then - powerusers[accountID] = trustedNames[Spring.GetPlayerInfo(playerID)] + if not powerusers[accountID] and trustedNames[SpringShared.GetPlayerInfo(playerID)] then + powerusers[accountID] = trustedNames[SpringShared.GetPlayerInfo(playerID)] end end end @@ -33,9 +33,9 @@ local numPlayers = Spring.Utilities.GetPlayerCount() -- give permissions when in singleplayer if numPlayers <= 1 then - for _, playerID in ipairs(Spring.GetPlayerList()) do + for _, playerID in ipairs(SpringShared.GetPlayerList()) do local accountID = Spring.Utilities.GetAccountID(playerID) - local _, _, spec = Spring.GetPlayerInfo(playerID) + local _, _, spec = SpringShared.GetPlayerInfo(playerID) -- dont give permissions to the spectators when there is a player is playing if not spec or numPlayers == 0 then @@ -66,7 +66,7 @@ _G.permissions = permissions _G.isSinglePlayer = isSinglePlayer local function ResolveTrustedName(playerID) - local name = Spring.GetPlayerInfo(playerID) + local name = SpringShared.GetPlayerInfo(playerID) if not name or not trustedNames[name] then return false end @@ -84,7 +84,7 @@ local function ResolveTrustedName(playerID) end permissions[permission][accountID] = value end - Spring.Log("Permissions", LOG.INFO, "Granted trusted-name permissions to " .. name .. " (accountID: " .. accountID .. ")") + SpringShared.Log("Permissions", LOG.INFO, "Granted trusted-name permissions to " .. name .. " (accountID: " .. accountID .. ")") return true end @@ -111,9 +111,9 @@ function gadget:GameFrame(frame) if frame % 200 ~= 0 then return end - for _, playerID in ipairs(Spring.GetPlayerList()) do + for _, playerID in ipairs(SpringShared.GetPlayerList()) do if not resolvedPlayerIDs[playerID] then - local name = Spring.GetPlayerInfo(playerID) + local name = SpringShared.GetPlayerInfo(playerID) if name and trustedNames[name] then if ResolveTrustedName(playerID) then resolvedPlayerIDs[playerID] = true diff --git a/luarules/gadgets/api_widget_events.lua b/luarules/gadgets/api_widget_events.lua index bb4971d3669..c4309b6b6bf 100644 --- a/luarules/gadgets/api_widget_events.lua +++ b/luarules/gadgets/api_widget_events.lua @@ -16,10 +16,10 @@ function gadget:GetInfo() } end -local spAreTeamsAllied = Spring.AreTeamsAllied +local spAreTeamsAllied = SpringShared.AreTeamsAllied local spGetMyAllyTeamID = Spring.GetMyAllyTeamID -local spGetSpectatingState = Spring.GetSpectatingState -local spGetUnitLosState = Spring.GetUnitLosState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetUnitLosState = SpringShared.GetUnitLosState local myAllyTeamID, myTeamID, spec, specFullView diff --git a/luarules/gadgets/camera_lockcamera.lua b/luarules/gadgets/camera_lockcamera.lua index e5db959a838..0d06da7f1d2 100644 --- a/luarules/gadgets/camera_lockcamera.lua +++ b/luarules/gadgets/camera_lockcamera.lua @@ -38,14 +38,14 @@ if gadgetHandler:IsSyncedCode() then else -- UNSYNCED - local GetCameraState = Spring.GetCameraState - local SetCameraState = Spring.SetCameraState - local GetLastUpdateSeconds = Spring.GetLastUpdateSeconds + local GetCameraState = SpringUnsynced.GetCameraState + local SetCameraState = SpringUnsynced.SetCameraState + local GetLastUpdateSeconds = SpringUnsynced.GetLastUpdateSeconds local GetMyAllyTeamID = Spring.GetMyAllyTeamID - local GetSpectatingState = Spring.GetSpectatingState - local GetPlayerInfo = Spring.GetPlayerInfo - local SendLuaRulesMsg = Spring.SendLuaRulesMsg - local SendCommands = Spring.SendCommands + local GetSpectatingState = SpringUnsynced.GetSpectatingState + local GetPlayerInfo = SpringShared.GetPlayerInfo + local SendLuaRulesMsg = SpringUnsynced.SendLuaRulesMsg + local SendCommands = SpringUnsynced.SendCommands local strByte = string.byte local strChar = string.char @@ -58,7 +58,7 @@ else -- UNSYNCED local lastPacketSent - local CAMERA_IDS = Spring.GetCameraNames() + local CAMERA_IDS = SpringUnsynced.GetCameraNames() local CAMERA_NAMES = {} local CAMERA_STATE_FORMATS = {} @@ -203,7 +203,7 @@ else -- UNSYNCED return result end - Spring.Echo(": Sorry for the camera switch spam, but this is the only reliable way to list camera states other than hardcoding them") + SpringShared.Echo(": Sorry for the camera switch spam, but this is the only reliable way to list camera states other than hardcoding them") local prevCameraState = GetCameraState() for name, num in pairs(CAMERA_IDS) do CAMERA_NAMES[num] = name @@ -246,7 +246,7 @@ else -- UNSYNCED if msg ~= PACKET_HEADER then cameraState = PacketToCameraState(msg) if not cameraState then - Spring.Echo(": Bad packet recieved.") + SpringShared.Echo(": Bad packet recieved.") return end end @@ -272,7 +272,7 @@ else -- UNSYNCED local msg = CameraStateToPacket(state) if not msg then - Spring.Echo(": Error creating packet!") + SpringShared.Echo(": Error creating packet!") return end diff --git a/luarules/gadgets/cmd_alliance_break.lua b/luarules/gadgets/cmd_alliance_break.lua index 5a04bc07138..177b79cac3e 100644 --- a/luarules/gadgets/cmd_alliance_break.lua +++ b/luarules/gadgets/cmd_alliance_break.lua @@ -12,22 +12,22 @@ function gadget:GetInfo() } end -if Spring.GetModOptions().fixedallies then +if SpringShared.GetModOptions().fixedallies then return -- no use if alliances are disabled end if gadgetHandler:IsSyncedCode() then - local GetUnitDefID = Spring.GetUnitDefID - local AreTeamsAllied = Spring.AreTeamsAllied - local GetUnitsInSphere = Spring.GetUnitsInSphere - local GetUnitTeam = Spring.GetUnitTeam - local GetUnitAllyTeam = Spring.GetUnitAllyTeam - local GetTeamList = Spring.GetTeamList - local GetUnitHealth = Spring.GetUnitHealth - local GetUnitsInCylinder = Spring.GetUnitsInCylinder - local SetAlly = Spring.SetAlly - local ValidUnitID = Spring.ValidUnitID + local GetUnitDefID = SpringShared.GetUnitDefID + local AreTeamsAllied = SpringShared.AreTeamsAllied + local GetUnitsInSphere = SpringShared.GetUnitsInSphere + local GetUnitTeam = SpringShared.GetUnitTeam + local GetUnitAllyTeam = SpringShared.GetUnitAllyTeam + local GetTeamList = SpringShared.GetTeamList + local GetUnitHealth = SpringShared.GetUnitHealth + local GetUnitsInCylinder = SpringShared.GetUnitsInCylinder + local SetAlly = SpringSynced.SetAlly + local ValidUnitID = SpringShared.ValidUnitID local min = math.min local CMD_UNIT_SET_TARGET = GameCMD.UNIT_SET_TARGET @@ -39,7 +39,7 @@ if gadgetHandler:IsSyncedCode() then local UPDATE_RATE = 3 --in times per second ( max one time per sim frame ) local UPDATE_FRAMES = math.floor(Game.gameSpeed / UPDATE_RATE) - local allyTeamList = Spring.GetAllyTeamList() + local allyTeamList = SpringShared.GetAllyTeamList() local attackAOEs = {} local attackDamages = {} @@ -147,9 +147,9 @@ else -- Unsynced ---------------------------------------------------------------- - local SendMessageToTeam = Spring.SendMessageToTeam - local GetTeamInfo = Spring.GetTeamInfo - local GetPlayerInfo = Spring.GetPlayerInfo + local SendMessageToTeam = SpringUnsynced.SendMessageToTeam + local GetTeamInfo = SpringShared.GetTeamInfo + local GetPlayerInfo = SpringShared.GetPlayerInfo -- Dynamic alliances are not supported for AI teams local function getTeamLeaderName(teamID) diff --git a/luarules/gadgets/cmd_area_mex.lua b/luarules/gadgets/cmd_area_mex.lua index fa15c09c63d..9f7dfa63b8c 100644 --- a/luarules/gadgets/cmd_area_mex.lua +++ b/luarules/gadgets/cmd_area_mex.lua @@ -13,6 +13,6 @@ function gadget:GetInfo() end function gadget:Initialize() - Spring.AssignMouseCursor("upgmex", "cursorupgmex", false) - Spring.AssignMouseCursor("areamex", "cursorareamex", false) + SpringUnsynced.AssignMouseCursor("upgmex", "cursorupgmex", false) + SpringUnsynced.AssignMouseCursor("areamex", "cursorareamex", false) end diff --git a/luarules/gadgets/cmd_build_bugger_off.lua b/luarules/gadgets/cmd_build_bugger_off.lua index 200cc663709..0558d55e946 100644 --- a/luarules/gadgets/cmd_build_bugger_off.lua +++ b/luarules/gadgets/cmd_build_bugger_off.lua @@ -21,21 +21,21 @@ local math_max = math.max local math_diag = math.diag local math_pointOnCircle = math.closestPointOnCircle -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGetUnitStates = Spring.GetUnitStates -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitIsBuilding = Spring.GetUnitIsBuilding -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitVelocity = Spring.GetUnitVelocity -local spGetUnitTeam = Spring.GetUnitTeam - -local spAreTeamsAllied = Spring.AreTeamsAllied -local spDestroyUnit = Spring.DestroyUnit -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spTestMoveOrder = Spring.TestMoveOrder +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGetUnitStates = SpringShared.GetUnitStates +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitIsBuilding = SpringShared.GetUnitIsBuilding +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitVelocity = SpringShared.GetUnitVelocity +local spGetUnitTeam = SpringShared.GetUnitTeam + +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spDestroyUnit = SpringSynced.DestroyUnit +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spTestMoveOrder = SpringShared.TestMoveOrder local gameSpeed = Game.gameSpeed local footprint = Game.squareSize * Game.footprintScale @@ -74,7 +74,7 @@ local areaCommandCooldown = {} local FAST_UPDATE_RADIUS = 400 -- builders take about this much to enter build stance; determined empirically local BUILDER_DELAY_SECONDS = 3.3 -local BUILDER_BUILD_RADIUS = 200 * Spring.GetModOptions().multiplier_builddistance -- ! varies per-unit +local BUILDER_BUILD_RADIUS = 200 * SpringShared.GetModOptions().multiplier_builddistance -- ! varies per-unit -- Assume the units are super-fast and medium-sized. local SEARCH_RADIUS_OFFSET = unitSpeedMax + 2 * footprint local FAST_UPDATE_FREQUENCY = gameSpeed * 0.5 diff --git a/luarules/gadgets/cmd_commander_dance.lua b/luarules/gadgets/cmd_commander_dance.lua index 75416f57bb2..c7fcfe0add9 100644 --- a/luarules/gadgets/cmd_commander_dance.lua +++ b/luarules/gadgets/cmd_commander_dance.lua @@ -19,20 +19,20 @@ end local strSub = string.sub local mathAbs = math.abs -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetGameFrame = Spring.GetGameFrame -local spSendMessageToPlayer = Spring.SendMessageToPlayer -local spValidUnitID = Spring.ValidUnitID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitVelocity = Spring.GetUnitVelocity -local spGetUnitIsBuilding = Spring.GetUnitIsBuilding -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGetCOBScriptID = Spring.GetCOBScriptID -local spCallCOBScript = Spring.CallCOBScript -local spIsCheatingEnabled = Spring.IsCheatingEnabled - -local UnitScript = Spring.UnitScript +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetGameFrame = SpringShared.GetGameFrame +local spSendMessageToPlayer = SpringUnsynced.SendMessageToPlayer +local spValidUnitID = SpringShared.ValidUnitID +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitVelocity = SpringShared.GetUnitVelocity +local spGetUnitIsBuilding = SpringShared.GetUnitIsBuilding +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGetCOBScriptID = SpringSynced.GetCOBScriptID +local spCallCOBScript = SpringSynced.CallCOBScript +local spIsCheatingEnabled = SpringShared.IsCheatingEnabled + +local UnitScript = SpringSynced.UnitScript local usGetScriptEnv = UnitScript.GetScriptEnv local usCallAsUnit = UnitScript.CallAsUnit diff --git a/luarules/gadgets/cmd_dev_helpers.lua b/luarules/gadgets/cmd_dev_helpers.lua index e3a241f9a9b..945662f8856 100644 --- a/luarules/gadgets/cmd_dev_helpers.lua +++ b/luarules/gadgets/cmd_dev_helpers.lua @@ -28,10 +28,10 @@ if gadgetHandler:IsSyncedCode() then end function isAuthorized(playerID, subPermission) - if Spring.IsCheatingEnabled() then + if SpringShared.IsCheatingEnabled() then return true end - local playername = Spring.GetPlayerInfo(playerID) + local playername = SpringShared.GetPlayerInfo(playerID) local accountID = Spring.Utilities.GetAccountID(playerID) local hasPermission = false -- check catch-all devhelpers permission @@ -56,9 +56,9 @@ end if gadgetHandler:IsSyncedCode() then function checkStartPlayers() - for _, playerID in ipairs(Spring.GetPlayerList()) do + for _, playerID in ipairs(SpringShared.GetPlayerList()) do -- update player infos - local playername, _, spec = Spring.GetPlayerInfo(playerID, false) + local playername, _, spec = SpringShared.GetPlayerInfo(playerID, false) if not spec then startPlayers[playername] = true end @@ -70,23 +70,23 @@ if gadgetHandler:IsSyncedCode() then end function LoadMissiles() - if not Spring.IsCheatingEnabled() then + if not SpringShared.IsCheatingEnabled() then return end - for _, unitID in pairs(Spring.GetAllUnits()) do - Spring.SetUnitStockpile(unitID, math.max(5, select(2, Spring.GetUnitStockpile(unitID)))) --no effect if the unit can't stockpile + for _, unitID in pairs(SpringShared.GetAllUnits()) do + SpringSynced.SetUnitStockpile(unitID, math.max(5, select(2, SpringShared.GetUnitStockpile(unitID)))) --no effect if the unit can't stockpile end end function HalfHealth() - if not Spring.IsCheatingEnabled() then + if not SpringShared.IsCheatingEnabled() then return end -- reduce all units health to 1/2 of its current value - for _, unitID in pairs(Spring.GetAllUnits()) do - Spring.SetUnitHealth(unitID, Spring.GetUnitHealth(unitID) / 2) + for _, unitID in pairs(SpringShared.GetAllUnits()) do + SpringSynced.SetUnitHealth(unitID, SpringShared.GetUnitHealth(unitID) / 2) end end @@ -94,7 +94,7 @@ if gadgetHandler:IsSyncedCode() then local feedstep = 20 local mapcx = Game.mapSizeX / 2 local mapcz = Game.mapSizeZ / 2 - local mapcy = Spring.GetGroundHeight(mapcx, mapcz) + local mapcy = SpringShared.GetGroundHeight(mapcx, mapcz) local fightertestenabled = false local placementradius = 2000 local keepfeatures = 150 @@ -126,10 +126,10 @@ if gadgetHandler:IsSyncedCode() then end local function SpawnUnitDefsForTeam(teamID, unitDefName) - local unitcount = Spring.GetTeamUnits(teamID) + local unitcount = SpringShared.GetTeamUnits(teamID) if #unitcount < maxunits then local cmd = string.format("give %d %s %d @%d,%d,%d", feedstep, unitDefName, teamID, mapcx + placementradius * (getrandom() - 0.5), mapcy, mapcz + placementradius * (getrandom() - 0.5)) - Spring.SendCommands({ cmd }) + SpringUnsynced.SendCommands({ cmd }) fightertesttotalunitsspawned = fightertesttotalunitsspawned + feedstep end end @@ -139,7 +139,7 @@ if gadgetHandler:IsSyncedCode() then --return: nil | number count local unitDefID = UnitDefNames[unitDefName].id - local unitcount = Spring.GetTeamUnitDefCount(teamID, unitDefID) + local unitcount = SpringShared.GetTeamUnitDefCount(teamID, unitDefID) if unitcount < maxunits then local cx = mapcx + placementradius * (getrandom() - 0.5) @@ -154,8 +154,8 @@ if gadgetHandler:IsSyncedCode() then if numspawned < feedstep then local px = cx + 12 * footprint * x local pz = cz + 12 * footprint * z - local py = Spring.GetGroundHeight(px, pz) - local unitID = Spring.CreateUnit(unitDefID, px, py, pz, "n", teamID) + local py = SpringShared.GetGroundHeight(px, pz) + local unitID = SpringSynced.CreateUnit(unitDefID, px, py, pz, "n", teamID) if unitID then numspawned = numspawned + 1 newUnitIDs[#newUnitIDs + 1] = unitID @@ -167,20 +167,20 @@ if gadgetHandler:IsSyncedCode() then --Spring.GiveOrderToUnitArray ( table unitArray = { [1] = number unitID, etc... }, number cmdID, table params = {number, etc...}, table options = {"alt", "ctrl", "shift", "right"} ) --return: nil | bool true --CMD.MOVE, { p.x, p.y, p.z }, 0 ) - Spring.GiveOrderToUnitArray(newUnitIDs, CMD.REPEAT, { 1 }, 0) + SpringSynced.GiveOrderToUnitArray(newUnitIDs, CMD.REPEAT, { 1 }, 0) local ncx = mapcx + placementradius * (getrandom() - 0.5) local ncz = mapcz + placementradius * (getrandom() - 0.5) - local gh = Spring.GetGroundHeight(ncx, ncz) - Spring.GiveOrderToUnitArray(newUnitIDs, CMD.MOVE, { ncx, gh, ncz }, { "shift" }) + local gh = SpringShared.GetGroundHeight(ncx, ncz) + SpringSynced.GiveOrderToUnitArray(newUnitIDs, CMD.MOVE, { ncx, gh, ncz }, { "shift" }) ncx = mapcx + placementradius * (getrandom() - 0.5) ncz = mapcz + placementradius * (getrandom() - 0.5) - gh = Spring.GetGroundHeight(ncx, ncz) - Spring.GiveOrderToUnitArray(newUnitIDs, CMD.MOVE, { ncx, gh, ncz }, { "shift" }) + gh = SpringShared.GetGroundHeight(ncx, ncz) + SpringSynced.GiveOrderToUnitArray(newUnitIDs, CMD.MOVE, { ncx, gh, ncz }, { "shift" }) - gh = Spring.GetGroundHeight(cx, cz) - Spring.GiveOrderToUnitArray(newUnitIDs, CMD.MOVE, { cx, gh, cz }, { "shift" }) + gh = SpringShared.GetGroundHeight(cx, cz) + SpringSynced.GiveOrderToUnitArray(newUnitIDs, CMD.MOVE, { cx, gh, cz }, { "shift" }) fightertesttotalunitsspawned = fightertesttotalunitsspawned + numspawned end @@ -195,13 +195,13 @@ if gadgetHandler:IsSyncedCode() then else minHeight = tonumber(value[1]) if not minHeight then - _, minHeight = Spring.GetGroundExtremes() + _, minHeight = SpringShared.GetGroundExtremes() end end - Spring.SetHeightMapFunc(function() + SpringSynced.SetHeightMapFunc(function() for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - Spring.SetHeightMap(x, z, (minHeight - Spring.GetGroundHeight(x, z))) + SpringSynced.SetHeightMap(x, z, (minHeight - SpringShared.GetGroundHeight(x, z))) end end end) @@ -211,10 +211,10 @@ if gadgetHandler:IsSyncedCode() then if height == nil then return end - Spring.SetHeightMapFunc(function() + SpringSynced.SetHeightMapFunc(function() for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - Spring.SetHeightMap(x, z, (math.abs(Spring.GetGroundHeight(x, z) - height) + height)) + SpringSynced.SetHeightMap(x, z, (math.abs(SpringShared.GetGroundHeight(x, z) - height) + height)) end end end) @@ -224,10 +224,10 @@ if gadgetHandler:IsSyncedCode() then if height == nil then return end - Spring.SetHeightMapFunc(function() + SpringSynced.SetHeightMapFunc(function() for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - Spring.SetHeightMap(x, z, -(math.abs(-Spring.GetGroundHeight(x, z) + height) - height)) + SpringSynced.SetHeightMap(x, z, -(math.abs(-SpringShared.GetGroundHeight(x, z) + height) - height)) end end end) @@ -235,10 +235,10 @@ if gadgetHandler:IsSyncedCode() then -- extreme - multipliy the heightmap extreme = function(value) local multiplier = math.clamp(tonumber(value[1]) or 2, -10, 10) - Spring.SetHeightMapFunc(function() + SpringSynced.SetHeightMapFunc(function() for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - Spring.SetHeightMap(x, z, Spring.GetGroundHeight(x, z) * multiplier) + SpringSynced.SetHeightMap(x, z, SpringShared.GetGroundHeight(x, z) * multiplier) end end end) @@ -249,12 +249,12 @@ if gadgetHandler:IsSyncedCode() then if height == nil then return end - Spring.SetHeightMapFunc(function() + SpringSynced.SetHeightMapFunc(function() for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - local tmp = Spring.GetGroundHeight(x, z) + local tmp = SpringShared.GetGroundHeight(x, z) if tmp > height then - Spring.SetHeightMap(x, z, (tmp - height) * multiplier + height) + SpringSynced.SetHeightMap(x, z, (tmp - height) * multiplier + height) end end end @@ -266,12 +266,12 @@ if gadgetHandler:IsSyncedCode() then if height == nil then return end - Spring.SetHeightMapFunc(function() + SpringSynced.SetHeightMapFunc(function() for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - local tmp = Spring.GetGroundHeight(x, z) + local tmp = SpringShared.GetGroundHeight(x, z) if tmp < height then - Spring.SetHeightMap(x, z, (tmp - height) * multiplier + height) + SpringSynced.SetHeightMap(x, z, (tmp - height) * multiplier + height) end end end @@ -283,10 +283,10 @@ if gadgetHandler:IsSyncedCode() then if height == nil then return end - Spring.SetHeightMapFunc(function() + SpringSynced.SetHeightMapFunc(function() for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - Spring.SetHeightMap(x, z, math.min(Spring.GetGroundHeight(x, z), height)) + SpringSynced.SetHeightMap(x, z, math.min(SpringShared.GetGroundHeight(x, z), height)) end end end) @@ -296,23 +296,23 @@ if gadgetHandler:IsSyncedCode() then if height == nil then return end - Spring.SetHeightMapFunc(function() + SpringSynced.SetHeightMapFunc(function() for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - Spring.SetHeightMap(x, z, math.max(Spring.GetGroundHeight(x, z), height)) + SpringSynced.SetHeightMap(x, z, math.max(SpringShared.GetGroundHeight(x, z), height)) end end end) end, -- move the water level to designated position, or to the lowest point zero = function(value) - local height = Spring.GetGroundExtremes() + (tonumber(value[1]) or 0) - Spring.AdjustHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, -height) + local height = SpringShared.GetGroundExtremes() + (tonumber(value[1]) or 0) + SpringSynced.AdjustHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, -height) end, waterlevel = function(value) local height = tonumber(value[1]) if height then - Spring.AdjustHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, -height) + SpringSynced.AdjustHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, -height) end end, } @@ -361,8 +361,8 @@ if gadgetHandler:IsSyncedCode() then local MODESTEPSIZE = 16 for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - height = Spring.GetGroundHeight(x, z) or 0 - _, normal, _ = Spring.GetGroundNormal(x, z) + height = SpringShared.GetGroundHeight(x, z) or 0 + _, normal, _ = SpringShared.GetGroundNormal(x, z) smallestStepHeight = math.floor(height / MODESTEPSIZE) if tempModeArray[smallestStepHeight] then tempModeArray[smallestStepHeight][1] = tempModeArray[smallestStepHeight][1] + 1 @@ -387,14 +387,14 @@ if gadgetHandler:IsSyncedCode() then end) -- log the table of mode heights, might be useful for users who wish to fish them out - Spring.Echo("cmd_dev_helpers, terrainMods; generating table format mode height sampling") - Spring.Echo("where id is sorted by most common map height for this map") - Spring.Echo("id: | height: |\tid: | height: |\tid: | height:") + SpringShared.Echo("cmd_dev_helpers, terrainMods; generating table format mode height sampling") + SpringShared.Echo("where id is sorted by most common map height for this map") + SpringShared.Echo("id: | height: |\tid: | height: |\tid: | height:") local tableDebth = math.floor(#modeArray / 3) for j = 1, tableDebth do - Spring.Echo(j .. "\t" .. modeArray[j][2] .. "\t\t\t" .. j + tableDebth .. "\t" .. modeArray[j + tableDebth][2] .. "\t\t\t" .. j + tableDebth + tableDebth .. "\t" .. modeArray[j + tableDebth + tableDebth][2]) + SpringShared.Echo(j .. "\t" .. modeArray[j][2] .. "\t\t\t" .. j + tableDebth .. "\t" .. modeArray[j + tableDebth][2] .. "\t\t\t" .. j + tableDebth + tableDebth .. "\t" .. modeArray[j + tableDebth + tableDebth][2]) end - Spring.Echo("cmd_dev_helpers, terrainMods, end of table") + SpringShared.Echo("cmd_dev_helpers, terrainMods, end of table") end -- used for reading mode position within the array's constraints or 0 @@ -468,29 +468,29 @@ if gadgetHandler:IsSyncedCode() then -- finishing touches do -- Edge patchwork, something is not right with map edges, i don't know if its the above functions that fail, or if it is during map making - Spring.SetHeightMapFunc(function() + SpringSynced.SetHeightMapFunc(function() for x = 0, Game.mapSizeX, Game.squareSize do - Spring.SetHeightMap(x, Game.mapSizeZ, (Spring.GetGroundHeight(x, Game.mapSizeZ - Game.squareSize))) + SpringSynced.SetHeightMap(x, Game.mapSizeZ, (SpringShared.GetGroundHeight(x, Game.mapSizeZ - Game.squareSize))) end for z = 0, Game.mapSizeZ, Game.squareSize do - Spring.SetHeightMap(Game.mapSizeX, z, (Spring.GetGroundHeight(Game.mapSizeX - Game.squareSize, z))) + SpringSynced.SetHeightMap(Game.mapSizeX, z, (SpringShared.GetGroundHeight(Game.mapSizeX - Game.squareSize, z))) end end) -- orginal height map so that restore ground command doesn't dig trenches or construct mountains - Spring.SetOriginalHeightMapFunc(function() + SpringSynced.SetOriginalHeightMapFunc(function() for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - Spring.SetOriginalHeightMap(x, z, Spring.GetGroundHeight(x, z)) + SpringSynced.SetOriginalHeightMap(x, z, SpringShared.GetGroundHeight(x, z)) end end end) -- temporary smooth mesh, as on some maps it can take up to a minute and a half for it to be created - Spring.SetSmoothMeshFunc(function() + SpringSynced.SetSmoothMeshFunc(function() for z = 0, Game.mapSizeZ, Game.squareSize do for x = 0, Game.mapSizeX, Game.squareSize do - Spring.SetSmoothMesh(x, z, 50 + Spring.GetGroundHeight(x, z)) + SpringSynced.SetSmoothMesh(x, z, 50 + SpringShared.GetGroundHeight(x, z)) end end end) @@ -500,9 +500,9 @@ if gadgetHandler:IsSyncedCode() then local debugcommands = nil function gadget:Initialize() - if Spring.GetModOptions() and Spring.GetModOptions().debugcommands then + if SpringShared.GetModOptions() and SpringShared.GetModOptions().debugcommands then - local debugString = Spring.GetModOptions().debugcommands + local debugString = SpringShared.GetModOptions().debugcommands -- "for fun" terrain moddifiers -- they block any accompanying actual debug comands from running @@ -515,13 +515,13 @@ if gadgetHandler:IsSyncedCode() then end debugcommands = {} - local commands = string.split(Spring.GetModOptions().debugcommands, "|") + local commands = string.split(SpringShared.GetModOptions().debugcommands, "|") for i, command in ipairs(commands) do local cmdsplit = string.split(command, ":") if cmdsplit[1] and cmdsplit[2] and tonumber(cmdsplit[1]) then if not string.find(string.lower(cmdsplit[2]), "execute", nil, true) then debugcommands[tonumber(cmdsplit[1])] = cmdsplit[2] - Spring.Echo("Adding debug command", cmdsplit[1], cmdsplit[2]) + SpringShared.Echo("Adding debug command", cmdsplit[1], cmdsplit[2]) end end end @@ -563,8 +563,8 @@ if gadgetHandler:IsSyncedCode() then end if cmd == "desync" then - Spring.Echo("Synced: Attempting to trigger a /desync") - Spring.SendCommands("desync") + SpringShared.Echo("Synced: Attempting to trigger a /desync") + SpringUnsynced.SendCommands("desync") end if cmd == "givecat" then @@ -623,49 +623,49 @@ if gadgetHandler:IsSyncedCode() then local featuredefstoremove = {} function globallos(words) - local allyteams = Spring.GetAllyTeamList() + local allyteams = SpringShared.GetAllyTeamList() for i = 1, #allyteams do local allyTeamID = allyteams[i] if not words[3] or allyTeamID == tonumber(words[3]) then - Spring.SetGlobalLos(allyTeamID, words[2] == "1") + SpringSynced.SetGlobalLos(allyTeamID, words[2] == "1") end end end function playertoteam(words) - Spring.AssignPlayerToTeam(tonumber(words[2]), tonumber(words[3])) + SpringSynced.AssignPlayerToTeam(tonumber(words[2]), tonumber(words[3])) end function killteam(words) - Spring.KillTeam(tonumber(words[2])) + SpringSynced.KillTeam(tonumber(words[2])) end function fightertest(words) fightertestenabled = not fightertestenabled if not fightertestenabled then - Spring.Echo(string.format("Fightertest ended, %d units spawned over %d gameframes, Units/frame = %f", fightertesttotalunitsspawned, Spring.GetGameFrame() - fighterteststartgameframe, fightertesttotalunitsspawned * (1.0 / (Spring.GetGameFrame() - fighterteststartgameframe)))) + SpringShared.Echo(string.format("Fightertest ended, %d units spawned over %d gameframes, Units/frame = %f", fightertesttotalunitsspawned, SpringShared.GetGameFrame() - fighterteststartgameframe, fightertesttotalunitsspawned * (1.0 / (SpringShared.GetGameFrame() - fighterteststartgameframe)))) ExecuteRemoveUnitDefName(team1unitDefName) ExecuteRemoveUnitDefName(team2unitDefName) return end - fighterteststartgameframe = Spring.GetGameFrame() + fighterteststartgameframe = SpringShared.GetGameFrame() fightertesttotalunitsspawned = 0 initrandom(7654321) if words[2] and UnitDefNames[words[2]] then team1unitDefName = words[2] else - Spring.Echo(words[2], "is not a valid unitDefName, using", team1unitDefName, "instead") + SpringShared.Echo(words[2], "is not a valid unitDefName, using", team1unitDefName, "instead") end if words[3] and UnitDefNames[words[3]] then team2unitDefName = words[3] else - Spring.Echo(words[3], "is not a valid unitDefName, using", team2unitDefName, "instead") + SpringShared.Echo(words[3], "is not a valid unitDefName, using", team2unitDefName, "instead") end if words[4] then local maxunitsint = tonumber(words[4]) if maxunitsint == nil then - Spring.Echo(words[4], "must be the number of max units to keep spawning, using", maxunits, "instead") + SpringShared.Echo(words[4], "must be the number of max units to keep spawning, using", maxunits, "instead") else maxunits = math.floor(maxunitsint) end @@ -673,7 +673,7 @@ if gadgetHandler:IsSyncedCode() then if words[5] then local feedstepint = tonumber(words[5]) if feedstepint == nil then - Spring.Echo(words[5], "must be the number units to spawn each step, using", maxunits, "instead") + SpringShared.Echo(words[5], "must be the number units to spawn each step, using", maxunits, "instead") else feedstep = math.floor(feedstepint) end @@ -681,7 +681,7 @@ if gadgetHandler:IsSyncedCode() then if words[6] then local placementradiusint = tonumber(words[6]) if placementradiusint == nil then - Spring.Echo(words[6], "must be the radius in which to spawn units, using ", placementradius, "instead") + SpringShared.Echo(words[6], "must be the radius in which to spawn units, using ", placementradius, "instead") else placementradius = math.floor(placementradiusint) end @@ -689,19 +689,19 @@ if gadgetHandler:IsSyncedCode() then if words[7] then local keepfeaturesint = tonumber(words[7]) if keepfeaturesint == nil then - Spring.Echo(words[7], "must be the number of frames wrecks will live ", placementradius, "instead") + SpringShared.Echo(words[7], "must be the number of frames wrecks will live ", placementradius, "instead") else keepfeatures = math.floor(keepfeaturesint) end end - Spring.Echo(string.format("Starting fightertest %s vs %s with %i maxunits and %i units per step in a %d radius, features live %d frames", team1unitDefName, team2unitDefName, maxunits, feedstep, placementradius, keepfeatures)) + SpringShared.Echo(string.format("Starting fightertest %s vs %s with %i maxunits and %i units per step in a %d radius, features live %d frames", team1unitDefName, team2unitDefName, maxunits, feedstep, placementradius, keepfeatures)) featuredefstoremove = {} for _, udn in ipairs({ team1unitDefName, team2unitDefName }) do for _, wreckheap in ipairs({ "_dead", "_heap" }) do if FeatureDefNames[udn .. wreckheap] and FeatureDefNames[udn .. wreckheap].id then featuredefstoremove[FeatureDefNames[udn .. wreckheap].id] = true - Spring.Echo(udn .. wreckheap) + SpringShared.Echo(udn .. wreckheap) end end end @@ -710,24 +710,24 @@ if gadgetHandler:IsSyncedCode() then local featurestoremove = {} function gadget:FeatureCreated(featureID, allyTeam) if fightertestenabled then - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if featureDefID and featuredefstoremove[featureDefID] then - featurestoremove[featureID] = Spring.GetGameFrame() + keepfeatures + featurestoremove[featureID] = SpringShared.GetGameFrame() + keepfeatures end end end local function adjustFeatureHeight() - local featuretable = Spring.GetAllFeatures() + local featuretable = SpringShared.GetAllFeatures() local x, y, z for i = 1, #featuretable do - x, y, z = Spring.GetFeaturePosition(featuretable[i]) - Spring.SetFeaturePosition(featuretable[i], x, Spring.GetGroundHeight(x, z), z, true) -- snaptoground = true + x, y, z = SpringShared.GetFeaturePosition(featuretable[i]) + SpringSynced.SetFeaturePosition(featuretable[i], x, SpringShared.GetGroundHeight(x, z), z, true) -- snaptoground = true end end function gadget:GameFrame(n) - if n == 1 and isTerrainMod(Spring.GetModOptions().debugcommands) then + if n == 1 and isTerrainMod(SpringShared.GetModOptions().debugcommands) then adjustFeatureHeight() end if fightertestenabled then @@ -739,8 +739,8 @@ if gadgetHandler:IsSyncedCode() then if n % 3 == 1 then for featureID, deathtime in pairs(featurestoremove) do if deathtime < n then - if Spring.ValidFeatureID(featureID) then - Spring.DestroyFeature(featureID) + if SpringShared.ValidFeatureID(featureID) then + SpringSynced.DestroyFeature(featureID) end featurestoremove[featureID] = nil end @@ -749,8 +749,8 @@ if gadgetHandler:IsSyncedCode() then end if debugcommands then if debugcommands[n] then - Spring.Echo("Executing debugcommand", debugcommands[n]) - Spring.SendCommands(debugcommands[n]) + SpringShared.Echo("Executing debugcommand", debugcommands[n]) + SpringUnsynced.SendCommands(debugcommands[n]) debugcommands[n] = nil end end @@ -773,8 +773,8 @@ if gadgetHandler:IsSyncedCode() then local n = 0 local x, z = ox, oz for _, uDID in ipairs(giveUnits) do - local y = Spring.GetGroundHeight(x, z) - Spring.CreateUnit(uDID, x, y, z, "n", teamID) + local y = SpringShared.GetGroundHeight(x, z) + SpringSynced.CreateUnit(uDID, x, y, z, "n", teamID) n = n + 1 if n % arrayWidth == 0 then x = ox @@ -791,44 +791,44 @@ if gadgetHandler:IsSyncedCode() then end for n = 2, #words do local unitID = tonumber(words[n]) - local h, mh = Spring.GetUnitHealth(unitID) + local h, mh = SpringShared.GetUnitHealth(unitID) if not action then - Spring.DestroyUnit(unitID) + SpringSynced.DestroyUnit(unitID) elseif action == "xp" and params then --Spring.SetUnitExperience(unitID, select(1, Spring.GetUnitExperience(unitID)) + tonumber(params)) if type(tonumber(params)) == "number" then - Spring.SetUnitExperience(unitID, tonumber(params)) + SpringSynced.SetUnitExperience(unitID, tonumber(params)) end elseif action == "remove" then - Spring.DestroyUnit(unitID, false, true) + SpringSynced.DestroyUnit(unitID, false, true) elseif action == "removenearbyunits" then - Spring.DestroyUnit(unitID, false, true) + SpringSynced.DestroyUnit(unitID, false, true) elseif action == "transfer" then if type(tonumber(params)) == "number" then - Spring.TransferUnit(unitID, tonumber(params), true) + SpringSynced.TransferUnit(unitID, tonumber(params), true) end elseif action == "reclaim" then - local teamID = Spring.GetUnitTeam(unitID) - local unitDefID = Spring.GetUnitDefID(unitID) - Spring.DestroyUnit(unitID, false, true) -- this doesnt give back resources in itself - Spring.AddTeamResource(teamID, "metal", UnitDefs[unitDefID].metalCost) - Spring.AddTeamResource(teamID, "energy", UnitDefs[unitDefID].energyCost) + local teamID = SpringShared.GetUnitTeam(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) + SpringSynced.DestroyUnit(unitID, false, true) -- this doesnt give back resources in itself + SpringSynced.AddTeamResource(teamID, "metal", UnitDefs[unitDefID].metalCost) + SpringSynced.AddTeamResource(teamID, "energy", UnitDefs[unitDefID].energyCost) elseif action == "wreck" then - local unitDefID = Spring.GetUnitDefID(unitID) - local x, y, z = Spring.GetUnitPosition(unitID) - local heading = Spring.GetUnitHeading(unitID) - local unitTeam = Spring.GetUnitTeam(unitID) - Spring.DestroyUnit(unitID, false, true) + local unitDefID = SpringShared.GetUnitDefID(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) + local heading = SpringShared.GetUnitHeading(unitID) + local unitTeam = SpringShared.GetUnitTeam(unitID) + SpringSynced.DestroyUnit(unitID, false, true) if UnitDefs[unitDefID] and UnitDefs[unitDefID].corpse and FeatureDefNames[UnitDefs[unitDefID].corpse] then - Spring.CreateFeature(FeatureDefNames[UnitDefs[unitDefID].corpse].id, x, y, z, heading, unitTeam) + SpringSynced.CreateFeature(FeatureDefNames[UnitDefs[unitDefID].corpse].id, x, y, z, heading, unitTeam) end end end end function spawnceg(words) - Spring.Echo("SYNCED spawnceg", words[1], words[2], words[3], words[4], words[5]) - Spring.SpawnCEG( + SpringShared.Echo("SYNCED spawnceg", words[1], words[2], words[3], words[4], words[5]) + SpringSynced.SpawnCEG( words[2], --cegname tonumber(words[3]), tonumber(words[4]), @@ -841,8 +841,8 @@ if gadgetHandler:IsSyncedCode() then end function spawnunitexplosion(words, playerID) - Spring.Echo("SYNCED spawnunitexplosion", words[1], words[2], words[3], words[4], words[5], words[6]) - Spring.SpawnCEG( + SpringShared.Echo("SYNCED spawnunitexplosion", words[1], words[2], words[3], words[4], words[5], words[6]) + SpringSynced.SpawnCEG( words[2], --cegname tonumber(words[3]), tonumber(words[4]), @@ -854,16 +854,16 @@ if gadgetHandler:IsSyncedCode() then ) local unitDefID = UnitDefNames[words[2]] and UnitDefNames[words[2]].id or false if unitDefID then - local _, _, _, teamID = Spring.GetPlayerInfo(playerID, false) - local unitID = Spring.CreateUnit(unitDefID, tonumber(words[3]), tonumber(words[4]), tonumber(words[5]), "n", teamID) + local _, _, _, teamID = SpringShared.GetPlayerInfo(playerID, false) + local unitID = SpringSynced.CreateUnit(unitDefID, tonumber(words[3]), tonumber(words[4]), tonumber(words[5]), "n", teamID) if unitID then - Spring.DestroyUnit(unitID, words[6] == "1" and true or false, false) + SpringSynced.DestroyUnit(unitID, words[6] == "1" and true or false, false) --if words[6] ~= '1' then -- this wont clear up the wreck of the above destroyed unit, but its maybe even bettter this way :) - local featuresInRange = Spring.GetFeaturesInSphere(tonumber(words[3]), tonumber(words[4]), tonumber(words[5]), 220) + local featuresInRange = SpringShared.GetFeaturesInSphere(tonumber(words[3]), tonumber(words[4]), tonumber(words[5]), 220) for j = 1, #featuresInRange do - Spring.DestroyFeature(featuresInRange[j]) + SpringSynced.DestroyFeature(featuresInRange[j]) end --end end @@ -879,69 +879,69 @@ if gadgetHandler:IsSyncedCode() then if FeatureDefNames[unitdefname .. "_heap"] then heapFeatureDefID = FeatureDefNames[unitdefname .. "_heap"].id end - local allunits = Spring.GetAllUnits() + local allunits = SpringShared.GetAllUnits() local removedunits = 0 local removedwrecks = 0 local removedheaps = 0 for i, unitID in ipairs(allunits) do - if unitDefID == Spring.GetUnitDefID(unitID) then - Spring.DestroyUnit(unitID, false, true) + if unitDefID == SpringShared.GetUnitDefID(unitID) then + SpringSynced.DestroyUnit(unitID, false, true) removedunits = removedunits + 1 end end - local allfeatures = Spring.GetAllFeatures() + local allfeatures = SpringShared.GetAllFeatures() for i, featureID in ipairs(allfeatures) do - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if featureDefID == wreckFeatureDefID then - Spring.DestroyFeature(featureID) + SpringSynced.DestroyFeature(featureID) removedwrecks = removedwrecks + 1 end if featureDefID == heapFeatureDefID then - Spring.DestroyFeature(featureID) + SpringSynced.DestroyFeature(featureID) removedheaps = removedheaps + 1 end end - Spring.Echo(string.format("Removed %i units, %i wrecks, %i heaps for unitDefName %s", removedunits, removedwrecks, removedheaps, unitdefname)) + SpringShared.Echo(string.format("Removed %i units, %i wrecks, %i heaps for unitDefName %s", removedunits, removedwrecks, removedheaps, unitdefname)) else - Spring.Echo("Removeunitdef:", unitdefname, "is not a valid UnitDefName") + SpringShared.Echo("Removeunitdef:", unitdefname, "is not a valid UnitDefName") end end function ClearWrecks() - local allfeatures = Spring.GetAllFeatures() + local allfeatures = SpringShared.GetAllFeatures() local removedwrecks = 0 for i, featureID in pairs(allfeatures) do - local featureDef = FeatureDefs[Spring.GetFeatureDefID(featureID)] + local featureDef = FeatureDefs[SpringShared.GetFeatureDefID(featureID)] local category = featureDef.customParams.category if category == "corpses" or category == "heaps" then - Spring.DestroyFeature(featureID) + SpringSynced.DestroyFeature(featureID) removedwrecks = removedwrecks + 1 end end - Spring.Echo(string.format("Removed %i wrecks and heaps", removedwrecks)) + SpringShared.Echo(string.format("Removed %i wrecks and heaps", removedwrecks)) end function ReduceWrecksAndHeaps() - local allfeatures = Spring.GetAllFeatures() + local allfeatures = SpringShared.GetAllFeatures() local removedwrecks, removedheaps = 0, 0 for i, featureID in pairs(allfeatures) do - local featureDef = FeatureDefs[Spring.GetFeatureDefID(featureID)] + local featureDef = FeatureDefs[SpringShared.GetFeatureDefID(featureID)] local category = featureDef.customParams.category if category == "corpses" then - Spring.AddFeatureDamage(featureID, (Spring.GetFeatureHealth(featureID))) + SpringSynced.AddFeatureDamage(featureID, (SpringShared.GetFeatureHealth(featureID))) removedwrecks = removedwrecks + 1 elseif category == "heaps" then - Spring.AddFeatureDamage(featureID, (Spring.GetFeatureHealth(featureID))) + SpringSynced.AddFeatureDamage(featureID, (SpringShared.GetFeatureHealth(featureID))) removedheaps = removedheaps + 1 end end - Spring.Echo(string.format("Removed %i wrecks and %i heaps", removedwrecks, removedheaps)) + SpringShared.Echo(string.format("Removed %i wrecks and %i heaps", removedwrecks, removedheaps)) end else -- UNSYNCED - local vsx, vsy = Spring.GetViewGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() local uiScale = vsy / 1080 function gadget:Initialize() @@ -1029,7 +1029,7 @@ else -- UNSYNCED -- Spring.Echo(words[2]) -- Spring.Echo(words[3]) if words[1] and UnitDefNames[words[1]] then - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":removeunitdef " .. words[1]) + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":removeunitdef " .. words[1]) end end @@ -1040,7 +1040,7 @@ else -- UNSYNCED if not isAuthorized(playerID, "terrain") then return end - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":clearwrecks") + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":clearwrecks") end function reduceWrecks(_, line, words, playerID) @@ -1050,7 +1050,7 @@ else -- UNSYNCED if not isAuthorized(playerID, "terrain") then return end - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":reducewrecks") + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":reducewrecks") end function processUnits(_, line, words, playerID, action) @@ -1063,22 +1063,22 @@ else -- UNSYNCED local msg = "" local units = {} if action == "removenearbyunits" then - local mx, my = Spring.GetMouseState() - local targetType, pos = Spring.TraceScreenRay(mx, my, true) + local mx, my = SpringUnsynced.GetMouseState() + local targetType, pos = SpringUnsynced.TraceScreenRay(mx, my, true) if type(pos) == "table" then - units = Spring.GetUnitsInSphere(pos[1], pos[2], pos[3], words[1] and words[1] or 24, words[2] and words[2] or nil) + units = SpringShared.GetUnitsInSphere(pos[1], pos[2], pos[3], words[1] and words[1] or 24, words[2] and words[2] or nil) end else if not words[1] and action == "transferunits" then - local mx, my = Spring.GetMouseState() + local mx, my = SpringUnsynced.GetMouseState() Script.LuaUI.RestoreSelectionVolume() -- Fence calls to TraceScreenRay without onlyCoords == true. - local targetType, unitID = Spring.TraceScreenRay(mx, my) + local targetType, unitID = SpringUnsynced.TraceScreenRay(mx, my) Script.LuaUI.RemoveSelectionVolume() if targetType == "unit" then - words[1] = Spring.GetUnitTeam(unitID) + words[1] = SpringShared.GetUnitTeam(unitID) end end - units = Spring.GetSelectedUnits() + units = SpringUnsynced.GetSelectedUnits() end for _, unitID in ipairs(units) do msg = msg .. " " .. tostring(unitID) @@ -1086,7 +1086,7 @@ else -- UNSYNCED if words[1] then msg = msg .. ":" .. words[1] end - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":" .. action .. msg) + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":" .. action .. msg) end function dumpFeatures(_, line, words, playerID) @@ -1096,19 +1096,19 @@ else -- UNSYNCED if not isAuthorized(playerID, "units") then return end - local features = Spring.GetAllFeatures() - Spring.Echo("Dumping all features") + local features = SpringShared.GetAllFeatures() + SpringShared.Echo("Dumping all features") for k, featureID in pairs(features) do - local featureName = (FeatureDefs[Spring.GetFeatureDefID(featureID)].name or "nil") - local x, y, z = Spring.GetFeaturePosition(featureID) - local r = Spring.GetFeatureHeading(featureID) - local resurrectas = Spring.GetFeatureResurrect(featureID) + local featureName = (FeatureDefs[SpringShared.GetFeatureDefID(featureID)].name or "nil") + local x, y, z = SpringShared.GetFeaturePosition(featureID) + local r = SpringShared.GetFeatureHeading(featureID) + local resurrectas = SpringShared.GetFeatureResurrect(featureID) if resurrectas then resurrectas = '"' .. resurrectas .. '"' else resurrectas = "nil" end - Spring.Echo(string.format("{name = '%s', x = %d, y = %d, z = %d, rot = %d , scale = 1.0, resurrectas = %s},\n", featureName, x, y, z, r, resurrectas)) --{ name = 'ad0_aleppo_2', x = 2900, z = 52, rot = "-1" }, + SpringShared.Echo(string.format("{name = '%s', x = %d, y = %d, z = %d, rot = %d , scale = 1.0, resurrectas = %s},\n", featureName, x, y, z, r, resurrectas)) --{ name = 'ad0_aleppo_2', x = 2900, z = 52, rot = "-1" }, end end @@ -1119,24 +1119,24 @@ else -- UNSYNCED if not isAuthorized(playerID, "units") then return end - Spring.Echo("Dumping all units") - local units = Spring.GetAllUnits() + SpringShared.Echo("Dumping all units") + local units = SpringShared.GetAllUnits() for k, unitID in pairs(units) do - local unitname = (UnitDefs[Spring.GetUnitDefID(unitID)].name or "nil") - local x, y, z = Spring.GetUnitPosition(unitID) - local r = Spring.GetUnitHeading(unitID) - local tid = Spring.GetUnitTeam(unitID) - local isneutral = tostring(Spring.GetUnitNeutral(unitID)) - Spring.Echo(string.format("{name = '%s', x = %d, y = %d, z = %d, rot = %d , team = %d, neutral = %s},\n", unitname, x, y, z, r, tid, isneutral)) --{ name = 'ad0_aleppo_2', x = 2900, z = 52, rot = "-1" }, + local unitname = (UnitDefs[SpringShared.GetUnitDefID(unitID)].name or "nil") + local x, y, z = SpringShared.GetUnitPosition(unitID) + local r = SpringShared.GetUnitHeading(unitID) + local tid = SpringShared.GetUnitTeam(unitID) + local isneutral = tostring(SpringShared.GetUnitNeutral(unitID)) + SpringShared.Echo(string.format("{name = '%s', x = %d, y = %d, z = %d, rot = %d , team = %d, neutral = %s},\n", unitname, x, y, z, r, tid, isneutral)) --{ name = 'ad0_aleppo_2', x = 2900, z = 52, rot = "-1" }, end end local function centerCamera() - local camState = Spring.GetCameraState() + local camState = SpringUnsynced.GetCameraState() if camState then local mapcx = Game.mapSizeX / 2 local mapcz = Game.mapSizeZ / 2 - local mapcy = Spring.GetGroundHeight(mapcx, mapcz) + local mapcy = SpringShared.GetGroundHeight(mapcx, mapcz) camState["px"] = mapcx camState["py"] = mapcy @@ -1149,7 +1149,7 @@ else -- UNSYNCED camState["dist"] = mapcy + 2000 camState["name"] = "spring" - Spring.SetCameraState(camState, 0.75) + SpringUnsynced.SetCameraState(camState, 0.75) end end @@ -1168,9 +1168,9 @@ else -- UNSYNCED -- Spring.DiffTimers(Spring.GetTimerMicros(),tus) - local lastDrawTimerUS = Spring.GetTimerMicros() - local lastSimTimerUS = Spring.GetTimerMicros() - local lastUpdateTimerUs = Spring.GetTimerMicros() + local lastDrawTimerUS = SpringUnsynced.GetTimerMicros() + local lastSimTimerUS = SpringUnsynced.GetTimerMicros() + local lastUpdateTimerUs = SpringUnsynced.GetTimerMicros() local lastFrameType = "draw" -- can be draw, sim, update local simTime = 0 local drawTime = 0 @@ -1184,31 +1184,31 @@ else -- UNSYNCED local alpha = 0.98 function gadget:ViewResize() - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() uiScale = vsy / 1080 end function gadget:Update() -- START OF UPDATE if fightertestactive then - local now = Spring.GetTimerMicros() + local now = SpringUnsynced.GetTimerMicros() if lastFrameType == "draw" then -- We are doing a double draw else -- We are ending a sim frame, so better push the sim frame time number - simTime = Spring.DiffTimers(now, lastSimTimerUS) + simTime = SpringUnsynced.DiffTimers(now, lastSimTimerUS) fighterteststats.simFrameTimes[#fighterteststats.simFrameTimes + 1] = simTime ss = alpha * ss + (1 - alpha) * simTime end - lastUpdateTimerUs = Spring.GetTimerMicros() + lastUpdateTimerUs = SpringUnsynced.GetTimerMicros() end end function gadget:GameFrame(n) -- START OF SIM FRAME if fightertestactive then - local now = Spring.GetTimerMicros() + local now = SpringUnsynced.GetTimerMicros() if lastFrameType == "sim" then -- We are doing double sim, push a sim frame time number - simTime = Spring.DiffTimers(now, lastSimTimerUS) + simTime = SpringUnsynced.DiffTimers(now, lastSimTimerUS) fighterteststats.simFrameTimes[#fighterteststats.simFrameTimes + 1] = simTime ss = alpha * ss + (1 - alpha) * simTime else -- we are coming off a draw frame @@ -1221,8 +1221,8 @@ else -- UNSYNCED function gadget:DrawGenesis() -- START OF DRAW if fightertestactive then - local now = Spring.GetTimerMicros() - updateTime = Spring.DiffTimers(now, lastUpdateTimerUs) + local now = SpringUnsynced.GetTimerMicros() + updateTime = SpringUnsynced.DiffTimers(now, lastUpdateTimerUs) fighterteststats.updateFrameTimes[#fighterteststats.updateFrameTimes + 1] = updateTime su = alpha * su + (1 - alpha) * updateTime lastDrawTimerUS = now @@ -1231,7 +1231,7 @@ else -- UNSYNCED function gadget:DrawScreenPost() -- END OF DRAW if fightertestactive then - drawTime = Spring.DiffTimers(Spring.GetTimerMicros(), lastDrawTimerUS) + drawTime = SpringUnsynced.DiffTimers(SpringUnsynced.GetTimerMicros(), lastDrawTimerUS) fighterteststats.drawFrameTimes[#fighterteststats.drawFrameTimes + 1] = drawTime sd = alpha * sd + (1 - alpha) * drawTime @@ -1267,14 +1267,14 @@ else -- UNSYNCED if playerID ~= Spring.GetMyPlayerID() then return end - Spring.Echo("Fightertest", line, words, playerID, action) + SpringShared.Echo("Fightertest", line, words, playerID, action) if not isAuthorized(playerID, "terrain") then return end if fightertestactive then -- We need to dump the stats local s1 = string.format("Fightertest complete, #created = %d, #destroyed = %d", fighterteststats.numunitscreated, fighterteststats.numunitsdestroyed) - Spring.Echo(s1) + SpringShared.Echo(s1) local res = {} local stats = {} for n, t in pairs({ Sim = fighterteststats.simFrameTimes, Draw = fighterteststats.drawFrameTimes, Update = fighterteststats.updateFrameTimes }) do @@ -1318,7 +1318,7 @@ else -- UNSYNCED local s2 = string.format("%s %d frames, %3.2fms per frame, %4.2fs total", n, ms.count, ms.mean, ms.total) res[#res + 1] = s2 - Spring.Echo(s2) + SpringShared.Echo(s2) end if isBenchMark then @@ -1331,24 +1331,24 @@ else -- UNSYNCED stats.cpu = Platform.hwConfig stats.display = tostring(vsx) .. "x" .. tostring(vsy) - Spring.Echo("Benchmark Results") - Spring.Echo(stats) + SpringShared.Echo("Benchmark Results") + SpringShared.Echo(stats) - if Spring.GetMenuName then + if SpringUnsynced.GetMenuName then local message = Json.encode(stats) --Spring.Echo("Sending Message", message) - Spring.SendLuaMenuMsg("ScenarioGameEnd " .. message) + SpringUnsynced.SendLuaMenuMsg("ScenarioGameEnd " .. message) end end -- clean up --fighterteststats = {} else - Spring.Echo("Starting Fightertest") - if Spring.GetModOptions().scenariooptions then + SpringShared.Echo("Starting Fightertest") + if SpringShared.GetModOptions().scenariooptions then --Spring.Echo("Scenario: Spawning on frame", Spring.GetGameFrame()) - local scenariooptions = string.base64Decode(Spring.GetModOptions().scenariooptions) - Spring.Echo(scenariooptions) + local scenariooptions = string.base64Decode(SpringShared.GetModOptions().scenariooptions) + SpringShared.Echo(scenariooptions) scenariooptions = Json.decode(scenariooptions) if scenariooptions and scenariooptions.benchmarkcommand then --This is where the magic happens! @@ -1365,9 +1365,9 @@ else -- UNSYNCED numunitscreated = 0, numunitsdestroyed = 0, } - lastDrawTimerUS = Spring.GetTimerMicros() - lastSimTimerUS = Spring.GetTimerMicros() - lastUpdateTimerUs = Spring.GetTimerMicros() + lastDrawTimerUS = SpringUnsynced.GetTimerMicros() + lastSimTimerUS = SpringUnsynced.GetTimerMicros() + lastUpdateTimerUs = SpringUnsynced.GetTimerMicros() end fightertestactive = not fightertestactive local msg = PACKET_HEADER .. ":fightertest" @@ -1377,7 +1377,7 @@ else -- UNSYNCED end end centerCamera() - Spring.SendLuaRulesMsg(msg) + SpringUnsynced.SendLuaRulesMsg(msg) end function globallos(_, line, words, playerID, action) @@ -1391,8 +1391,8 @@ else -- UNSYNCED end local globallos = (not words[1] or words[1] ~= "0") or false - Spring.Echo("Globallos: " .. (globallos and "enabled" or "disabled")) - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":globallos:" .. (globallos and " 1" or " 0") .. (words[2] and ":" .. words[2] or "")) + SpringShared.Echo("Globallos: " .. (globallos and "enabled" or "disabled")) + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":globallos:" .. (globallos and " 1" or " 0") .. (words[2] and ":" .. words[2] or "")) end function playertoteam(_, line, words, playerID, action) @@ -1403,14 +1403,14 @@ else -- UNSYNCED return end if not words[1] then - units = Spring.GetSelectedUnits() + units = SpringUnsynced.GetSelectedUnits() if #units > 0 then - words[1] = Spring.GetUnitTeam(units[1]) + words[1] = SpringShared.GetUnitTeam(units[1]) else - local mx, my = Spring.GetMouseState() - local targetType, unitID = Spring.TraceScreenRay(mx, my) + local mx, my = SpringUnsynced.GetMouseState() + local targetType, unitID = SpringUnsynced.TraceScreenRay(mx, my) if targetType == "unit" then - words[1] = Spring.GetUnitTeam(unitID) + words[1] = SpringShared.GetUnitTeam(unitID) end end end @@ -1418,8 +1418,8 @@ else -- UNSYNCED words[2] = words[1] words[1] = Spring.GetMyPlayerID() end - if tonumber(words[2]) < (#Spring.GetTeamList()) - 1 then - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":playertoteam:" .. words[1] .. ":" .. words[2]) + if tonumber(words[2]) < (#SpringShared.GetTeamList()) - 1 then + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":playertoteam:" .. words[1] .. ":" .. words[2]) end end @@ -1433,7 +1433,7 @@ else -- UNSYNCED if not words[1] then return end - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":killteam:" .. words[1]) + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":killteam:" .. words[1]) end function desync(_, line, words, playerID) @@ -1443,8 +1443,8 @@ else -- UNSYNCED if not isAuthorized(playerID, "test") then return end - Spring.Echo("Unsynced: Attempting to trigger a /desync") - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":desync") + SpringShared.Echo("Unsynced: Attempting to trigger a /desync") + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":desync") end function spawnceg(_, line, words, playerID) @@ -1461,16 +1461,16 @@ else -- UNSYNCED if words[2] and tonumber(words[2]) then height = tonumber(words[2]) end - local mx, my = Spring.GetMouseState() - local t, pos = Spring.TraceScreenRay(mx, my, true) + local mx, my = SpringUnsynced.GetMouseState() + local t, pos = SpringUnsynced.TraceScreenRay(mx, my, true) if type(pos) == "table" then local n = 0 local ox, oy, oz = math.floor(pos[1]), math.floor(pos[2] + height), math.floor(pos[3]) local x, y, z = ox, oy, oz local msg = "spawnceg " .. tostring(words[1]) .. " " .. tostring(x) .. " " .. tostring(y) .. " " .. tostring(z) - Spring.Echo("Spawning CEG:", line, playerID, msg) - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":" .. msg) + SpringShared.Echo("Spawning CEG:", line, playerID, msg) + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":" .. msg) end end @@ -1483,14 +1483,14 @@ else -- UNSYNCED if not isAuthorized(playerID, "units") then return end - local mx, my = Spring.GetMouseState() - local t, pos = Spring.TraceScreenRay(mx, my, true) + local mx, my = SpringUnsynced.GetMouseState() + local t, pos = SpringUnsynced.TraceScreenRay(mx, my, true) local ox, oy, oz = math.floor(pos[1]), math.floor(pos[2]), math.floor(pos[3]) local x, y, z = ox, oy, oz local msg = "spawnunitexplosion " .. tostring(words[1]) .. " " .. tostring(x) .. " " .. tostring(y) .. " " .. tostring(z) .. ((words[2] and words[2] == "1") and " 1" or " 0") --Spring.Echo('Spawning unit explosion:', line, playerID, msg) - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":" .. msg) + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":" .. msg) end function GiveCat(_, line, words, playerID) @@ -1522,23 +1522,23 @@ else -- UNSYNCED end end collectBuildOptions(rootDef.id, 0) - Spring.Echo("givecat: giving " .. #result .. " unique units from '" .. unitName .. "'") + SpringShared.Echo("givecat: giving " .. #result .. " unique units from '" .. unitName .. "'") if #result == 0 then return end - local _, _, _, teamID = Spring.GetPlayerInfo(Spring.GetMyPlayerID(), false) + local _, _, _, teamID = SpringShared.GetPlayerInfo(Spring.GetMyPlayerID(), false) if words[2] and tonumber(words[2]) then teamID = tonumber(words[2]) end - local mx, my = Spring.GetMouseState() - local t, pos = Spring.TraceScreenRay(mx, my, true) + local mx, my = SpringUnsynced.GetMouseState() + local t, pos = SpringUnsynced.TraceScreenRay(mx, my, true) if type(pos) == "table" then local x, z = math.floor(pos[1]), math.floor(pos[3]) local msg = "givecat " .. x .. " " .. z .. " " .. teamID for _, uDID in ipairs(result) do msg = msg .. " " .. uDID end - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":" .. msg) + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":" .. msg) end return end @@ -1704,7 +1704,7 @@ else -- UNSYNCED end -- team - local _, _, _, teamID = Spring.GetPlayerInfo(Spring.GetMyPlayerID(), false) + local _, _, _, teamID = SpringShared.GetPlayerInfo(Spring.GetMyPlayerID(), false) if string.match(line, " ([0-9].*)") then teamID = string.match(line, " ([0-9].*)") end @@ -1732,13 +1732,13 @@ else -- UNSYNCED end end - Spring.Echo("givecat found " .. #giveUnits .. " units") + SpringShared.Echo("givecat found " .. #giveUnits .. " units") if #giveUnits == 0 then return end - local mx, my = Spring.GetMouseState() - local t, pos = Spring.TraceScreenRay(mx, my, true) + local mx, my = SpringUnsynced.GetMouseState() + local t, pos = SpringUnsynced.TraceScreenRay(mx, my, true) if type(pos) == "table" then local n = 0 local ox, oz = math.floor(pos[1]), math.floor(pos[3]) @@ -1749,7 +1749,7 @@ else -- UNSYNCED msg = msg .. " " .. uDID end - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":" .. msg) + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":" .. msg) end end diff --git a/luarules/gadgets/cmd_factory_stop_production.lua b/luarules/gadgets/cmd_factory_stop_production.lua index 5be8882eb46..f0f4fa9ad27 100644 --- a/luarules/gadgets/cmd_factory_stop_production.lua +++ b/luarules/gadgets/cmd_factory_stop_production.lua @@ -24,9 +24,9 @@ if gadgetHandler:IsSyncedCode() then end end - local spGetRealBuildQueue = Spring.GetRealBuildQueue - local spGiveOrderToUnit = Spring.GiveOrderToUnit - local spInsertUnitCmdDesc = Spring.InsertUnitCmdDesc + local spGetRealBuildQueue = SpringShared.GetRealBuildQueue + local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit + local spInsertUnitCmdDesc = SpringSynced.InsertUnitCmdDesc local CMD_STOP_PRODUCTION = GameCMD.STOP_PRODUCTION local CMD_WAIT = CMD.WAIT @@ -86,7 +86,7 @@ if gadgetHandler:IsSyncedCode() then end local keepDefID if total > 1 then - local firstCommand = Spring.GetFactoryCommands(unitID, 1) + local firstCommand = SpringShared.GetFactoryCommands(unitID, 1) local firstID = firstCommand[1]["id"] if firstID < 0 then keepDefID = -firstID @@ -120,22 +120,22 @@ if gadgetHandler:IsSyncedCode() then function gadget:Initialize() gadgetHandler:RegisterCMDID(CMD_STOP_PRODUCTION) gadgetHandler:RegisterAllowCommand(CMD_STOP_PRODUCTION) - for _, unitID in pairs(Spring.GetAllUnits()) do - gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID)) + for _, unitID in pairs(SpringShared.GetAllUnits()) do + gadget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID)) end end else local myTeamID, isSpec local function stopProduction(_, unitID, unitDefID, unitTeam, cmdID) - if isSpec or Spring.AreTeamsAllied(unitTeam, myTeamID) then + if isSpec or SpringShared.AreTeamsAllied(unitTeam, myTeamID) then Script.LuaUI.UnitCommand(unitID, unitDefID, unitTeam, cmdID, {}, { coded = 0 }) end end function gadget:PlayerChanged() myTeamID = Spring.GetMyTeamID() - isSpec = Spring.GetSpectatingState() + isSpec = SpringUnsynced.GetSpectatingState() end function gadget:Initialize() diff --git a/luarules/gadgets/cmd_get_player_data.lua b/luarules/gadgets/cmd_get_player_data.lua index e4dfcb9fb76..cf2d121678a 100644 --- a/luarules/gadgets/cmd_get_player_data.lua +++ b/luarules/gadgets/cmd_get_player_data.lua @@ -32,7 +32,7 @@ if gadgetHandler:IsSyncedCode() then function gadget:RecvLuaMsg(msg, player) if msg:sub(3, 4) == validation then if msg:sub(1, 2) == "sd" then - local name = Spring.GetPlayerInfo(player, false) + local name = SpringShared.GetPlayerInfo(player, false) -- Extract requestingPlayerID from position 5 onwards until first semicolon local semicolonPos = string.find(msg, ";", 5) local requestingPlayerID = string.sub(msg, 5, semicolonPos - 1) @@ -66,15 +66,15 @@ else local screenshotCompressedBytes = 0 -- Font - local fontfile = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") - local vsx, vsy = Spring.GetViewGeometry() + local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") + local vsx, vsy = SpringUnsynced.GetViewGeometry() local uiScale = math.max(vsy / 1080, 1) local fontfileSize = 26 local fontfileOutlineSize = 9 local fontfileOutlineStrength = 1.7 local myPlayerID = Spring.GetMyPlayerID() - local myPlayerName = Spring.GetPlayerInfo(myPlayerID) + local myPlayerName = SpringShared.GetPlayerInfo(myPlayerID) local accountID = Spring.Utilities.GetAccountID(myPlayerID) local authorized = SYNCED.permissions.playerdata[accountID] @@ -100,7 +100,7 @@ else end function gadget:ViewResize() - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() uiScale = math.max(vsy / 1080, 1) -- Reload font @@ -115,8 +115,8 @@ else end local function getPlayerIdFromName(targetPlayerName) - for _, pID in ipairs(Spring.GetPlayerList()) do - local name = Spring.GetPlayerInfo(pID, false) + for _, pID in ipairs(SpringShared.GetPlayerList()) do + local name = SpringShared.GetPlayerInfo(pID, false) if name == targetPlayerName then return pID end @@ -133,12 +133,12 @@ else end local targetPlayerID = getPlayerIdFromName(targetPlayerName) if not targetPlayerID then - Spring.Echo("Player not found: " .. targetPlayerName) + SpringShared.Echo("Player not found: " .. targetPlayerName) return end -- Send message to synced code, which will forward to unsynced -- Format: width;targetPlayerID (requestingPlayerID comes from RecvLuaMsg player param) - Spring.SendLuaRulesMsg("ss" .. validation .. width .. ";" .. targetPlayerID) + SpringUnsynced.SendLuaRulesMsg("ss" .. validation .. width .. ";" .. targetPlayerID) end function GetScreenshot(_, line, words, player) @@ -195,8 +195,8 @@ else return end - local _, _, requestingSpec = Spring.GetPlayerInfo(requestingPlayerID, false) - local _, _, mySpec = Spring.GetPlayerInfo(myPlayerID, false) + local _, _, requestingSpec = SpringShared.GetPlayerInfo(requestingPlayerID, false) + local _, _, mySpec = SpringShared.GetPlayerInfo(myPlayerID, false) -- Allow screenshot if: singleplayer OR (requesting player is a spec) OR (I'm a spec) if not isSingleplayer and not requestingSpec and not mySpec then @@ -204,12 +204,12 @@ else end -- Clamp screenshot width to screen width - local vsx, vsy = Spring.GetViewGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() queueScreenShotWidth = math.min(width, vsx) queueScreenShotHeightBatch = math.max(1, math.floor(1500 / queueScreenShotWidth)) queueScreenshot = true - queueScreenshotGameframe = Spring.GetGameFrame() + queueScreenshotGameframe = SpringShared.GetGameFrame() queueScreenShotHeight = math.min(math.floor(queueScreenShotWidth * (vsy / vsx)), vsy) queueScreenShotH = 0 queueScreenShotHmax = queueScreenShotH + queueScreenShotHeightBatch @@ -252,7 +252,7 @@ else -- Second frame: now capture the framebuffer (which includes widgets from previous frame) if not screenshotCaptured then - local vsx, vsy = Spring.GetViewGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() -- Create a full-size texture to capture the current framebuffer local fullSizeTexture = gl.CreateTexture(vsx, vsy, { @@ -344,7 +344,7 @@ else return end - sec = sec + Spring.GetLastUpdateSeconds() + sec = sec + SpringUnsynced.GetLastUpdateSeconds() if sec > 0.03 then sec = 0 @@ -415,7 +415,7 @@ else end local data = finished .. ";" .. queueScreenShotWidth .. ";" .. queueScreenShotHeight .. ";" .. queueScreenshotGameframe .. ";" .. table.concat(queueScreenShotPixels) local message = "sd" .. validation .. queueScreenShotRequestingPlayerID .. ";screenshot;" .. VFS.ZlibCompress(data) - Spring.SendLuaRulesMsg(message) + SpringUnsynced.SendLuaRulesMsg(message) queueScreenShotBroadcastChars = 0 queueScreenShotPixels = {} data = nil @@ -454,7 +454,7 @@ else local playerName = string.sub(remainingMsg, 1, secondSemicolonPos - 1) local data = string.sub(remainingMsg, secondSemicolonPos + 1) - local _, _, mySpec = Spring.GetPlayerInfo(myPlayerID, false) + local _, _, mySpec = SpringShared.GetPlayerInfo(myPlayerID, false) -- data format is "screenshot;compressed_data", and PlayerDataBroadcast expects "playerName;msgType;data" -- So we need to prepend playerName to the data local fullMsg = playerName .. ";" .. data @@ -614,7 +614,7 @@ else if screenshotVars.finished or totalTime - 4000 > screenshotVars.dataLast then screenshotVars.finished = true local compressedKB = screenshotCompressedBytes / 1024 - Spring.Echo(string.format("Received screenshot from %s (%.0f KB, increased replay size)", playerName, compressedKB)) + SpringShared.Echo(string.format("Received screenshot from %s (%.0f KB, increased replay size)", playerName, compressedKB)) screenshotCompressedBytes = 0 local minutes = math.floor((screenshotVars.gameframe / 30 / 60)) @@ -628,22 +628,22 @@ else screenshotVars.pixels = toPixels(screenshotVars.data) screenshotVars.player = playerName screenshotVars.filename = playerName .. "_" .. minutes .. "." .. seconds - if Spring.GetModOptions().date_year then - screenshotVars.filename = Spring.GetModOptions().date_year .. "-" .. Spring.GetModOptions().date_month .. "-" .. Spring.GetModOptions().date_day .. "_" .. screenshotVars.filename + if SpringShared.GetModOptions().date_year then + screenshotVars.filename = SpringShared.GetModOptions().date_year .. "-" .. SpringShared.GetModOptions().date_month .. "-" .. SpringShared.GetModOptions().date_day .. "_" .. screenshotVars.filename else screenshotVars.filename = "_" .. screenshotVars.filename end screenshotVars.filename = string.gsub(screenshotVars.filename, '[<>:"/\\|?*]', "_") -- Get team color for player name - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() local teamID, r, g, b for _, pID in ipairs(playerList) do - local name = Spring.GetPlayerInfo(pID, false) + local name = SpringShared.GetPlayerInfo(pID, false) if name == playerName then - teamID = select(4, Spring.GetPlayerInfo(pID, false)) + teamID = select(4, SpringShared.GetPlayerInfo(pID, false)) if teamID then - r, g, b = Spring.GetTeamColor(teamID) + r, g, b = SpringUnsynced.GetTeamColor(teamID) end break end @@ -710,7 +710,7 @@ else local height = screenshotVars.height + margin + margin + 17 local file = "screenshots/" .. screenshotVars.filename .. ".png" gl.SaveImage(left, bottom, width, height, file) - Spring.Echo("Screenshot saved to: " .. file) + SpringShared.Echo("Screenshot saved to: " .. file) screenshotVars.saveQueued = nil else -- Normal rendering with scaling @@ -722,7 +722,7 @@ else end -- Handle mouse interaction (click anywhere to close) - local mouseX, mouseY, mouseButtonL = Spring.GetMouseState() + local mouseX, mouseY, mouseButtonL = SpringUnsynced.GetMouseState() if screenshotVars.width and mouseButtonL then gl.DeleteList(screenshotVars.dlist) screenshotVars = {} diff --git a/luarules/gadgets/cmd_give.lua b/luarules/gadgets/cmd_give.lua index 769c58a0ad9..6eecf6a7c6f 100644 --- a/luarules/gadgets/cmd_give.lua +++ b/luarules/gadgets/cmd_give.lua @@ -31,8 +31,8 @@ if gadgetHandler:IsSyncedCode() then local startPlayers = {} local function checkStartPlayers() - for _, playerID in ipairs(Spring.GetPlayerList()) do -- update player infos - local playername, _, spec = Spring.GetPlayerInfo(playerID, false) + for _, playerID in ipairs(SpringShared.GetPlayerList()) do -- update player infos + local playername, _, spec = SpringShared.GetPlayerInfo(playerID, false) if not spec then startPlayers[playername] = true end @@ -46,16 +46,16 @@ if gadgetHandler:IsSyncedCode() then end local function giveunits(amount, unitName, teamID, x, z, playerID, xp) - if not Spring.GetTeamInfo(teamID, false) then - Spring.SendMessageToPlayer(playerID, "TeamID '" .. teamID .. "' isn't valid") + if not SpringShared.GetTeamInfo(teamID, false) then + SpringUnsynced.SendMessageToPlayer(playerID, "TeamID '" .. teamID .. "' isn't valid") return end -- give resources if unitName == "metal" or unitName == "energy" then -- Give resources instead of units - Spring.AddTeamResource(teamID, unitName, amount) - Spring.SendMessageToTeam(teamID, "You have been given: " .. amount .. " " .. unitName) - Spring.SendMessageToPlayer(playerID, "You have given team " .. teamID .. ": " .. amount .. " " .. unitName) + SpringSynced.AddTeamResource(teamID, unitName, amount) + SpringUnsynced.SendMessageToTeam(teamID, "You have been given: " .. amount .. " " .. unitName) + SpringUnsynced.SendMessageToPlayer(playerID, "You have given team " .. teamID .. ": " .. amount .. " " .. unitName) return end -- give units @@ -67,49 +67,49 @@ if gadgetHandler:IsSyncedCode() then end end if unitDefID == nil then - Spring.SendMessageToPlayer(playerID, "Unitname '" .. unitName .. "' isnt valid") + SpringUnsynced.SendMessageToPlayer(playerID, "Unitname '" .. unitName .. "' isnt valid") return end local succesfullyCreated = 0 for i = 1, amount do - local unitID = Spring.CreateUnit(unitDefID, x, Spring.GetGroundHeight(x, z), z, 0, teamID) + local unitID = SpringSynced.CreateUnit(unitDefID, x, SpringShared.GetGroundHeight(x, z), z, 0, teamID) if unitID ~= nil then succesfullyCreated = succesfullyCreated + 1 if xp and type(xp) == "number" then - Spring.SetUnitExperience(unitID, xp) + SpringSynced.SetUnitExperience(unitID, xp) end end end if succesfullyCreated > 0 then if isSilentUnitGift[unitDefID] == nil then - Spring.SendMessageToTeam(teamID, "You have been given: " .. succesfullyCreated .. " " .. unitName) + SpringUnsynced.SendMessageToTeam(teamID, "You have been given: " .. succesfullyCreated .. " " .. unitName) end - Spring.SendMessageToPlayer(playerID, "You have given team " .. teamID .. ": " .. succesfullyCreated .. " " .. unitName) + SpringUnsynced.SendMessageToPlayer(playerID, "You have given team " .. teamID .. ": " .. succesfullyCreated .. " " .. unitName) end end function gadget:RecvLuaMsg(msg, playerID) if string.sub(msg, 1, PACKET_HEADER_LENGTH) ~= PACKET_HEADER then return - elseif givenSomethingAtFrame == Spring.GetGameFrame() then + elseif givenSomethingAtFrame == SpringShared.GetGameFrame() then return end - local playername, _, spec = Spring.GetPlayerInfo(playerID) + local playername, _, spec = SpringShared.GetPlayerInfo(playerID) local accountID = Spring.Utilities.GetAccountID(playerID) local authorized = false if _G.permissions.give[accountID] then authorized = true - givenSomethingAtFrame = Spring.GetGameFrame() + givenSomethingAtFrame = SpringShared.GetGameFrame() end if authorized == nil then - Spring.SendMessageToPlayer(playerID, "You are not authorized to give units") + SpringUnsynced.SendMessageToPlayer(playerID, "You are not authorized to give units") return elseif not spec then - Spring.SendMessageToPlayer(playerID, "You arent allowed to give units when playing") + SpringUnsynced.SendMessageToPlayer(playerID, "You arent allowed to give units when playing") return elseif startPlayers[playername] ~= nil then - Spring.SendMessageToPlayer(playerID, "You arent allowed to give units when you have been a player") + SpringUnsynced.SendMessageToPlayer(playerID, "You arent allowed to give units when you have been a player") return end local params = string.split(msg, ":") @@ -125,17 +125,17 @@ else -- UNSYNCED local function RequestGive(cmd, line, words, playerID) if authorized and playerID == myPlayerID then - local mx, my = Spring.GetMouseState() - local targettype, pos = Spring.TraceScreenRay(mx, my) + local mx, my = SpringUnsynced.GetMouseState() + local targettype, pos = SpringUnsynced.TraceScreenRay(mx, my) if targettype == "unit" then - pos = { Spring.GetUnitPosition(pos) } + pos = { SpringShared.GetUnitPosition(pos) } elseif targettype == "feature" then - pos = { Spring.GetFeaturePosition(pos) } + pos = { SpringShared.GetFeaturePosition(pos) } end if type(pos) == "table" and pos[1] ~= nil and pos[3] ~= nil and pos[1] > 0 and pos[3] > 0 and words[1] ~= nil and words[2] ~= nil and words[3] ~= nil then - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":" .. words[1] .. ":" .. words[2] .. ":" .. words[3] .. ":" .. pos[1] .. ":" .. pos[3] .. (words[4] ~= nil and ":" .. words[4] or "")) + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":" .. words[1] .. ":" .. words[2] .. ":" .. words[3] .. ":" .. pos[1] .. ":" .. pos[3] .. (words[4] ~= nil and ":" .. words[4] or "")) else - Spring.SendMessageToPlayer(playerID, "failed to give, check syntax or cursor position") + SpringUnsynced.SendMessageToPlayer(playerID, "failed to give, check syntax or cursor position") end end end diff --git a/luarules/gadgets/cmd_idle_players.lua b/luarules/gadgets/cmd_idle_players.lua index 1784577b355..33302be600a 100644 --- a/luarules/gadgets/cmd_idle_players.lua +++ b/luarules/gadgets/cmd_idle_players.lua @@ -26,7 +26,7 @@ local takeCommand = "take2" local minTimeToTake = 12 -- in seconds local checkQueueTime = 25 -- in seconds -- in chose ingame startpostype, players must place beforehand, so take an action, grace period can be shorter -minTimeToTake = Spring.GetModOptions().startpostype == 2 and 1 or minTimeToTake +minTimeToTake = SpringShared.GetModOptions().startpostype == 2 and 1 or minTimeToTake local AFKMessage = "idleplayers " local AFKMessageSize = #AFKMessage @@ -42,22 +42,22 @@ if gadgetHandler:IsSyncedCode() then local playerInfoTable = {} local currentGameFrame = 0 - local TransferUnit = Spring.TransferUnit - local GetPlayerList = Spring.GetPlayerList - local ShareTeamResource = Spring.ShareTeamResource - local GetTeamResources = Spring.GetTeamResources - local GetPlayerInfo = Spring.GetPlayerInfo - local GetTeamLuaAI = Spring.GetTeamLuaAI - local GetAIInfo = Spring.GetAIInfo - local SetTeamRulesParam = Spring.SetTeamRulesParam - local GetTeamRulesParam = Spring.GetTeamRulesParam - local GetTeamUnits = Spring.GetTeamUnits - local GetTeamInfo = Spring.GetTeamInfo - local GetTeamList = Spring.GetTeamList - local IsCheatingEnabled = Spring.IsCheatingEnabled + local TransferUnit = SpringSynced.TransferUnit + local GetPlayerList = SpringShared.GetPlayerList + local ShareTeamResource = SpringSynced.ShareTeamResource + local GetTeamResources = SpringShared.GetTeamResources + local GetPlayerInfo = SpringShared.GetPlayerInfo + local GetTeamLuaAI = SpringShared.GetTeamLuaAI + local GetAIInfo = SpringShared.GetAIInfo + local SetTeamRulesParam = SpringSynced.SetTeamRulesParam + local GetTeamRulesParam = SpringShared.GetTeamRulesParam + local GetTeamUnits = SpringShared.GetTeamUnits + local GetTeamInfo = SpringShared.GetTeamInfo + local GetTeamList = SpringShared.GetTeamList + local IsCheatingEnabled = SpringShared.IsCheatingEnabled local resourceList = { "metal", "energy" } - local gaiaTeamID = Spring.GetGaiaTeamID() + local gaiaTeamID = SpringShared.GetGaiaTeamID() local gameSpeed = Game.gameSpeed local validation = string.randomString(2) @@ -232,12 +232,12 @@ if gadgetHandler:IsSyncedCode() then else -- UNSYNCED - local GetLastUpdateSeconds = Spring.GetLastUpdateSeconds - local SendLuaRulesMsg = Spring.SendLuaRulesMsg - local GetMouseState = Spring.GetMouseState - local GetGameSeconds = Spring.GetGameSeconds - local GetUnitDefID = Spring.GetUnitDefID - local GetRealBuildQueue = Spring.GetRealBuildQueue + local GetLastUpdateSeconds = SpringUnsynced.GetLastUpdateSeconds + local SendLuaRulesMsg = SpringUnsynced.SendLuaRulesMsg + local GetMouseState = SpringUnsynced.GetMouseState + local GetGameSeconds = SpringShared.GetGameSeconds + local GetUnitDefID = SpringShared.GetUnitDefID + local GetRealBuildQueue = SpringShared.GetRealBuildQueue local min = math.min local max = math.max @@ -254,7 +254,7 @@ else -- UNSYNCED local warningGiven = false local myTeamID = Spring.GetMyTeamID() local myAllyTeamID = Spring.GetMyAllyTeamID() - local gaiaTeamID = Spring.GetGaiaTeamID() + local gaiaTeamID = SpringShared.GetGaiaTeamID() local isBuilder = {} local unitBuildSpeedTime = {} @@ -302,33 +302,33 @@ else -- UNSYNCED local function notifyError(_, playerID, errorKey) if Script.LuaUI("GadgetMessageProxy") then local translationKey = "ui.idlePlayers." .. errorKey - Spring.SendMessageToPlayer(playerID, Script.LuaUI.GadgetMessageProxy(translationKey)) + SpringUnsynced.SendMessageToPlayer(playerID, Script.LuaUI.GadgetMessageProxy(translationKey)) end end local function playerLagging(_, playerName) if Script.LuaUI("GadgetMessageProxy") then - Spring.Echo(Script.LuaUI.GadgetMessageProxy("ui.idlePlayers.lagging", { name = playerName })) + SpringShared.Echo(Script.LuaUI.GadgetMessageProxy("ui.idlePlayers.lagging", { name = playerName })) end end local function playerResumed(_, playerName) if Script.LuaUI("GadgetMessageProxy") then - Spring.Echo(Script.LuaUI.GadgetMessageProxy("ui.idlePlayers.resumed", { name = playerName })) + SpringShared.Echo(Script.LuaUI.GadgetMessageProxy("ui.idlePlayers.resumed", { name = playerName })) end end local function playerAFK(_, allyTeamID, playerName) if Script.LuaUI("GadgetMessageProxy") then local message = Script.LuaUI.GadgetMessageProxy("ui.idlePlayers.afk", { name = playerName }) - Spring.SendMessageToAllyTeam(allyTeamID, message) + SpringUnsynced.SendMessageToAllyTeam(allyTeamID, message) end end local function playerReturned(_, allyTeamID, playerName) if Script.LuaUI("GadgetMessageProxy") then local message = Script.LuaUI.GadgetMessageProxy("ui.idlePlayers.returned", { name = playerName }) - Spring.SendMessageToAllyTeam(allyTeamID, message) + SpringUnsynced.SendMessageToAllyTeam(allyTeamID, message) end end @@ -359,7 +359,7 @@ else -- UNSYNCED if checkQueueTime and GetGameSeconds() > checkQueueTime then local teamID = Spring.GetMyTeamID() - local myUnits = Spring.GetTeamUnits(teamID) + local myUnits = SpringShared.GetTeamUnits(teamID) local queueTime = 0 for i = 1, #myUnits do local unitID = myUnits[i] @@ -391,15 +391,15 @@ else -- UNSYNCED if timer - lastActionTime > maxIdleTreshold - warningPeriod then if not warningGiven then warningGiven = true - local spectator = Spring.GetSpectatingState() + local spectator = SpringUnsynced.GetSpectatingState() if not spectator then -- check first if user has team players... that could possibly take... and then give warning - local teamList = Spring.GetTeamList(myAllyTeamID) + local teamList = SpringShared.GetTeamList(myAllyTeamID) for _, teamID in ipairs(teamList) do - local luaAI = Spring.GetTeamLuaAI(teamID) - local _, leader, isDead, isAiTeam, side, allyTeamID, incomeMultiplier, customTeamKeys = Spring.GetTeamInfo(teamID, false) - if Script.LuaUI("GadgetMessageProxy") and teamID ~= myTeamID and teamID ~= gaiaTeamID and not isDead and not isAiTeam and (not luaAI or luaAI == "") and Spring.GetTeamRulesParam(teamID, "numActivePlayers") > 0 then - Spring.Echo("\255\255\166\166" .. Script.LuaUI.GadgetMessageProxy("ui.idlePlayers.warning")) + local luaAI = SpringShared.GetTeamLuaAI(teamID) + local _, leader, isDead, isAiTeam, side, allyTeamID, incomeMultiplier, customTeamKeys = SpringShared.GetTeamInfo(teamID, false) + if Script.LuaUI("GadgetMessageProxy") and teamID ~= myTeamID and teamID ~= gaiaTeamID and not isDead and not isAiTeam and (not luaAI or luaAI == "") and SpringShared.GetTeamRulesParam(teamID, "numActivePlayers") > 0 then + SpringShared.Echo("\255\255\166\166" .. Script.LuaUI.GadgetMessageProxy("ui.idlePlayers.warning")) break end end diff --git a/luarules/gadgets/cmd_limiter.lua b/luarules/gadgets/cmd_limiter.lua index c3abbb533c4..484a0696a7f 100644 --- a/luarules/gadgets/cmd_limiter.lua +++ b/luarules/gadgets/cmd_limiter.lua @@ -30,15 +30,15 @@ local totalCmdCount = 0 local totalOffence = 0 local offenceFrames = {} -local spec = Spring.GetSpectatingState() +local spec = SpringUnsynced.GetSpectatingState() function gadget:PlayerChanged(playerID) - spec = Spring.GetSpectatingState() + spec = SpringUnsynced.GetSpectatingState() end function gadget:CommandNotify(cmdID, cmdParams, cmdOpts) if cmdID < 0 and not spec then -- is build order if cmdOpts.shift then - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() if offenceFrames[gf] then return true end @@ -50,11 +50,11 @@ function gadget:CommandNotify(cmdID, cmdParams, cmdOpts) if not isSingleplayer then if totalOffence >= maxOffences then --Spring.I18N('ui.cmdlimiter.forceresign') - Spring.Echo("\255\255\040\040YOU QUEUED TOO MUCH BUILDINGS TOO MANY TIMES, YOU HAVE BEEN FORCE RESIGNED!") - Spring.SendCommands("spectator") + SpringShared.Echo("\255\255\040\040YOU QUEUED TOO MUCH BUILDINGS TOO MANY TIMES, YOU HAVE BEEN FORCE RESIGNED!") + SpringUnsynced.SendCommands("spectator") elseif totalOffence >= startWarningOffences then --Spring.I18N('ui.cmdlimiter.forceresignwarning') - Spring.Echo("\255\255\085\085YOU HAVE QUEUED TOO MUCH BUILDINGS IN A SHORT PERIOD, KEEP DOING THIS AND YOU WILL GET AUTO RESIGNED!") + SpringShared.Echo("\255\255\085\085YOU HAVE QUEUED TOO MUCH BUILDINGS IN A SHORT PERIOD, KEEP DOING THIS AND YOU WILL GET AUTO RESIGNED!") end end totalCmdCount = totalCmdCount - mathFloor(maxCommands / 2) -- remove some so user can instantly queue something next without instantly being warned again diff --git a/luarules/gadgets/cmd_luaui_reload.lua b/luarules/gadgets/cmd_luaui_reload.lua index 68a557a68fd..e24fe23ceda 100644 --- a/luarules/gadgets/cmd_luaui_reload.lua +++ b/luarules/gadgets/cmd_luaui_reload.lua @@ -18,7 +18,7 @@ end function LuaUIReload(cmd, line, words, playerID) if playerID and playerID == Spring.GetMyPlayerID() then - Spring.SendCommands("luaui reload") + SpringUnsynced.SendCommands("luaui reload") end end diff --git a/luarules/gadgets/cmd_manual_launch.lua b/luarules/gadgets/cmd_manual_launch.lua index e070b8b5826..ab53c0022b4 100644 --- a/luarules/gadgets/cmd_manual_launch.lua +++ b/luarules/gadgets/cmd_manual_launch.lua @@ -42,9 +42,9 @@ end function gadget:UnitCreated(unitID, unitDefID, teamID) if manualLaunchUnits[unitDefID] then - local manualFireCommand = Spring.FindUnitCmdDesc(unitID, CMD.MANUALFIRE) - Spring.RemoveUnitCmdDesc(unitID, manualFireCommand) - Spring.InsertUnitCmdDesc(unitID, launchCommand) + local manualFireCommand = SpringShared.FindUnitCmdDesc(unitID, CMD.MANUALFIRE) + SpringSynced.RemoveUnitCmdDesc(unitID, manualFireCommand) + SpringSynced.InsertUnitCmdDesc(unitID, launchCommand) end end diff --git a/luarules/gadgets/cmd_mex_denier.lua b/luarules/gadgets/cmd_mex_denier.lua index 8a2a3335b3b..f121311ebf9 100644 --- a/luarules/gadgets/cmd_mex_denier.lua +++ b/luarules/gadgets/cmd_mex_denier.lua @@ -17,12 +17,12 @@ if not gadgetHandler:IsSyncedCode() then return end -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetTeamAllyTeamID = Spring.GetTeamAllyTeamID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetTeamAllyTeamID = SpringShared.GetTeamAllyTeamID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder local gExtractorRadius = Game.extractorRadius @@ -39,7 +39,7 @@ function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD.BUILD) local isMetalMap = GG["resource_spot_finder"].isMetalMap if isMetalMap then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Metal map detected, removing self") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Metal map detected, removing self") gadgetHandler:RemoveGadget(self) end metalSpotsList = GG["resource_spot_finder"].metalSpotsList diff --git a/luarules/gadgets/cmd_mouse_pos_broadcast.lua b/luarules/gadgets/cmd_mouse_pos_broadcast.lua index 862766615fd..a3f978e6d3c 100644 --- a/luarules/gadgets/cmd_mouse_pos_broadcast.lua +++ b/luarules/gadgets/cmd_mouse_pos_broadcast.lua @@ -65,12 +65,12 @@ else -------------------------------------------------------------------------------- - local GetMouseState = Spring.GetMouseState - local TraceScreenRay = Spring.TraceScreenRay - local SendLuaRulesMsg = Spring.SendLuaRulesMsg - local GetSpectatingState = Spring.GetSpectatingState - local GetPlayerInfo = Spring.GetPlayerInfo - local GetLastUpdateSeconds = Spring.GetLastUpdateSeconds + local GetMouseState = SpringUnsynced.GetMouseState + local TraceScreenRay = SpringUnsynced.TraceScreenRay + local SendLuaRulesMsg = SpringUnsynced.SendLuaRulesMsg + local GetSpectatingState = SpringUnsynced.GetSpectatingState + local GetPlayerInfo = SpringShared.GetPlayerInfo + local GetLastUpdateSeconds = SpringUnsynced.GetLastUpdateSeconds local floor = math.floor local abs = math.abs @@ -120,7 +120,7 @@ else function gadget:PlayerChanged(playerID) if playerID == myPlayerID then - spec, _ = Spring.GetSpectatingState() + spec, _ = SpringUnsynced.GetSpectatingState() myAllyTeamID = select(5, GetPlayerInfo(myPlayerID, false)) if spec then saveEach = sendPacketEveryWhenSpec / numMousePos diff --git a/luarules/gadgets/cmd_onoffdesc.lua b/luarules/gadgets/cmd_onoffdesc.lua index 3d9cf4eb38c..dcce121a78f 100644 --- a/luarules/gadgets/cmd_onoffdesc.lua +++ b/luarules/gadgets/cmd_onoffdesc.lua @@ -16,8 +16,8 @@ function gadget:GetInfo() } end -local spEditUnitCmdDesc = Spring.EditUnitCmdDesc -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc +local spEditUnitCmdDesc = SpringSynced.EditUnitCmdDesc +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc VFS.Include("luarules/configs/onoffdescs.lua") onoffNames = {} @@ -39,8 +39,8 @@ function gadget:UnitCreated(unitID, unitDefID) end function gadget:Initialize() - for _, unitID in ipairs(Spring.GetAllUnits()) do - local unitDefID = Spring.GetUnitDefID(unitID) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + local unitDefID = SpringShared.GetUnitDefID(unitID) gadget:UnitCreated(unitID, unitDefID) end end diff --git a/luarules/gadgets/cmd_paused_is_paused.lua b/luarules/gadgets/cmd_paused_is_paused.lua index 9cb72e912fb..2db364492a3 100644 --- a/luarules/gadgets/cmd_paused_is_paused.lua +++ b/luarules/gadgets/cmd_paused_is_paused.lua @@ -1,4 +1,4 @@ -if Spring.GetModOptions().allowpausegameplay or Spring.Utilities.Gametype.IsSinglePlayer() then +if SpringShared.GetModOptions().allowpausegameplay or Spring.Utilities.Gametype.IsSinglePlayer() then return end @@ -27,7 +27,7 @@ function gadget:GamePaused(playerID, isPaused) end function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions, cmdTag, playerID, fromSynced, fromLua) - if paused and not Spring.IsCheatingEnabled() then + if paused and not SpringShared.IsCheatingEnabled() then return false else return true diff --git a/luarules/gadgets/cmd_place_target_on_ground.lua b/luarules/gadgets/cmd_place_target_on_ground.lua index 04113cc4a3e..ad2c3294100 100644 --- a/luarules/gadgets/cmd_place_target_on_ground.lua +++ b/luarules/gadgets/cmd_place_target_on_ground.lua @@ -29,12 +29,12 @@ for uDefID, uDef in pairs(UnitDefs) do end end -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc -local spGetUnitCmdDescs = Spring.GetUnitCmdDescs -local spEditUnitCmdDesc = Spring.EditUnitCmdDesc -local spGetUnitPosition = Spring.GetUnitPosition -local spGetGroundHeight = Spring.GetGroundHeight -local spGiveOrderToUnit = Spring.GiveOrderToUnit +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc +local spGetUnitCmdDescs = SpringShared.GetUnitCmdDescs +local spEditUnitCmdDesc = SpringSynced.EditUnitCmdDesc +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit local CMD_ATTACK = CMD.ATTACK local CMD_UNIT_SET_TARGET = GameCMD.UNIT_SET_TARGET diff --git a/luarules/gadgets/cmd_remove_stop.lua b/luarules/gadgets/cmd_remove_stop.lua index 2e8dc22cd4a..8f6451d5e9e 100644 --- a/luarules/gadgets/cmd_remove_stop.lua +++ b/luarules/gadgets/cmd_remove_stop.lua @@ -16,8 +16,8 @@ function gadget:GetInfo() } end -local spRemoveUnitCmdDesc = Spring.RemoveUnitCmdDesc -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc +local spRemoveUnitCmdDesc = SpringSynced.RemoveUnitCmdDesc +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc local CMD_STOP = CMD.STOP local removeCommands = { @@ -65,8 +65,8 @@ end function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD_STOP) -- load active units - for _, unitID in ipairs(Spring.GetAllUnits()) do - local unitDefID = Spring.GetUnitDefID(unitID) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + local unitDefID = SpringShared.GetUnitDefID(unitID) gadget:UnitCreated(unitID, unitDefID) end end diff --git a/luarules/gadgets/cmd_remove_wait.lua b/luarules/gadgets/cmd_remove_wait.lua index 707ac6db32f..f7876649a75 100644 --- a/luarules/gadgets/cmd_remove_wait.lua +++ b/luarules/gadgets/cmd_remove_wait.lua @@ -16,8 +16,8 @@ function gadget:GetInfo() } end -local spRemoveUnitCmdDesc = Spring.RemoveUnitCmdDesc -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc +local spRemoveUnitCmdDesc = SpringSynced.RemoveUnitCmdDesc +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc local CMD_WAIT = CMD.WAIT local removeCommands = { @@ -65,8 +65,8 @@ end function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD_WAIT) -- load active units - for _, unitID in ipairs(Spring.GetAllUnits()) do - local unitDefID = Spring.GetUnitDefID(unitID) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + local unitDefID = SpringShared.GetUnitDefID(unitID) gadget:UnitCreated(unitID, unitDefID) end end diff --git a/luarules/gadgets/cmd_selected_units.lua b/luarules/gadgets/cmd_selected_units.lua index 37d942e9933..a4b2dae2e96 100644 --- a/luarules/gadgets/cmd_selected_units.lua +++ b/luarules/gadgets/cmd_selected_units.lua @@ -36,12 +36,12 @@ else local floor = math.floor local ZlibCompress = Spring.ZlibCompress local ZlibDeCompress = Spring.ZlibDeCompress - local SendLuaRulesMsg = Spring.SendLuaRulesMsg - local GetSelectedUnits = Spring.GetSelectedUnits - local IsUnitSelected = Spring.IsUnitSelected - local GetSpectatingState = Spring.GetSpectatingState - local GetLastUpdateSeconds = Spring.GetLastUpdateSeconds - local GetPlayerInfo = Spring.GetPlayerInfo + local SendLuaRulesMsg = SpringUnsynced.SendLuaRulesMsg + local GetSelectedUnits = SpringUnsynced.GetSelectedUnits + local IsUnitSelected = SpringUnsynced.IsUnitSelected + local GetSpectatingState = SpringUnsynced.GetSpectatingState + local GetLastUpdateSeconds = SpringUnsynced.GetLastUpdateSeconds + local GetPlayerInfo = SpringShared.GetPlayerInfo local PackU16 = VFS.PackU16 local UnpackU16 = VFS.UnpackU16 diff --git a/luarules/gadgets/cmd_sendcommand.lua b/luarules/gadgets/cmd_sendcommand.lua index ff5a82b509c..418f7b4a425 100644 --- a/luarules/gadgets/cmd_sendcommand.lua +++ b/luarules/gadgets/cmd_sendcommand.lua @@ -23,8 +23,8 @@ if gadgetHandler:IsSyncedCode() then local startPlayers = {} function checkStartPlayers() - for _, playerID in ipairs(Spring.GetPlayerList()) do -- update player infos - local playername, _, spec = Spring.GetPlayerInfo(playerID, false) + for _, playerID in ipairs(SpringShared.GetPlayerList()) do -- update player infos + local playername, _, spec = SpringShared.GetPlayerInfo(playerID, false) if not spec then startPlayers[playername] = true end @@ -41,20 +41,20 @@ if gadgetHandler:IsSyncedCode() then if string.sub(msg, 1, PACKET_HEADER_LENGTH) ~= PACKET_HEADER then return end - local playername, _, spec = Spring.GetPlayerInfo(playerID) + local playername, _, spec = SpringShared.GetPlayerInfo(playerID) local accountID = Spring.Utilities.GetAccountID(playerID) local authorized = false if _G.permissions.cmd[accountID] then authorized = true end if authorized == nil then - Spring.SendMessageToPlayer(playerID, "You are not authorized to send commands for a player") + SpringUnsynced.SendMessageToPlayer(playerID, "You are not authorized to send commands for a player") return elseif not spec then - Spring.SendMessageToPlayer(playerID, "You arent allowed to send commands when playing") + SpringUnsynced.SendMessageToPlayer(playerID, "You arent allowed to send commands when playing") return elseif startPlayers[playername] ~= nil then - Spring.SendMessageToPlayer(playerID, "You arent allowed to send commands when you have been a player") + SpringUnsynced.SendMessageToPlayer(playerID, "You arent allowed to send commands when you have been a player") return end local params = string.split(msg, ":") @@ -69,8 +69,8 @@ else -- UNSYNCED local authorized = SYNCED.permissions.cmd[accountID] local function execCmd(_, playername, cmd) - if playername == select(1, Spring.GetPlayerInfo(Spring.GetMyPlayerID())) or playername == "*" then - Spring.SendCommands(cmd) + if playername == select(1, SpringShared.GetPlayerInfo(Spring.GetMyPlayerID())) or playername == "*" then + SpringUnsynced.SendCommands(cmd) end end @@ -85,9 +85,9 @@ else -- UNSYNCED end end end - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":" .. words[1] .. ":" .. command) + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":" .. words[1] .. ":" .. command) else - Spring.SendMessageToPlayer(playerID, "failed to execute, check syntax") + SpringUnsynced.SendMessageToPlayer(playerID, "failed to execute, check syntax") end end end diff --git a/luarules/gadgets/cmd_undo.lua b/luarules/gadgets/cmd_undo.lua index dbf6cb2c271..371d5b4f12c 100644 --- a/luarules/gadgets/cmd_undo.lua +++ b/luarules/gadgets/cmd_undo.lua @@ -13,7 +13,7 @@ function gadget:GetInfo() } end -if (#Spring.GetTeamList()) - 1 <= 64 then +if (#SpringShared.GetTeamList()) - 1 <= 64 then return end @@ -67,8 +67,8 @@ if gadgetHandler:IsSyncedCode() then local startPlayers = {} local function checkStartPlayers() - for _, playerID in ipairs(Spring.GetPlayerList()) do -- update player infos - local playername, _, spec, teamID = Spring.GetPlayerInfo(playerID, false) + for _, playerID in ipairs(SpringShared.GetPlayerList()) do -- update player infos + local playername, _, spec, teamID = SpringShared.GetPlayerInfo(playerID, false) if not spec then startPlayers[playername] = true end @@ -96,7 +96,7 @@ if gadgetHandler:IsSyncedCode() then teamSelfdUnits[teamID] = cleanedUnits end cleanedUnits = {} - local curGameframe = Spring.GetGameFrame() + local curGameframe = SpringShared.GetGameFrame() for unitID, gameframe in pairs(selfdCmdUnits) do if gameframe > curGameframe - 30 then cleanedUnits[unitID] = gameframe @@ -107,36 +107,36 @@ if gadgetHandler:IsSyncedCode() then -- apply sceduled heightmap restoration if sceduledRestoreHeightmap[gameFrame] ~= nil then for i, params in pairs(sceduledRestoreHeightmap[gameFrame]) do - Spring.RevertHeightMap(params[1], params[2], params[3], params[4], 1) + SpringSynced.RevertHeightMap(params[1], params[2], params[3], params[4], 1) end sceduledRestoreHeightmap[gameFrame] = nil end end function restoreUnits(teamID, seconds, toTeamID, playerID) - if not Spring.GetTeamInfo(toTeamID, false) then + if not SpringShared.GetTeamInfo(toTeamID, false) then return end if teamSelfdUnits[teamID] == nil then - Spring.SendMessageToPlayer(playerID, "There is no self destruct unit history for team " .. teamID) + SpringUnsynced.SendMessageToPlayer(playerID, "There is no self destruct unit history for team " .. teamID) return end - local oldestGameFrame = Spring.GetGameFrame() - (seconds * 30) + local oldestGameFrame = SpringShared.GetGameFrame() - (seconds * 30) local numRestoredUnits = 0 local leftovers = {} for oldUnitID, params in pairs(teamSelfdUnits[teamID]) do if params[1] > oldestGameFrame then -- destroy old unit wreckage if any - local features = Spring.GetFeaturesInCylinder(math.floor(params[4]), math.floor(params[6]), 70) -- using radius larger than 1 cause wreckage can fly off a bit + local features = SpringShared.GetFeaturesInCylinder(math.floor(params[4]), math.floor(params[6]), 70) -- using radius larger than 1 cause wreckage can fly off a bit for i = 1, #features do local featureID = features[i] if UnitDefs[params[2]] ~= nil then local wreckName = UnitDefs[params[2]].wreckName if wreckName ~= nil and FeatureDefNames[wreckName] then local wreckageID = FeatureDefNames[wreckName].id - if wreckageID ~= nil and wreckageID == Spring.GetFeatureDefID(featureID) then - Spring.DestroyFeature(featureID, false) + if wreckageID ~= nil and wreckageID == SpringShared.GetFeatureDefID(featureID) then + SpringSynced.DestroyFeature(featureID, false) break end end @@ -144,23 +144,23 @@ if gadgetHandler:IsSyncedCode() then end -- add unit - local unitID = Spring.CreateUnit(params[2], params[4], Spring.GetGroundHeight(params[4], params[6]), params[6], params[7], toTeamID) + local unitID = SpringSynced.CreateUnit(params[2], params[4], SpringShared.GetGroundHeight(params[4], params[6]), params[6], params[7], toTeamID) if unitID ~= nil then - Spring.SetUnitHealth(unitID, params[3]) - Spring.SetUnitDirection(unitID, params[8], params[9], params[10]) + SpringSynced.SetUnitHealth(unitID, params[3]) + SpringSynced.SetUnitDirection(unitID, params[8], params[9], params[10]) numRestoredUnits = numRestoredUnits + 1 else leftovers[oldUnitID] = params end -- delay ground height restoration cause otherwise it just doesnt work properly - if sceduledRestoreHeightmap[Spring.GetGameFrame() + 15] == nil then - sceduledRestoreHeightmap[Spring.GetGameFrame() + 15] = {} + if sceduledRestoreHeightmap[SpringShared.GetGameFrame() + 15] == nil then + sceduledRestoreHeightmap[SpringShared.GetGameFrame() + 15] = {} end if UnitDefs[params[2]].selfDExplosion ~= nil then local radius = WeaponDefs[WeaponDefNames[UnitDefs[params[2]].selfDExplosion].id].damageAreaOfEffect if radius ~= nil then - sceduledRestoreHeightmap[Spring.GetGameFrame() + 15][#sceduledRestoreHeightmap[Spring.GetGameFrame() + 15] + 1] = { params[4] - radius, params[6] - radius, params[4] + radius, params[6] + radius } + sceduledRestoreHeightmap[SpringShared.GetGameFrame() + 15][#sceduledRestoreHeightmap[SpringShared.GetGameFrame() + 15] + 1] = { params[4] - radius, params[6] - radius, params[4] + radius, params[6] + radius } --table.insert(sceduledRestoreHeightmap[Spring.GetGameFrame() + 15], {params[4]-radius, params[6]-radius, params[4]+radius, params[6]+radius}) end end @@ -169,7 +169,7 @@ if gadgetHandler:IsSyncedCode() then end end teamSelfdUnits[teamID] = leftovers - Spring.SendMessageToPlayer(playerID, "Restored: " .. numRestoredUnits .. " units") + SpringUnsynced.SendMessageToPlayer(playerID, "Restored: " .. numRestoredUnits .. " units") end function gadget:RecvLuaMsg(msg, playerID) @@ -189,30 +189,30 @@ if gadgetHandler:IsSyncedCode() then end local function notify(message) - for _, playerID in pairs(Spring.GetPlayerList()) do + for _, playerID in pairs(SpringShared.GetPlayerList()) do local accountID = Spring.Utilities.GetAccountID(playerID) if _G.permissions.undo[accountID] then - Spring.SendMessageToPlayer(playerID, message) + SpringUnsynced.SendMessageToPlayer(playerID, message) end end end function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponID, projectileID, attackerID, attackerDefID, attackerTeam) - if safeguardedUnits[unitDefID] and attackerTeam and Spring.AreTeamsAllied(unitTeam, attackerTeam) then - if dgunDef[weaponID] or weaponUnitSelfd[weaponID] or not Spring.GetUnitNearestEnemy(unitID, 1000) then - local _, playerID, _, victimIsAi = Spring.GetTeamInfo(unitTeam, false) - local name = Spring.GetPlayerInfo(playerID, false) - if victimIsAi and Spring.GetGameRulesParam("ainame_" .. unitTeam) then - name = Spring.GetGameRulesParam("ainame_" .. unitTeam) .. " (AI)" + if safeguardedUnits[unitDefID] and attackerTeam and SpringShared.AreTeamsAllied(unitTeam, attackerTeam) then + if dgunDef[weaponID] or weaponUnitSelfd[weaponID] or not SpringShared.GetUnitNearestEnemy(unitID, 1000) then + local _, playerID, _, victimIsAi = SpringShared.GetTeamInfo(unitTeam, false) + local name = SpringShared.GetPlayerInfo(playerID, false) + if victimIsAi and SpringShared.GetGameRulesParam("ainame_" .. unitTeam) then + name = SpringShared.GetGameRulesParam("ainame_" .. unitTeam) .. " (AI)" end name = name or "---" - local _, attackerPlayerID, _, attackerIsAi = Spring.GetTeamInfo(attackerTeam, false) - local attackerName = Spring.GetPlayerInfo(attackerPlayerID, false) - if attackerIsAi and Spring.GetGameRulesParam("ainame_" .. attackerTeam) then - attackerName = Spring.GetGameRulesParam("ainame_" .. attackerTeam) .. " (AI)" + local _, attackerPlayerID, _, attackerIsAi = SpringShared.GetTeamInfo(attackerTeam, false) + local attackerName = SpringShared.GetPlayerInfo(attackerPlayerID, false) + if attackerIsAi and SpringShared.GetGameRulesParam("ainame_" .. attackerTeam) then + attackerName = SpringShared.GetGameRulesParam("ainame_" .. attackerTeam) .. " (AI)" end attackerName = attackerName or "---" - local x, _, z = Spring.GetUnitPosition(unitID) + local x, _, z = SpringShared.GetUnitPosition(unitID) local unitName = UnitDefs[unitDefID].name local atPosition = not x and "" or " (pos: " .. math.floor(math.floor(x / 100) * 100) .. ", " .. math.floor(math.floor(z / 100) * 100) .. ")" --if not attackerIsAi then @@ -230,7 +230,7 @@ if gadgetHandler:IsSyncedCode() then notify("\255\255\100\100 -- ALERT -- " .. attackerName .. " tried to damage " .. name .. "'s " .. unitName .. " (via a SELFD)" .. atPosition) end return 0, 0 - elseif not Spring.GetUnitNearestEnemy(unitID, 1000) then + elseif not SpringShared.GetUnitNearestEnemy(unitID, 1000) then if name == attackerName then notify("\255\255\100\100 -- ALERT -- " .. attackerName .. " tried to damage their own " .. unitName .. " without nearby enemy" .. atPosition) else @@ -247,12 +247,12 @@ if gadgetHandler:IsSyncedCode() then -- log selfd units and all the deaths they caused function gadget:UnitDestroyed(unitID, unitDefID, teamID, attackerID, attackerDefID, attackerTeamID, weaponDefID) if (attackerID == nil and selfdCmdUnits[unitID]) or (attackerID ~= nil and selfdCmdUnits[attackerID]) then -- attackerID == nil -> selfd/reclaim - local ux, uy, uz = Spring.GetUnitPosition(unitID) - local health, maxHealth = Spring.GetUnitHealth(unitID) - local buildFacing = Spring.GetUnitBuildFacing(unitID) - local dx, dy, dz = Spring.GetUnitDirection(unitID) + local ux, uy, uz = SpringShared.GetUnitPosition(unitID) + local health, maxHealth = SpringShared.GetUnitHealth(unitID) + local buildFacing = SpringShared.GetUnitBuildFacing(unitID) + local dx, dy, dz = SpringShared.GetUnitDirection(unitID) if attackerID ~= nil then - selfdCmdUnits[unitID] = Spring.GetGameFrame() - Spring.GetUnitSelfDTime(unitID) + selfdCmdUnits[unitID] = SpringShared.GetGameFrame() - SpringShared.GetUnitSelfDTime(unitID) teamID = lastSelfdTeamID health = maxHealth -- health only applicable to actual selfd units else @@ -261,7 +261,7 @@ if gadgetHandler:IsSyncedCode() then if teamSelfdUnits[teamID] == nil then teamSelfdUnits[teamID] = {} end - teamSelfdUnits[teamID][unitID] = { Spring.GetGameFrame(), unitDefID, health, ux, uy, uz, buildFacing, dx, dy, dz } + teamSelfdUnits[teamID][unitID] = { SpringShared.GetGameFrame(), unitDefID, health, ux, uy, uz, buildFacing, dx, dy, dz } end end @@ -271,7 +271,7 @@ if gadgetHandler:IsSyncedCode() then -- check for queued selfd (to check if queue gets cancelled) if selfdCmdUnits[unitID] then local foundSelfdCmd = false - local unitQueue = Spring.GetUnitCommands(unitID, 20) or {} + local unitQueue = SpringShared.GetUnitCommands(unitID, 20) or {} if #unitQueue > 0 then for i = 1, #unitQueue do local cmd = unitQueue[i] @@ -287,10 +287,10 @@ if gadgetHandler:IsSyncedCode() then end if cmdID == CMD.SELFD then - if Spring.GetUnitSelfDTime(unitID) > 0 then -- since cmd hasnt been cancelled yet + if SpringShared.GetUnitSelfDTime(unitID) > 0 then -- since cmd hasnt been cancelled yet selfdCmdUnits[unitID] = nil else - selfdCmdUnits[unitID] = Spring.GetGameFrame() + selfdCmdUnits[unitID] = SpringShared.GetGameFrame() end end end @@ -313,7 +313,7 @@ else -- UNSYNCED if words[3] ~= nil then targetTeamID = words[3] end - Spring.SendLuaRulesMsg("un" .. validation .. ":" .. words[1] .. ":" .. words[2] .. ":" .. targetTeamID) + SpringUnsynced.SendLuaRulesMsg("un" .. validation .. ":" .. words[1] .. ":" .. words[2] .. ":" .. targetTeamID) end end end diff --git a/luarules/gadgets/cus_gl4.lua b/luarules/gadgets/cus_gl4.lua index 93c50e06dba..c5fe2039a1f 100644 --- a/luarules/gadgets/cus_gl4.lua +++ b/luarules/gadgets/cus_gl4.lua @@ -214,7 +214,7 @@ end -- floats 0-5 are already in use by HealthBars -- Set autoReload.enabled = true to enable on-the-fly editing of shaders. -local autoReload = { enabled = false, vssrc = "", fssrc = "", lastUpdate = Spring.GetTimer(), updateRate = 0.5 } +local autoReload = { enabled = false, vssrc = "", fssrc = "", lastUpdate = SpringUnsynced.GetTimer(), updateRate = 0.5 } -- Indicates wether the first round of getting units should grab all instead of delta local manualReload = autoReload.enabled or false @@ -241,7 +241,7 @@ local function GetUniformBinID(objectDefID, reason) return objectDefToUniformBin[objectDefID] else if debugmode then - Spring.Echo("Failed to find a uniform bin id for objectDefID", objectDefID, reason) + SpringShared.Echo("Failed to find a uniform bin id for objectDefID", objectDefID, reason) end return "otherunit" end @@ -375,7 +375,7 @@ local cusUnitIDtoDrawFlag = {} -- {unitID = drawFlag,...}, these remain positive -- For managing under construction units: local buildProgresses = {} -- keys unitID, value buildprogress, updated each frame for units being built local uniformCache = {} -local spGetUnitHealth = Spring.GetUnitHealth +local spGetUnitHealth = SpringShared.GetUnitHealth -- local processedUnits = {} local cusFeatureIDtoDrawFlag = {} -- {featureID = drawFlag,...}, this remains positive @@ -573,7 +573,7 @@ local itsXmas = false local function initMaterials() defaultMaterialTemplate = VFS.Include("modelmaterials_gl4/templates/defaultMaterialTemplate.lua") if itsXmas then - Spring.Echo("CUS GL4 enabled XMAS mode") + SpringShared.Echo("CUS GL4 enabled XMAS mode") end unitsNormalMapTemplate = appendShaderDefinitionsToTemplate(defaultMaterialTemplate, { @@ -679,15 +679,15 @@ local function dumpShaderCodeToFile(defs, src, filename) -- no IO in unsynced ga end local function dumpShaderCodeToInfolog(defs, src, filename) -- no IO in unsynced gadgets :/ - Spring.Echo(filename) - Spring.Echo(defs) - Spring.Echo(src) + SpringShared.Echo(filename) + SpringShared.Echo(defs) + SpringShared.Echo(src) end local function CompileLuaShader(shader, definitions, plugIns, addName, recompilation) --Spring.Echo(" CompileLuaShader",shader, definitions, plugIns, addName) if definitions == nil or definitions == {} then - Spring.Echo(addName, "nul definitions", definitions) + SpringShared.Echo(addName, "nul definitions", definitions) end definitions = definitions or {} @@ -733,7 +733,7 @@ local function CompileLuaShader(shader, definitions, plugIns, addName, recompila local luaShader = LuaShader(shader, "CUS_" .. addName) local compilationResult = luaShader:Initialize() if compilationResult ~= true then - Spring.Echo("Custom Unit Shaders. " .. addName .. " shader compilation failed") + SpringShared.Echo("Custom Unit Shaders. " .. addName .. " shader compilation failed") --dumpShaderCodeToInfolog(shader.definitions, shader.vertex, "vs" .. addName) --dumpShaderCodeToInfolog(shader.definitions, shader.fragment, "fs" .. addName) if not recompilation then @@ -930,7 +930,7 @@ local knowntrees = VFS.Include("modelmaterials_gl4/known_feature_trees.lua") local function initBinsAndTextures() -- init features first, to gain access to stored wreck textures! - Spring.Echo("[CUS GL4] Init Feature bins") + SpringShared.Echo("[CUS GL4] Init Feature bins") for featureDefID, featureDef in pairs(FeatureDefs) do if featureDef.model then -- this is kind of a hack to work around specific modelless features metalspots found on Otago 1.4 local normalTex = GetNormal(nil, featureDef) @@ -970,7 +970,7 @@ local function initBinsAndTextures() end end --if true then return end - Spring.Echo("[CUS GL4] Init Unit bins") + SpringShared.Echo("[CUS GL4] Init Unit bins") for unitDefID, unitDef in pairs(UnitDefs) do if unitDef.model then local lowercasetex1 = string.lower(unitDef.model.textures.tex1 or "") @@ -1052,7 +1052,7 @@ end local preloadedTextures = false local function PreloadTextures() - Spring.Echo("[CUS GL4] Cache Textures") + SpringShared.Echo("[CUS GL4] Cache Textures") -- init the arm and core wrecks, and wreck normals gl.Texture(0, "unittextures/Arm_wreck_color_normal.dds") --gl.Texture(0, "unittextures/Arm_wreck_color.dds") @@ -1066,7 +1066,7 @@ local function PreloadTextures() --gl.Texture(0, "unittextures/cor_other_wreck.dds") --gl.Texture(0, "unittextures/cor_color_wreck.dds") gl.Texture(0, "unittextures/cor_color_wreck_normal.dds") - if Spring.GetModOptions().experimentallegionfaction then + if SpringShared.GetModOptions().experimentallegionfaction then gl.Texture(0, "unittextures/leg_wreck_normal.dds") end gl.Texture(0, false) @@ -1077,15 +1077,15 @@ local function GetObjectDefName(objectID) if objectID == nil then return "Failed to GetObjectDefName(objectID): " .. tostring(objectID) elseif objectID >= 0 then - if Spring.ValidUnitID(objectID) then - local udid = Spring.GetUnitDefID(objectID) + if SpringShared.ValidUnitID(objectID) then + local udid = SpringShared.GetUnitDefID(objectID) return UnitDefs[udid].name else return "Invalid UnitID:" .. tostring(objectID) end else - if Spring.ValidFeatureID(-1 * objectID) then - local fdid = Spring.GetFeatureDefID(-1 * objectID) + if SpringShared.ValidFeatureID(-1 * objectID) then + local fdid = SpringShared.GetFeatureDefID(-1 * objectID) return FeatureDefs[fdid].name else return "Invalid featuredefid:" .. tostring(objectID) @@ -1110,15 +1110,15 @@ local function AssignObjectToBin(objectID, objectDefID, flag, shader, textures, texKey = texKey or fastObjectDefIDtoTextureKey[objectDefID] if objectDefID == nil then - Spring.Echo("AssignObjectToBin", objectID, objectDefID, flag, shader, textures, texKey, uniformBinID, calledfrom) + SpringShared.Echo("AssignObjectToBin", objectID, objectDefID, flag, shader, textures, texKey, uniformBinID, calledfrom) end uniformBinID = uniformBinID or GetUniformBinID(objectDefID, "AssignObjectToBin") --Spring.Echo("AssignObjectToBin", objectID, objectDefID, flag, shader, textures, texKey, uniformBinID) -- Spring.Debug.TraceFullEcho() if texKey == nil or uniformBinID == nil then if badassigns[objectID] == nil then - Spring.Echo("[CUS GL4]Failure to assign to ", objectID, objectDefID, flag, shader, textures, texKey, uniformBinID, calledfrom) - Spring.Echo("REPORT THIS TO BEHERITH: bad object:", GetObjectDefName(objectID)) + SpringShared.Echo("[CUS GL4]Failure to assign to ", objectID, objectDefID, flag, shader, textures, texKey, uniformBinID, calledfrom) + SpringShared.Echo("REPORT THIS TO BEHERITH: bad object:", GetObjectDefName(objectID)) badassigns[objectID] = true end return @@ -1137,12 +1137,12 @@ local function AssignObjectToBin(objectID, objectDefID, flag, shader, textures, local unitDrawBinsFlagShaderUniforms = unitDrawBinsFlagShader[uniformBinID] if unitDrawBinsFlagShaderUniforms[texKey] == nil then - local t0 = Spring.GetTimerMicros() + local t0 = SpringUnsynced.GetTimerMicros() local mybinVAO = gl.GetVAO() local mybinIBO = gl.GetVBO(GL.ARRAY_BUFFER, true) if (mybinIBO == nil) or (mybinVAO == nil) then - Spring.Echo("Failed to allocate IBO or VAO for CUS GL4", mybinIBO, mybinVAO) + SpringShared.Echo("Failed to allocate IBO or VAO for CUS GL4", mybinIBO, mybinVAO) --Spring.Debug.TraceFullEcho() gadgetHandler:RemoveGadget() return @@ -1179,17 +1179,17 @@ local function AssignObjectToBin(objectID, objectDefID, flag, shader, textures, end end if debugmode then - Spring.Echo("Init of bin", shader, flag, texKey, uniformBinID, "took", Spring.DiffTimers(Spring.GetTimerMicros(), t0, nil), "ms") + SpringShared.Echo("Init of bin", shader, flag, texKey, uniformBinID, "took", SpringUnsynced.DiffTimers(SpringUnsynced.GetTimerMicros(), t0, nil), "ms") end end local unitDrawBinsFlagShaderUniformsTexKey = unitDrawBinsFlagShaderUniforms[texKey] if unitDrawBinsFlagShaderUniformsTexKey.objectsIndex[objectID] then - Spring.Echo("Trying to add a unit to a bin that it is already in!") + SpringShared.Echo("Trying to add a unit to a bin that it is already in!") else if debugmode then - Spring.Echo("AssignObjectToBin success:", objectID, objectDefID, flag, shader, texKey, uniformBinID) + SpringShared.Echo("AssignObjectToBin success:", objectID, objectDefID, flag, shader, texKey, uniformBinID) end end @@ -1212,7 +1212,7 @@ local function AssignObjectToBin(objectID, objectDefID, flag, shader, textures, local newObjectsIndex = {} if (mybinIBO == nil) or (mybinVAO == nil) then - Spring.Echo("Failed to allocate IBO or VAO for CUS GL4", mybinIBO, mybinVAO) + SpringShared.Echo("Failed to allocate IBO or VAO for CUS GL4", mybinIBO, mybinVAO) --Spring.Debug.TraceFullEcho() gadgetHandler:RemoveGadget() return @@ -1237,7 +1237,7 @@ local function AssignObjectToBin(objectID, objectDefID, flag, shader, textures, local objectsArray = unitDrawBinsFlagShaderUniformsTexKey.objectsArray if objectID >= 0 then -- this tells us if we are gonna be using features or units for i, unitID in ipairs(objectsArray) do - if Spring.ValidUnitID(unitID) == true and Spring.GetUnitIsDead(unitID) ~= true then + if SpringShared.ValidUnitID(unitID) == true and SpringShared.GetUnitIsDead(unitID) ~= true then newObjectsCount = newObjectsCount + 1 newObjectsArray[newObjectsCount] = unitID newObjectsIndex[unitID] = newObjectsCount @@ -1251,7 +1251,7 @@ local function AssignObjectToBin(objectID, objectDefID, flag, shader, textures, -- this additional table is needed to allow for one-time translation of negative objectID to featureID local newFeaturesArray = {} for i, featureID in ipairs(objectsArray) do - if Spring.ValidFeatureID(-featureID) then + if SpringShared.ValidFeatureID(-featureID) then newObjectsCount = newObjectsCount + 1 newObjectsArray[newObjectsCount] = featureID newObjectsIndex[featureID] = newObjectsCount @@ -1282,23 +1282,23 @@ local function AssignObjectToBin(objectID, objectDefID, flag, shader, textures, unitDrawBinsFlagShaderUniformsTexKey.objectsIndex[objectID] = numobjects if debugmode and flag == 0 then - Spring.Echo("AssignObjectToBin", objectID, objectDefID, texKey, uniformBinID, shader, flag, numobjects) + SpringShared.Echo("AssignObjectToBin", objectID, objectDefID, texKey, uniformBinID, shader, flag, numobjects) local objids = "objectsArray " for k, v in pairs(unitDrawBinsFlagShaderUniformsTexKey.objectsArray) do objids = objids .. tostring(k) .. ":" .. tostring(v) .. " " end - Spring.Echo(objids) + SpringShared.Echo(objids) end end -local spGetUnitDefID = Spring.GetUnitDefID -local spValidUnitID = Spring.ValidUnitID -local spSetUnitEngineDrawMask = Spring.SetUnitEngineDrawMask -local spGetFeatureDefID = Spring.GetFeatureDefID -local spValidFeatureID = Spring.ValidFeatureID -local spSetFeatureEngineDrawMask = Spring.SetFeatureEngineDrawMask -local spSetFeatureNoDraw = Spring.SetFeatureNoDraw -local spSetFeatureFade = Spring.SetFeatureFade +local spGetUnitDefID = SpringShared.GetUnitDefID +local spValidUnitID = SpringShared.ValidUnitID +local spSetUnitEngineDrawMask = SpringUnsynced.SetUnitEngineDrawMask +local spGetFeatureDefID = SpringShared.GetFeatureDefID +local spValidFeatureID = SpringShared.ValidFeatureID +local spSetFeatureEngineDrawMask = SpringUnsynced.SetFeatureEngineDrawMask +local spSetFeatureNoDraw = SpringUnsynced.SetFeatureNoDraw +local spSetFeatureFade = SpringUnsynced.SetFeatureFade local glSetUnitBufferUniforms = gl.SetUnitBufferUniforms local function AddObject(objectID, drawFlag, reason) @@ -1315,7 +1315,7 @@ local function AddObject(objectID, drawFlag, reason) objectIDtoDefID[objectID] = objectDefID end if debugmode then - Spring.Echo("AddObject", objectID, objectDefID, drawFlag, reason) + SpringShared.Echo("AddObject", objectID, objectDefID, drawFlag, reason) end if objectDefID == nil then return @@ -1347,7 +1347,7 @@ local function AddObject(objectID, drawFlag, reason) end else if spValidFeatureID(-1 * objectID) == false then - Spring.Echo("Invalid feature for drawmask", objectID, objectDefID) + SpringShared.Echo("Invalid feature for drawmask", objectID, objectDefID) end spSetFeatureEngineDrawMask(-1 * objectID, 255 - overrideDrawFlag) -- ~overrideDrawFlag & 255 spSetFeatureNoDraw(-1 * objectID, false) -- ~overrideDrawFlag & 255 @@ -1361,7 +1361,7 @@ local function RemoveObjectFromBin(objectID, objectDefID, texKey, shader, flag, shader = shader or GetShaderName(flag, objectDefID) texKey = texKey or fastObjectDefIDtoTextureKey[objectDefID] if debugmode then - Spring.Echo("RemoveObjectFromBin", objectID, objectDefID, texKey, shader, flag, uniformBinID, reason) + SpringShared.Echo("RemoveObjectFromBin", objectID, objectDefID, texKey, shader, flag, uniformBinID, reason) end if unitDrawBins[flag][shader] then @@ -1387,24 +1387,24 @@ local function RemoveObjectFromBin(objectID, objectDefID, texKey, shader, flag, else local objectIDatEnd = unitDrawBinsFlagShaderTexKey.objectsArray[numobjects] if debugmode and flag == 0 then - Spring.Echo("Moving", objectIDatEnd, "from", numobjects, " to", objectIndex, "while removing", objectID) + SpringShared.Echo("Moving", objectIDatEnd, "from", numobjects, " to", objectIndex, "while removing", objectID) end unitDrawBinsFlagShaderTexKey.objectsIndex[objectID] = nil -- pop back unitDrawBinsFlagShaderTexKey.objectsIndex[objectIDatEnd] = objectIndex -- bring the last objectID to to this one if objectID >= 0 then -- unit - if Spring.ValidUnitID(objectIDatEnd) == true and Spring.GetUnitIsDead(objectIDatEnd) ~= true then + if SpringShared.ValidUnitID(objectIDatEnd) == true and SpringShared.GetUnitIsDead(objectIDatEnd) ~= true then unitDrawBinsFlagShaderTexKey.IBO:InstanceDataFromUnitIDs(objectIDatEnd, objectTypeAttribID, objectIndex - 1) else if debugmode then - Spring.Echo("Tried to remove invalid unitID", objectIDatEnd, "while removing", objectID) + SpringShared.Echo("Tried to remove invalid unitID", objectIDatEnd, "while removing", objectID) end end else -- feauture - if Spring.ValidFeatureID(-objectIDatEnd) == true then + if SpringShared.ValidFeatureID(-objectIDatEnd) == true then unitDrawBinsFlagShaderTexKey.IBO:InstanceDataFromFeatureIDs(-1 * objectIDatEnd, objectTypeAttribID, objectIndex - 1) else if debugmode then - Spring.Echo("Tried to remove invalid featureID", -objectIDatEnd, "while removing", -objectID) + SpringShared.Echo("Tried to remove invalid featureID", -objectIDatEnd, "while removing", -objectID) end end end @@ -1415,7 +1415,7 @@ local function RemoveObjectFromBin(objectID, objectDefID, texKey, shader, flag, end else if debugmode then - Spring.Echo("Failed to find uniformBinID for", objectID, objectDefID, texKey, shader, flag, uniformBinID) + SpringShared.Echo("Failed to find uniformBinID for", objectID, objectDefID, texKey, shader, flag, uniformBinID) end end else @@ -1428,7 +1428,7 @@ local function RemoveObjectFromBin(objectID, objectDefID, texKey, shader, flag, defName = FeatureDefs[-1 * objectDefID].name end end - Spring.Echo("Failed to find shader for", objectID, objectDefID, texKey, shader, flag, uniformBinID, defName) + SpringShared.Echo("Failed to find shader for", objectID, objectDefID, texKey, shader, flag, uniformBinID, defName) end --Spring.Debug.TraceFullEcho(30,30,30) end @@ -1436,7 +1436,7 @@ end local function UpdateObject(objectID, drawFlag, reason) if debugmode then - Spring.Echo("UpdateObject", objectID, drawFlag, reason) + SpringShared.Echo("UpdateObject", objectID, drawFlag, reason) end if drawFlag >= 128 then --icon return @@ -1481,7 +1481,7 @@ end local function RemoveObject(objectID, reason) -- we get pos/neg objectID here --remove the object from every bin and table if debugmode then - Spring.Echo("RemoveObject", objectID, reason) + SpringShared.Echo("RemoveObject", objectID, reason) end local objectDefID = objectIDtoDefID[objectID] if objectDefID == nil then @@ -1510,7 +1510,7 @@ local function RemoveObject(objectID, reason) -- we get pos/neg objectID here break end -- if shadows are off, then dont even try to remove from them if debugmode then - Spring.Echo("RemoveObject Flags", objectID, flag, overrideDrawFlagsCombined[flag]) + SpringShared.Echo("RemoveObject Flags", objectID, flag, overrideDrawFlagsCombined[flag]) end if overrideDrawFlagsCombined[flag] then RemoveObjectFromBin(objectID, objectDefID, texKey, shader, flag, uniformBinID, "removeobject") @@ -1530,8 +1530,8 @@ local function RemoveObject(objectID, reason) -- we get pos/neg objectID here end end -local spGetUnitIsCloaked = Spring.GetUnitIsCloaked -local spValidUnitID = Spring.ValidUnitID +local spGetUnitIsCloaked = SpringShared.GetUnitIsCloaked +local spValidUnitID = SpringShared.ValidUnitID local glSetUnitBufferUniforms = gl.SetUnitBufferUniforms local function ProcessUnits(units, drawFlags, reason) @@ -1540,7 +1540,7 @@ local function ProcessUnits(units, drawFlags, reason) local unitID = units[i] local drawFlag = drawFlags[i] if debugmode then - Spring.Echo("ProcessUnits", unitID, drawFlag, reason) + SpringShared.Echo("ProcessUnits", unitID, drawFlag, reason) end if math_bit_and(drawFlag, 34) > 0 then -- has alpha (2) or alphashadow(32) flag @@ -1580,10 +1580,10 @@ local function ProcessUnits(units, drawFlags, reason) end end -local spValidFeatureID = Spring.ValidFeatureID -local spSetFeatureEngineDrawMask = Spring.SetFeatureEngineDrawMask -local spSetFeatureNoDraw = Spring.SetFeatureNoDraw -local spSetFeatureFade = Spring.SetFeatureFade +local spValidFeatureID = SpringShared.ValidFeatureID +local spSetFeatureEngineDrawMask = SpringUnsynced.SetFeatureEngineDrawMask +local spSetFeatureNoDraw = SpringUnsynced.SetFeatureNoDraw +local spSetFeatureFade = SpringUnsynced.SetFeatureFade local function ProcessFeatures(features, drawFlags, reason) local numFeatures = #features @@ -1729,7 +1729,7 @@ end local function RecompileShaders(recompilation) initMaterials() - Spring.Echo("[CUS GL4] Compiling Shaders") + SpringShared.Echo("[CUS GL4] Compiling Shaders") -- Initialize shaders types like so:: -- shaders[0]['unit_deferred'] = LuaShaderObject compileMaterialShader(unitsNormalMapTemplate, "unit", recompilation) @@ -1744,7 +1744,7 @@ local function initGL4() end if Platform.glHaveGL4 ~= true then - Spring.Echo("[CUS GL4] No GL4 support for this gpu as indicated by Platform.glHaveGL4, disabling.") + SpringShared.Echo("[CUS GL4] No GL4 support for this gpu as indicated by Platform.glHaveGL4, disabling.") return end @@ -1764,7 +1764,7 @@ local function initGL4() [2 + 8] = {}, -- alpha + refraction [16] = {}, -- shadow } - Spring.Echo("[CUS GL4] Initializing materials") + SpringShared.Echo("[CUS GL4] Initializing materials") RecompileShaders() @@ -1772,7 +1772,7 @@ local function initGL4() modelsIndexVBO = gl.GetVBO(GL.ELEMENT_ARRAY_BUFFER, false) if modelsVertexVBO == nil or modelsIndexVBO == nil then - Spring.Echo("CUS GL4 failed to initialize VBO, exiting") + SpringShared.Echo("CUS GL4 failed to initialize VBO, exiting") gadgetHandler:RemoveGadget() return end @@ -1780,14 +1780,14 @@ local function initGL4() modelsVertexVBO:ModelsVBO() modelsIndexVBO:ModelsVBO() - Spring.Echo("[CUS GL4] Initializing bins") + SpringShared.Echo("[CUS GL4] Initializing bins") initBinsAndTextures() - Spring.Echo("[CUS GL4] Collecting units") - Spring.ClearUnitsPreviousDrawFlag() - Spring.ClearFeaturesPreviousDrawFlag() - Spring.Echo("[CUS GL4] Ready") + SpringShared.Echo("[CUS GL4] Collecting units") + SpringUnsynced.ClearUnitsPreviousDrawFlag() + SpringUnsynced.ClearFeaturesPreviousDrawFlag() + SpringShared.Echo("[CUS GL4] Ready") initiated = true end @@ -1799,7 +1799,7 @@ local function ReloadCUSGL4(optName, line, words, playerID) if playerID ~= Spring.GetMyPlayerID() then return end - Spring.Echo("[CustomUnitShadersGL4] Reloading") + SpringShared.Echo("[CustomUnitShadersGL4] Reloading") gadget:Shutdown() gadget:Initialize() initGL4() @@ -1809,7 +1809,7 @@ local function DisableCUSGL4(optName, _, _, playerID) if playerID ~= Spring.GetMyPlayerID() then return end - Spring.Echo("[CustomUnitShadersGL4] Disabling") + SpringShared.Echo("[CustomUnitShadersGL4] Disabling") gadget:Shutdown() end @@ -1843,7 +1843,7 @@ local function CUSGL4updaterate(optName, line, words, playerID) else updaterate = 1 end - Spring.Echo("[CustomUnitShadersGL4] Updaterate set to", updaterate) + SpringShared.Echo("[CustomUnitShadersGL4] Updaterate set to", updaterate) end local function DebugCUSGL4(optName, line, words, playerID) @@ -1851,56 +1851,56 @@ local function DebugCUSGL4(optName, line, words, playerID) return end debugmode = not debugmode - Spring.Echo("[CustomUnitShadersGL4] Debugmode set to", debugmode) + SpringShared.Echo("[CustomUnitShadersGL4] Debugmode set to", debugmode) end local function DumpCUSGL4(optName, line, words, playerID) if playerID ~= Spring.GetMyPlayerID() then return end - Spring.Echo("[CustomUnitShadersGL4] Dumping unit bins:", debugmode) + SpringShared.Echo("[CustomUnitShadersGL4] Dumping unit bins:", debugmode) if unitDrawBins == nil then return end for drawflag, bin in pairs(unitDrawBins) do - Spring.Echo(string.format("%i = { -- drawFlag", drawflag)) + SpringShared.Echo(string.format("%i = { -- drawFlag", drawflag)) for shadername, uniformbin in pairs(bin) do - Spring.Echo(string.format(" %s = { -- shadername", shadername)) + SpringShared.Echo(string.format(" %s = { -- shadername", shadername)) for uniformbinid, texandobjset in pairs(uniformbin) do - Spring.Echo(string.format(" %s = { -- uniformbin", uniformbinid)) + SpringShared.Echo(string.format(" %s = { -- uniformbin", uniformbinid)) for texturekey, minibin in pairs(texandobjset) do - Spring.Echo(string.format(" %i = { -- textureset", texturekey)) + SpringShared.Echo(string.format(" %i = { -- textureset", texturekey)) for minibinattr, minibinvalue in pairs(minibin) do if type(minibinvalue) == "table" then - Spring.Echo(string.format(" %s = {", minibinattr)) + SpringShared.Echo(string.format(" %s = {", minibinattr)) if minibinattr == "objectsIndex" then for k, v in pairs(minibinvalue) do - local objdefname = (k >= 0 and Spring.GetUnitDefID(k) and UnitDefs[Spring.GetUnitDefID(k)].name) or (Spring.GetFeatureDefID(-1 * k) and FeatureDefs[Spring.GetFeatureDefID(-1 * k)].name) or "???" - Spring.Echo(string.format(" %i = %i, --(%s)", k, v, objdefname)) + local objdefname = (k >= 0 and SpringShared.GetUnitDefID(k) and UnitDefs[SpringShared.GetUnitDefID(k)].name) or (SpringShared.GetFeatureDefID(-1 * k) and FeatureDefs[SpringShared.GetFeatureDefID(-1 * k)].name) or "???" + SpringShared.Echo(string.format(" %i = %i, --(%s)", k, v, objdefname)) end elseif minibinattr == "objectsArray" then for k, v in pairs(minibinvalue) do - local objdefname = (v >= 0 and Spring.GetUnitDefID(v) and UnitDefs[Spring.GetUnitDefID(v)].name) or (Spring.GetFeatureDefID(-1 * v) and FeatureDefs[Spring.GetFeatureDefID(-1 * v)].name) or "???" - Spring.Echo(string.format(" %i = %i, --(%s)", k, v, objdefname)) + local objdefname = (v >= 0 and SpringShared.GetUnitDefID(v) and UnitDefs[SpringShared.GetUnitDefID(v)].name) or (SpringShared.GetFeatureDefID(-1 * v) and FeatureDefs[SpringShared.GetFeatureDefID(-1 * v)].name) or "???" + SpringShared.Echo(string.format(" %i = %i, --(%s)", k, v, objdefname)) end else for k, v in pairs(minibinvalue) do - Spring.Echo(string.format(" %s = %s,", tostring(k), tostring(v))) + SpringShared.Echo(string.format(" %s = %s,", tostring(k), tostring(v))) end end - Spring.Echo(" },") + SpringShared.Echo(" },") else - Spring.Echo(string.format(" %s = %s,", tostring(minibinattr), tostring(minibinvalue))) + SpringShared.Echo(string.format(" %s = %s,", tostring(minibinattr), tostring(minibinvalue))) end end - Spring.Echo(" },") + SpringShared.Echo(" },") end - Spring.Echo(" },") + SpringShared.Echo(" },") end - Spring.Echo(" },") + SpringShared.Echo(" },") end - Spring.Echo("},") + SpringShared.Echo("},") end end @@ -1908,7 +1908,7 @@ local function MarkBinCUSGL4(optName, line, words, playerID) if playerID ~= Spring.GetMyPlayerID() then return end - Spring.Echo("[CustomUnitShadersGL4] Marking Bins", optName, line, words, playerID) + SpringShared.Echo("[CustomUnitShadersGL4] Marking Bins", optName, line, words, playerID) local passnum = tonumber(line) if passnum == nil then return @@ -1923,19 +1923,19 @@ local function MarkBinCUSGL4(optName, line, words, playerID) for objectID, _ in pairs(minibin.objectsIndex) do local px, py, pz if objectID > 0 then - px, py, pz = Spring.GetUnitPosition(objectID) + px, py, pz = SpringShared.GetUnitPosition(objectID) else - px, py, pz = Spring.GetFeaturePosition(-1 * objectID) + px, py, pz = SpringShared.GetFeaturePosition(-1 * objectID) end if px then - Spring.MarkerAddPoint(px, py, pz, tostring(drawPass) .. "/" .. tostring(shadername) .. "/" .. tostring(uniformbinid) .. "/" .. tostring(texturekey) .. "/" .. tostring(objectID)) + SpringUnsynced.MarkerAddPoint(px, py, pz, tostring(drawPass) .. "/" .. tostring(shadername) .. "/" .. tostring(uniformbinid) .. "/" .. tostring(texturekey) .. "/" .. tostring(objectID)) count = count + 1 end end end end end - Spring.Echo("Added markers for", count, "units in drawPass", drawPass) + SpringShared.Echo("Added markers for", count, "units in drawPass", drawPass) end markBin(passnum) @@ -1944,7 +1944,7 @@ end local function FreeTextures() -- pre we are using 2200mb -- free all raptor texes -- free all pilha texes - Spring.Echo("Freeing textures") + SpringShared.Echo("Freeing textures") --delete raptor texes if no raptors are present for unitDefID, uniformBin in pairs(objectDefToUniformBin) do if uniformBin == "raptor" then @@ -1952,12 +1952,12 @@ local function FreeTextures() -- pre we are using 2200mb local s1 = gl.DeleteTexture(textureTable[0]) local s2 = gl.DeleteTexture(textureTable[1]) - Spring.Echo("Freeing ", textureTable[0], textureTable[1], s1, s2) + SpringShared.Echo("Freeing ", textureTable[0], textureTable[1], s1, s2) end end -- delete feature texes if not present, except wrecks of course - local features = Spring.GetAllFeatures() + local features = SpringShared.GetAllFeatures() local delFeatureDefs = {} for featureDefID, featureDef in pairs(FeatureDefs) do @@ -1965,7 +1965,7 @@ local function FreeTextures() -- pre we are using 2200mb end for i, featureID in ipairs(features) do - local existingFeatureDefID = Spring.GetFeatureDefID(featureID) + local existingFeatureDefID = SpringShared.GetFeatureDefID(featureID) delFeatureDefs[existingFeatureDefID] = false end @@ -1974,15 +1974,15 @@ local function FreeTextures() -- pre we are using 2200mb local s1 = gl.DeleteTexture(textureTable[0]) local s2 = gl.DeleteTexture(textureTable[1]) - Spring.Echo("Freeing ", textureTable[0], textureTable[1], s1, s2) + SpringShared.Echo("Freeing ", textureTable[0], textureTable[1], s1, s2) end - Spring.Echo("RawDelete") + SpringShared.Echo("RawDelete") local unittexfiles = VFS.DirList("unittextures/") for i, fname in ipairs(unittexfiles) do if string.find(fname, "chicken", nil, true) then local s1 = gl.DeleteTexture(fname) - Spring.Echo("Freeing ", fname, s1) + SpringShared.Echo("Freeing ", fname, s1) end @@ -1998,7 +1998,7 @@ function gadget:Initialize() gadgetHandler:AddChatAction("dumpcusgl4", DumpCUSGL4) gadgetHandler:AddChatAction("markbincusgl4", MarkBinCUSGL4) gadgetHandler:AddChatAction("freetextures", FreeTextures) - if not initiated and tonumber(Spring.GetConfigInt("cus2", 1) or 1) == 1 then + if not initiated and tonumber(SpringUnsynced.GetConfigInt("cus2", 1) or 1) == 1 then initGL4() end @@ -2020,7 +2020,7 @@ end function gadget:Shutdown() if debugmode then - Spring.Echo(unitDrawBins, "unitDrawBins") + SpringShared.Echo(unitDrawBins, "unitDrawBins") end for unitID, _ in pairs(cusUnitIDtoDrawFlag) do @@ -2113,7 +2113,7 @@ end function gadget:UnitFinished(unitID) gl.SetUnitBufferUniforms(unitID, { -1 }, 0) -- set build progress to built buildProgresses[unitID] = nil - UpdateUnit(unitID, Spring.GetUnitDrawFlag(unitID)) + UpdateUnit(unitID, SpringUnsynced.GetUnitDrawFlag(unitID)) end local unitDefModelMaxY = {} @@ -2130,40 +2130,40 @@ function gadget:UnitCreated(unitID, unitDefID) gl.SetUnitBufferUniforms(unitID, uniformCache, 12) -- clear cloak effect gl.SetUnitBufferUniforms(unitID, uniformCache, 6) -- clear selectedness effect - UpdateUnit(unitID, Spring.GetUnitDrawFlag(unitID)) + UpdateUnit(unitID, SpringUnsynced.GetUnitDrawFlag(unitID)) end function gadget:UnitGiven(unitID) - local flag = Spring.GetUnitDrawFlag(unitID) + local flag = SpringUnsynced.GetUnitDrawFlag(unitID) if flag > 0 and flag < 128 then UpdateUnit(unitID, 0) - UpdateUnit(unitID, Spring.GetUnitDrawFlag(unitID)) + UpdateUnit(unitID, SpringUnsynced.GetUnitDrawFlag(unitID)) end end function gadget:UnitGiven(unitID) - local flag = Spring.GetUnitDrawFlag(unitID) + local flag = SpringUnsynced.GetUnitDrawFlag(unitID) if flag > 0 and flag < 128 then UpdateUnit(unitID, 0) - UpdateUnit(unitID, Spring.GetUnitDrawFlag(unitID)) + UpdateUnit(unitID, SpringUnsynced.GetUnitDrawFlag(unitID)) end end function gadget:UnitCloaked(unitID) - uniformCache[1] = Spring.GetGameFrame() + uniformCache[1] = SpringShared.GetGameFrame() gl.SetUnitBufferUniforms(unitID, uniformCache, 12) - UpdateUnit(unitID, Spring.GetUnitDrawFlag(unitID)) + UpdateUnit(unitID, SpringUnsynced.GetUnitDrawFlag(unitID)) if debugmode then - Spring.Echo("UnitCloaked", unitID, Spring.GetUnitDrawFlag(unitID)) + SpringShared.Echo("UnitCloaked", unitID, SpringUnsynced.GetUnitDrawFlag(unitID)) end end function gadget:UnitDecloaked(unitID) - UpdateUnit(unitID, Spring.GetUnitDrawFlag(unitID)) - uniformCache[1] = -1 * Spring.GetGameFrame() + UpdateUnit(unitID, SpringUnsynced.GetUnitDrawFlag(unitID)) + uniformCache[1] = -1 * SpringShared.GetGameFrame() gl.SetUnitBufferUniforms(unitID, uniformCache, 12) if debugmode then - Spring.Echo("UnitDecloaked", unitID, Spring.GetUnitDrawFlag(unitID)) + SpringShared.Echo("UnitDecloaked", unitID, SpringUnsynced.GetUnitDrawFlag(unitID)) end end @@ -2183,19 +2183,19 @@ function gadget:DrawWorldPreUnit() updateframe = (updateframe + 1) % updaterate if updateframe == 0 then - local t0 = Spring.GetTimerMicros() + local t0 = SpringUnsynced.GetTimerMicros() local units, drawFlagsUnits, features, drawFlagsFeatures if autoReload.enabled then - if Spring.DiffTimers(Spring.GetTimer(), autoReload.lastUpdate) > autoReload.updateRate then + if SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), autoReload.lastUpdate) > autoReload.updateRate then -- Check for fs and vs src identity - autoReload.lastUpdate = Spring.GetTimer() + autoReload.lastUpdate = SpringUnsynced.GetTimer() local defaulttemplate = VFS.Include("modelmaterials_gl4/templates/defaultMaterialTemplate.lua") if (defaulttemplate.shader.vertex ~= defaultMaterialTemplate.shader.vertex) or (defaulttemplate.shader.fragment ~= defaultMaterialTemplate.shader.fragment) then -- recompile on change: - Spring.Echo("Changes to CUS shaders detected, recompiling...") + SpringShared.Echo("Changes to CUS shaders detected, recompiling...") RecompileShaders(true) end end @@ -2203,11 +2203,11 @@ function gadget:DrawWorldPreUnit() if manualReload then manualReload = false - units, drawFlagsUnits = Spring.GetRenderUnits(overrideDrawFlag, true) - features, drawFlagsFeatures = Spring.GetRenderFeatures(overrideDrawFlag, true) + units, drawFlagsUnits = SpringUnsynced.GetRenderUnits(overrideDrawFlag, true) + features, drawFlagsFeatures = SpringUnsynced.GetRenderFeatures(overrideDrawFlag, true) else - units, drawFlagsUnits = Spring.GetRenderUnitsDrawFlagChanged(true) - features, drawFlagsFeatures = Spring.GetRenderFeaturesDrawFlagChanged(true) + units, drawFlagsUnits = SpringUnsynced.GetRenderUnitsDrawFlagChanged(true) + features, drawFlagsFeatures = SpringUnsynced.GetRenderFeaturesDrawFlagChanged(true) end --if (Spring.GetGameFrame() % 31) == 0 then @@ -2218,7 +2218,7 @@ function gadget:DrawWorldPreUnit() -- Why do we also do this processing round if #units > 0? if debugmode and (#destroyedUnitIDs > 0 or #units > 0) then - Spring.Echo("Processing destroyedUnitIDs", #units, #destroyedUnitIDs) + SpringShared.Echo("Processing destroyedUnitIDs", #units, #destroyedUnitIDs) end if numdestroyedUnits > 0 then ProcessUnits(destroyedUnitIDs, destroyedUnitDrawFlags, "destroyed") @@ -2239,12 +2239,12 @@ function gadget:DrawWorldPreUnit() numdestroyedFeatures = 0 end if firstDraw then - local firstfeatures = Spring.GetVisibleFeatures() + local firstfeatures = SpringUnsynced.GetVisibleFeatures() local firstdrawFlagsFeatures = {} local validFirstFeatures = {} local numfirstfeatures = 0 for i, featureID in ipairs(firstfeatures) do - local flag = Spring.GetFeatureDrawFlag(featureID) + local flag = SpringUnsynced.GetFeatureDrawFlag(featureID) if flag and flag > 0 then numfirstfeatures = numfirstfeatures + 1 validFirstFeatures[numfirstfeatures] = featureID @@ -2254,7 +2254,7 @@ function gadget:DrawWorldPreUnit() end ProcessFeatures(validFirstFeatures, firstdrawFlagsFeatures, "firstDraw") - local firstunits = Spring.GetVisibleUnits() + local firstunits = SpringUnsynced.GetVisibleUnits() local firstdrawFlagsUnits = {} for i, unitID in ipairs(firstunits) do firstdrawFlagsUnits[i] = 1 + 4 + 16 @@ -2267,11 +2267,11 @@ function gadget:DrawWorldPreUnit() ProcessUnits(units, drawFlagsUnits, "changed") ProcessFeatures(features, drawFlagsFeatures, "changed") - local deltat = Spring.DiffTimers(Spring.GetTimerMicros(), t0, nil) -- in ms + local deltat = SpringUnsynced.DiffTimers(SpringUnsynced.GetTimerMicros(), t0, nil) -- in ms --Spring.Echo(deltat) if (deltat > 2) and perfdebug then local usecperobjectchange = (1000 * deltat) / totalobjects - Spring.Echo("[CUS GL4] [", Spring.GetDrawFrame(), "]", totalobjects, " Update time 2 < ", deltat, string.format("ms, per object change: %.2fus ", usecperobjectchange), totalobjects, "objs") + SpringShared.Echo("[CUS GL4] [", SpringUnsynced.GetDrawFrame(), "]", totalobjects, " Update time 2 < ", deltat, string.format("ms, per object change: %.2fus ", usecperobjectchange), totalobjects, "objs") -- PERF CONCULUSION: -- Additions of units are about 30 uS -- Removals of units is about 50 uS @@ -2294,7 +2294,7 @@ end local nightFactorBins = { tree = 1.3, feature = 1.3, featurepbr = 1.3, treepbr = 1.3 } local lastSunChanged = -1 function gadget:SunChanged() -- Note that map_nightmode.lua gadget has to change sun twice in a single draw frame to update all - local df = Spring.GetDrawFrame() + local df = SpringUnsynced.GetDrawFrame() if df == lastSunChanged then return end diff --git a/luarules/gadgets/dbg_buildicons_run.lua b/luarules/gadgets/dbg_buildicons_run.lua index 0adbf88f6fa..d0bff638d67 100644 --- a/luarules/gadgets/dbg_buildicons_run.lua +++ b/luarules/gadgets/dbg_buildicons_run.lua @@ -44,13 +44,13 @@ local animationFrames = 120 local nextFrame, unitnumber function buildslowly(_, _, params) - nextFrame = Spring.GetGameFrame() + nextFrame = SpringShared.GetGameFrame() if #params == 1 then if type(tonumber(params[1])) == "number" then index = tonumber(params[1]) end end - Spring.Echo("building icons all slow-like, starting from " .. index) + SpringShared.Echo("building icons all slow-like, starting from " .. index) local counter = 1 for unitName, unitdefname in pairs(UnitDefNames) do @@ -86,7 +86,7 @@ function buildUnitAnim(unitName) end function buildanim(_, _, params) - nextFrame = Spring.GetGameFrame() + nextFrame = SpringShared.GetGameFrame() if #params == 1 then local unitName = params[1] if type(tonumber(params[1])) == "number" then @@ -100,7 +100,7 @@ function buildanim(_, _, params) end end end - Spring.Echo("building icon with animation frames all slow-like, starting from " .. index) + SpringShared.Echo("building icon with animation frames all slow-like, starting from " .. index) local filepath = "../buildicons/__256x256/" .. unitName .. ".png" if VFS.FileExists(filepath, VFS.RAW) then @@ -113,13 +113,13 @@ function buildanim(_, _, params) end function buildanimslowly(_, _, params) - nextFrame = Spring.GetGameFrame() + nextFrame = SpringShared.GetGameFrame() if #params == 1 then if type(tonumber(params[1])) == "number" then unitnumber = tonumber(params[1]) end end - Spring.Echo("building icons with animation frames all slow-like, starting from " .. index) + SpringShared.Echo("building icons with animation frames all slow-like, starting from " .. index) local counter = 1 for unitName, _ in pairs(UnitDefNames) do @@ -127,10 +127,10 @@ function buildanimslowly(_, _, params) if not unitnumber or counter >= unitnumber then local filepath = "../buildicons/256x256/" .. unitName .. ".png" if VFS.FileExists(filepath, VFS.RAW) then - Spring.Echo("File exists for: " .. unitName .. " " .. filepath) + SpringShared.Echo("File exists for: " .. unitName .. " " .. filepath) else if not skipUnits[unitName] then - Spring.Echo("Building filepath: " .. filepath) + SpringShared.Echo("Building filepath: " .. filepath) buildUnitAnim(unitName) end end @@ -170,7 +170,7 @@ local unitConfigs = { -- copy from configs/icon_generator.lua, included.. becaus } function gadget:GameFrame(n) if nextFrame and n > nextFrame and index <= #unitnames then - Spring.SendCommands("luarules buildicon " .. unitnames[index]) + SpringUnsynced.SendCommands("luarules buildicon " .. unitnames[index]) index = index + 1 counter = counter + 1 diff --git a/luarules/gadgets/dbg_cob_debug.lua b/luarules/gadgets/dbg_cob_debug.lua index a3ed2f20c18..526d35d7274 100644 --- a/luarules/gadgets/dbg_cob_debug.lua +++ b/luarules/gadgets/dbg_cob_debug.lua @@ -134,10 +134,10 @@ if gadgetHandler:IsSyncedCode() then local function CobDebug(unitID, unitDefID, team, cmdid, line, p1, p2, p3, p4, p5, p6, p7, p8) ResolveLine(unitDefID, line) - if lastgf == Spring.GetGameFrame() then + if lastgf == SpringShared.GetGameFrame() then count = count + 1 else - lastgf = Spring.GetGameFrame() + lastgf = SpringShared.GetGameFrame() count = 0 end -- f:<01368.000> u:27656 armstump.FireWeapon1:97 @@ -174,7 +174,7 @@ if gadgetHandler:IsSyncedCode() then msg = msg .. " p8=" .. tostring(p8) end - Spring.Echo(msg) + SpringShared.Echo(msg) end function gadget:Initialize() diff --git a/luarules/gadgets/dbg_gadget_profiler.lua b/luarules/gadgets/dbg_gadget_profiler.lua index 6e2f138aab2..6b8a1eb8175 100644 --- a/luarules/gadgets/dbg_gadget_profiler.lua +++ b/luarules/gadgets/dbg_gadget_profiler.lua @@ -104,10 +104,10 @@ local highres = false local tick = 0.2 local retainSortTime = 10 -local spGetTimer = Spring.GetTimer +local spGetTimer = SpringUnsynced.GetTimer -local spDiffTimers = Spring.DiffTimers -local spGetLuaMemUsage = Spring.GetLuaMemUsage or function() +local spDiffTimers = SpringUnsynced.DiffTimers +local spGetLuaMemUsage = SpringUnsynced.GetLuaMemUsage or function() return 0, 0, 0, 0, 0, 0, 0, 0 end @@ -178,12 +178,12 @@ if gadgetHandler:IsSyncedCode() then else local t, s - if Spring.GetTimerMicros and Spring.GetConfigInt("UseHighResTimer", 0) == 1 then - spGetTimer = Spring.GetTimerMicros + if SpringUnsynced.GetTimerMicros and SpringUnsynced.GetConfigInt("UseHighResTimer", 0) == 1 then + spGetTimer = SpringUnsynced.GetTimerMicros highres = true end if not highres then - Spring.Echo("Profiler not using highres timers", highres, Spring.GetConfigInt("UseHighResTimer", 0)) + SpringShared.Echo("Profiler not using highres timers", highres, SpringUnsynced.GetConfigInt("UseHighResTimer", 0)) end hookPreRealFunction = function(gadgetName, callinName) @@ -293,12 +293,12 @@ local function StartHook(optName, line, words, playerID) -- this one is synced? end hookset = true - Spring.Echo("start profiling (" .. (SendToUnsynced ~= nil and "synced" or "unsynced") .. ")") + SpringShared.Echo("start profiling (" .. (SendToUnsynced ~= nil and "synced" or "unsynced") .. ")") --// hook all existing callins ForAllGadgetCallins(AddHook) - Spring.Echo("hooked all callins") + SpringShared.Echo("hooked all callins") --// hook the UpdateCallin function oldUpdateGadgetCallIn = gadgetHandler.UpdateGadgetCallIn @@ -321,7 +321,7 @@ local function StartHook(optName, line, words, playerID) -- this one is synced? end end - Spring.Echo("hooked UpdateCallin") + SpringShared.Echo("hooked UpdateCallin") return false -- allow the unsynced chataction to execute too end @@ -338,16 +338,16 @@ function KillHook() return true end - Spring.Echo("stop profiling (" .. (SendToUnsynced ~= nil and "synced" or "unsynced") .. ")") + SpringShared.Echo("stop profiling (" .. (SendToUnsynced ~= nil and "synced" or "unsynced") .. ")") ForAllGadgetCallins(RemoveHook) - Spring.Echo("unhooked all callins") + SpringShared.Echo("unhooked all callins") --// unhook the UpdateCallin function gadgetHandler.UpdateGadgetCallIn = oldUpdateGadgetCallIn - Spring.Echo("unhooked UpdateCallin") + SpringShared.Echo("unhooked UpdateCallin") hookset = false return false -- allow the unsynced chataction to execute too @@ -404,20 +404,20 @@ else tick = (words and words[1] and tonumber(words[1])) or tick if highres and true then -- this tests the timers for correctness - local starttime = Spring.GetTimer() - local starttimeus = Spring.GetTimerMicros() + local starttime = SpringUnsynced.GetTimer() + local starttimeus = SpringUnsynced.GetTimerMicros() local j = 0 for i = 1, 1000000 do j = j + 1 end - local endtime = Spring.GetTimer() - local endtimeus = Spring.GetTimerMicros() + local endtime = SpringUnsynced.GetTimer() + local endtimeus = SpringUnsynced.GetTimerMicros() - Spring.Echo("GetTimer secs", Spring.DiffTimers(endtime, starttime, nil)) - Spring.Echo("GetTimer msecs", Spring.DiffTimers(endtime, starttime, true)) - Spring.Echo("GetTimerMicros secs", Spring.DiffTimers(endtimeus, starttimeus, nil, true)) - Spring.Echo("GetTimerMicros msecs", Spring.DiffTimers(endtimeus, starttimeus, true, true)) + SpringShared.Echo("GetTimer secs", SpringUnsynced.DiffTimers(endtime, starttime, nil)) + SpringShared.Echo("GetTimer msecs", SpringUnsynced.DiffTimers(endtime, starttime, true)) + SpringShared.Echo("GetTimerMicros secs", SpringUnsynced.DiffTimers(endtimeus, starttimeus, nil, true)) + SpringShared.Echo("GetTimerMicros msecs", SpringUnsynced.DiffTimers(endtimeus, starttimeus, true, true)) end StartHook() -- the unsynced one! @@ -425,7 +425,7 @@ else SetDrawCallin(gadget.DrawScreen_) - Spring.Echo("luarules profiler started (player " .. pID .. ")") + SpringShared.Echo("luarules profiler started (player " .. pID .. ")") end end @@ -433,7 +433,7 @@ else if running then running = false - Spring.Echo("Killing...") + SpringShared.Echo("Killing...") SetDrawCallin(nil) KillHook() @@ -441,7 +441,7 @@ else timersSynced = {} memUsageSynced = {} - Spring.Echo("luarules profiler killed (player " .. pID .. ")") + SpringShared.Echo("luarules profiler killed (player " .. pID .. ")") end end @@ -565,11 +565,11 @@ else local sorted = {} - local averageTime = Spring.GetConfigFloat("profiler_averagetime", 2) - local sortByLoad = Spring.GetConfigInt("profiler_sort_by_load", 1) == 1 + local averageTime = SpringUnsynced.GetConfigFloat("profiler_averagetime", 2) + local sortByLoad = SpringUnsynced.GetConfigInt("profiler_sort_by_load", 1) == 1 -- Cache FPS and frame calculation - local frames = mathMin(1 / tick, Spring.GetFPS()) * retainSortTime + local frames = mathMin(1 / tick, SpringUnsynced.GetFPS()) * retainSortTime local framesMinusOne = frames - 1 for gname, callins in pairs(stats) do @@ -873,7 +873,7 @@ else end if not next(callinStats) and not next(callinStatsSYNCED) then - Spring.Echo("no data in profiler!") + SpringShared.Echo("no data in profiler!") return end @@ -923,7 +923,7 @@ else Line(0, title_colour, "Callins in brackets are heaviest per gadget for (time,allocs)") Line(1, title_colour, "Tick time: " .. tick .. "s") - Line(0, title_colour, "Smoothing time: " .. Spring.GetConfigFloat("profiler_averagetime", 2) .. "s") + Line(0, title_colour, "Smoothing time: " .. SpringUnsynced.GetConfigFloat("profiler_averagetime", 2) .. "s") gl.EndText() end diff --git a/luarules/gadgets/dbg_synced_proxy.lua b/luarules/gadgets/dbg_synced_proxy.lua index b1e7a71cf27..7ce63fe3235 100644 --- a/luarules/gadgets/dbg_synced_proxy.lua +++ b/luarules/gadgets/dbg_synced_proxy.lua @@ -15,11 +15,11 @@ if not gadgetHandler:IsSyncedCode() then end if not Spring.Utilities.IsDevMode() or not Spring.Utilities.Gametype.IsSinglePlayer() then - Spring.SetGameRulesParam("isSyncedProxyEnabled", false) + SpringSynced.SetGameRulesParam("isSyncedProxyEnabled", false) return end -Spring.SetGameRulesParam("isSyncedProxyEnabled", true) +SpringSynced.SetGameRulesParam("isSyncedProxyEnabled", true) local LOG_LEVEL = LOG.INFO @@ -32,7 +32,7 @@ local function log(level, str, ...) return end - Spring.Log(gadget:GetInfo().name, LOG.NOTICE, str) + SpringShared.Log(gadget:GetInfo().name, LOG.NOTICE, str) end local function processFunctionCall(fn, returnID) @@ -46,7 +46,7 @@ local function processFunctionCall(fn, returnID) local serializedReturn = rpc:serializeFunctionReturn(pcallOk, pcallResult, returnID) log(LOG.DEBUG, "[processFunctionCall.SendLuaUIMsg] " .. Proxy.PREFIX.RETURN .. serializedReturn) - Spring.SendLuaUIMsg(Proxy.PREFIX.RETURN .. serializedReturn) + SpringUnsynced.SendLuaUIMsg(Proxy.PREFIX.RETURN .. serializedReturn) end local RECEIVE_MODES = { @@ -64,7 +64,7 @@ local RECEIVE_MODES = { function gadget:RecvLuaMsg(msg, playerID) -- check cheating here because cheats might not be enabled when the game starts - if not Spring.IsCheatingEnabled() then + if not SpringShared.IsCheatingEnabled() then return end for prefix, fn in pairs(RECEIVE_MODES) do @@ -76,5 +76,5 @@ function gadget:RecvLuaMsg(msg, playerID) end function gadget:Shutdown() - Spring.SetGameRulesParam("isSyncedProxyEnabled", false) + SpringSynced.SetGameRulesParam("isSyncedProxyEnabled", false) end diff --git a/luarules/gadgets/dbg_test_env_helper.lua b/luarules/gadgets/dbg_test_env_helper.lua index 3596c70a036..937d32ef08b 100644 --- a/luarules/gadgets/dbg_test_env_helper.lua +++ b/luarules/gadgets/dbg_test_env_helper.lua @@ -21,10 +21,10 @@ if gadgetHandler:IsSyncedCode() then local removeGadgets = { "Team Com Ends", "Game End" } - Spring.SetGameRulesParam(ENABLED_RULES_PARAM, true) + SpringSynced.SetGameRulesParam(ENABLED_RULES_PARAM, true) local function SetTestEndConditionsCmd(cmd, line, words, playerID) - if not Spring.IsCheatingEnabled() then + if not SpringShared.IsCheatingEnabled() then return end for _, gadgetName in pairs(removeGadgets) do @@ -32,23 +32,23 @@ if gadgetHandler:IsSyncedCode() then gadgetHandler:RemoveGadget(g) end - Spring.SetGameRulesParam("testEndConditionsOverride", true) + SpringSynced.SetGameRulesParam("testEndConditionsOverride", true) end local function SetTestReadyPlayersCmd(cmd, line, words, playerID) - if not Spring.IsCheatingEnabled() then + if not SpringShared.IsCheatingEnabled() then return end - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for _, playerID in pairs(playerList) do - Spring.SetGameRulesParam("player_" .. playerID .. "_readyState", 1) + SpringSynced.SetGameRulesParam("player_" .. playerID .. "_readyState", 1) end end function gadget:Initialize() gadgetHandler.actionHandler.AddChatAction(gadget, "setTestEndConditions", SetTestEndConditionsCmd) gadgetHandler.actionHandler.AddChatAction(gadget, "setTestReadyPlayers", SetTestReadyPlayersCmd) - if Spring.GetGameRulesParam("testEndConditionsOverride") then + if SpringShared.GetGameRulesParam("testEndConditionsOverride") then SetTestEndConditionsCmd() end end @@ -56,12 +56,12 @@ if gadgetHandler:IsSyncedCode() then function gadget:Shutdown() gadgetHandler.actionHandler.RemoveChatAction(gadget, "setTestEndConditions") gadgetHandler.actionHandler.RemoveChatAction(gadget, "setTestReadyPlayers") - Spring.SetGameRulesParam(ENABLED_RULES_PARAM, false) + SpringSynced.SetGameRulesParam(ENABLED_RULES_PARAM, false) end function gadget:RecvLuaMsg(msg, playerID) if msg == "testEnvironmentStarting" then - Spring.SetGameRulesParam("testEnvironmentStarting", true) + SpringSynced.SetGameRulesParam("testEnvironmentStarting", true) gadgetHandler:RemoveGadgetCallIn("RecvLuaMsg", self) end end @@ -71,8 +71,8 @@ else local SYSTEM_ID = -1 function gadget:Update(n) - if (Spring.GetPlayerTraffic(SYSTEM_ID, NETMSG_STARTPLAYING) or 0) > 0 then - Spring.SendLuaRulesMsg("testEnvironmentStarting") + if (SpringUnsynced.GetPlayerTraffic(SYSTEM_ID, NETMSG_STARTPLAYING) or 0) > 0 then + SpringUnsynced.SendLuaRulesMsg("testEnvironmentStarting") gadgetHandler:RemoveGadget(self) end end diff --git a/luarules/gadgets/dbg_unit_callins.lua b/luarules/gadgets/dbg_unit_callins.lua index 5786b575a17..4a692152ec0 100644 --- a/luarules/gadgets/dbg_unit_callins.lua +++ b/luarules/gadgets/dbg_unit_callins.lua @@ -39,8 +39,8 @@ local function addEvent(unitID, callin, param1, param2, param3, param4) px = unitID[1] py = unitID[2] pz = unitID[3] - elseif Spring.ValidUnitID(unitID) then - px, py, pz = Spring.GetUnitPosition(unitID) + elseif SpringShared.ValidUnitID(unitID) then + px, py, pz = SpringShared.GetUnitPosition(unitID) end if px == nil then return @@ -59,7 +59,7 @@ local function addEvent(unitID, callin, param1, param2, param3, param4) caption = caption .. " " .. tostring(param4) end local newevent = { - life = Spring.GetGameFrame() + taglife, + life = SpringShared.GetGameFrame() + taglife, caption = caption, x = px, y = py + startheight, @@ -71,7 +71,7 @@ end function gadget:GameFrame() if numevents > 0 then - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() local removelist = {} for k, v in pairs(eventlist) do if v.life < gf then @@ -92,7 +92,7 @@ function gadget:DrawWorld() if numevents > 0 then gl.Color(0.3, 1, 0.3, 1) for key, event in pairs(eventlist) do - if Spring.IsSphereInView(event.x, event.y, event.z, 128) then + if SpringUnsynced.IsSphereInView(event.x, event.y, event.z, 128) then gl.PushMatrix() local w = gl.GetTextWidth(event.caption) * 16.0 gl.Translate(event.x - w, event.y, event.z) @@ -109,7 +109,7 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) return end if printcallins then - Spring.Echo("g:UnitCreated", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, builderID) + SpringShared.Echo("g:UnitCreated", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, builderID) end if showcallins then addEvent(unitID, "UnitCreated") @@ -121,7 +121,7 @@ function gadget:UnitFinished(unitID, unitDefID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitFinished", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:UnitFinished", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "UnitFinished") @@ -133,7 +133,7 @@ function gadget:UnitFromFactory(unitID, unitDefID, unitTeam, factID, factDefID, return end if printcallins then - Spring.Echo("g:UnitFromFactory", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, factID, factDefID, userOrders) + SpringShared.Echo("g:UnitFromFactory", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, factID, factDefID, userOrders) end if showcallins then addEvent(unitID, "UnitFromFactory") @@ -146,7 +146,7 @@ function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerD return end if printcallins then - Spring.Echo("g:UnitDestroyed", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:UnitDestroyed", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "UnitDestroyed") @@ -158,7 +158,7 @@ function gadget:UnitReverseBuilt(unitID, unitDefID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitReverseBuilt", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:UnitReverseBuilt", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "UnitReverseBuilt") @@ -170,7 +170,7 @@ function gadget:UnitDestroyedByTeam(unitID, unitDefID, unitTeam, attackerTeamID) return end if printcallins then - Spring.Echo("g:UnitDestroyedByTeam", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, attackerTeamID) + SpringShared.Echo("g:UnitDestroyedByTeam", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, attackerTeamID) end if showcallins then addEvent(unitID, "UnitDestroyedByTeam") @@ -182,7 +182,7 @@ function gadget:UnitTaken(unitID, unitDefID, unitTeam, newTeam) return end if printcallins then - Spring.Echo("g:UnitTaken", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, newTeam) + SpringShared.Echo("g:UnitTaken", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, newTeam) end if showcallins then addEvent(unitID, "UnitTaken") @@ -193,7 +193,7 @@ function gadget:UnitExperience(unitID, unitDefID, unitTeam, experience, oldExper return end if printcallins then - Spring.Echo("g:UnitExperience", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, experience, oldExperience) + SpringShared.Echo("g:UnitExperience", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, experience, oldExperience) end if showcallins then addEvent(unitID, "UnitExperience") @@ -205,7 +205,7 @@ function gadget:UnitCommand(unitID, unitDefID, unitTeam, cmdId, cmdParams, cmdOp return end if printcallins then - Spring.Echo("g:UnitCommand", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, cmdId, cmdParams, cmdOpts, cmdTag, playerID, fromSynced, fromLua) + SpringShared.Echo("g:UnitCommand", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, cmdId, cmdParams, cmdOpts, cmdTag, playerID, fromSynced, fromLua) end if showcallins then addEvent(unitID, "UnitCommand") @@ -217,7 +217,7 @@ function gadget:UnitCmdDone(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOp return end if printcallins then - Spring.Echo("g:UnitCmdDone", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, cmdID, cmdParams, cmdOpts, cmdTag) + SpringShared.Echo("g:UnitCmdDone", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, cmdID, cmdParams, cmdOpts, cmdTag) end if showcallins then addEvent(unitID, "UnitCmdDone") @@ -229,7 +229,7 @@ function gadget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer) return end if printcallins then - Spring.Echo("g:UnitDamaged", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, damage, paralyzer) + SpringShared.Echo("g:UnitDamaged", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, damage, paralyzer) end if showcallins then addEvent(unitID, "UnitDamaged") @@ -241,7 +241,7 @@ function gadget:UnitGiven(unitID, unitDefID, unitTeam, oldTeam) return end if printcallins then - Spring.Echo("g:UnitGiven", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, oldTeam) + SpringShared.Echo("g:UnitGiven", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, oldTeam) end if showcallins then addEvent(unitID, "UnitGiven") @@ -253,7 +253,7 @@ function gadget:UnitIdle(unitID, unitDefID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitIdle", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:UnitIdle", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "UnitIdle") @@ -265,7 +265,7 @@ function gadget:UnitEnteredRadar(unitID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitEnteredRadar", unitID, unitTeam) + SpringShared.Echo("g:UnitEnteredRadar", unitID, unitTeam) end if showcallins then addEvent(unitID, "UnitEnteredRadar") @@ -277,7 +277,7 @@ function gadget:UnitEnteredLos(unitID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitEnteredLos", unitID, unitTeam) + SpringShared.Echo("g:UnitEnteredLos", unitID, unitTeam) end if showcallins then addEvent(unitID, "UnitEnteredLos") @@ -289,7 +289,7 @@ function gadget:UnitLeftRadar(unitID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitLeftRadar", unitID, unitTeam) + SpringShared.Echo("g:UnitLeftRadar", unitID, unitTeam) end if showcallins then addEvent(unitID, "UnitLeftRadar") @@ -301,7 +301,7 @@ function gadget:UnitLeftLos(unitID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitLeftLos", unitID, unitTeam) + SpringShared.Echo("g:UnitLeftLos", unitID, unitTeam) end if showcallins then addEvent(unitID, "UnitLeftLos") @@ -313,7 +313,7 @@ function gadget:UnitEnteredWater(unitID, unitDefID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitEnteredWater", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:UnitEnteredWater", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "UnitEnteredWater") @@ -325,7 +325,7 @@ function gadget:UnitEnteredAir(unitID, unitDefID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitEnteredAir", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:UnitEnteredAir", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "UnitEnteredAir") @@ -337,7 +337,7 @@ function gadget:UnitLeftWater(unitID, unitDefID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitLeftWater", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:UnitLeftWater", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "UnitLeftWater") @@ -349,7 +349,7 @@ function gadget:UnitLeftAir(unitID, unitDefID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitLeftAir", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:UnitLeftAir", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "UnitLeftAir") @@ -361,7 +361,7 @@ function gadget:UnitSeismicPing(x, y, z, strength) return end if printcallins then - Spring.Echo("g:UnitSeismicPing", x, y, z, strength) + SpringShared.Echo("g:UnitSeismicPing", x, y, z, strength) end --if showcallins then addEvent(unitID, "UnitGiven") end end @@ -371,7 +371,7 @@ function gadget:UnitLoaded(unitID, unitDefID, unitTeam, transportID, transportTe return end if printcallins then - Spring.Echo("g:UnitLoaded", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, transportID, transportTeam) + SpringShared.Echo("g:UnitLoaded", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, transportID, transportTeam) end if showcallins then addEvent(unitID, "UnitLoaded") @@ -383,7 +383,7 @@ function gadget:UnitUnloaded(unitID, unitDefID, unitTeam, transportID, transport return end if printcallins then - Spring.Echo("g:UnitUnloaded", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, transportID, transportTeam) + SpringShared.Echo("g:UnitUnloaded", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, transportID, transportTeam) end if showcallins then addEvent(unitID, "UnitUnloaded") @@ -395,7 +395,7 @@ function gadget:UnitCloaked(unitID, unitDefID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitCloaked", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:UnitCloaked", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "UnitCloaked") @@ -407,7 +407,7 @@ function gadget:UnitDecloaked(unitID, unitDefID, unitTeam) return end if printcallins then - Spring.Echo("g:UnitDecloaked", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:UnitDecloaked", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "UnitDecloaked") @@ -425,7 +425,7 @@ function gadget:StockpileChanged(unitID, unitDefID, unitTeam, weaponNum, oldCoun return end if printcallins then - Spring.Echo("g:StockpileChanged", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, weaponNum, oldCount, newCount) + SpringShared.Echo("g:StockpileChanged", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam, weaponNum, oldCount, newCount) end if showcallins then addEvent(unitID, "StockpileChanged") @@ -437,7 +437,7 @@ function gadget:RenderUnitDestroyed(unitID, unitDefID, unitTeam) return end if printcallins then - Spring.Echo("g:RenderUnitDestroyed", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) + SpringShared.Echo("g:RenderUnitDestroyed", unitID, unitDefID and UnitDefs[unitDefID].name, unitTeam) end if showcallins then addEvent(unitID, "RenderUnitDestroyed") @@ -449,7 +449,7 @@ function gadget:UnitUnitCollision(colliderID, collideeID) return end if printcallins then - Spring.Echo("g:UnitUnitCollision", colliderID, collideeID) + SpringShared.Echo("g:UnitUnitCollision", colliderID, collideeID) end if showcallins then addEvent(colliderID, "UnitUnitCollision") @@ -461,7 +461,7 @@ function gadget:UnitFeatureCollision(colliderID, collideeID) return end if printcallins then - Spring.Echo("g:UnitFeatureCollision", colliderID, collideeID) + SpringShared.Echo("g:UnitFeatureCollision", colliderID, collideeID) end if showcallins then addEvent(colliderID, "UnitFeatureCollision") @@ -473,7 +473,7 @@ function gadget:UnitFeatureCollision(colliderID, collideeID) return end if printcallins then - Spring.Echo("g:UnitFeatureCollision", colliderID, collideeID) + SpringShared.Echo("g:UnitFeatureCollision", colliderID, collideeID) end if showcallins then addEvent(colliderID, "UnitFeatureCollision") @@ -484,12 +484,12 @@ function gadget:FeatureCreated(featureID) if enabledcallins.FeatureCreated == nil then return end - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if printcallins then - Spring.Echo("g:FeatureCreated", featureID, FeatureDefs[featureDefID].name) + SpringShared.Echo("g:FeatureCreated", featureID, FeatureDefs[featureDefID].name) end if showcallins then - local fx, fy, fz = Spring.GetFeaturePosition(featureID) + local fx, fy, fz = SpringShared.GetFeaturePosition(featureID) local pos = { fx, fy, fz } addEvent(pos, "FeatureCreated") end @@ -499,12 +499,12 @@ function gadget:FeatureDestroyed(featureID) if enabledcallins.FeatureDestroyed == nil then return end - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if printcallins then - Spring.Echo("g:FeatureDestroyed", featureID, FeatureDefs[featureDefID].name) + SpringShared.Echo("g:FeatureDestroyed", featureID, FeatureDefs[featureDefID].name) end if showcallins then - local fx, fy, fz = Spring.GetFeaturePosition(featureID) + local fx, fy, fz = SpringShared.GetFeaturePosition(featureID) local pos = { fx, fy, fz } addEvent(pos, "FeatureDestroyed") end @@ -512,7 +512,7 @@ end local function togglegadget() enabled = not enabled - Spring.Echo("UnitCallinsGadget toggled to:", enabled) + SpringShared.Echo("UnitCallinsGadget toggled to:", enabled) if enabled == false then enabledcallins = {} else diff --git a/luarules/gadgets/dbg_unitposition_logger.lua b/luarules/gadgets/dbg_unitposition_logger.lua index afdcd8f16b5..a5981d4262b 100644 --- a/luarules/gadgets/dbg_unitposition_logger.lua +++ b/luarules/gadgets/dbg_unitposition_logger.lua @@ -24,11 +24,11 @@ end if not gadgetHandler:IsSyncedCode() then - if Spring.IsReplay() then + if SpringUnsynced.IsReplay() then return end - local DEBUG = select(1, Spring.GetPlayerInfo(Spring.GetMyPlayerID())) == "[teh]Flow" + local DEBUG = select(1, SpringShared.GetPlayerInfo(Spring.GetMyPlayerID())) == "[teh]Flow" local gameFramesPerSecond = 30 -- engine constant local pingCutoff = 1500 -- players with higher ping wont participate in sending unit positions log @@ -48,7 +48,7 @@ if not gadgetHandler:IsSyncedCode() then local validation = SYNCED.validationLogger - local spGetUnitPosition = Spring.GetUnitPosition + local spGetUnitPosition = SpringShared.GetUnitPosition local math_floor = math.floor local math_ceil = math.ceil @@ -126,7 +126,7 @@ if not gadgetHandler:IsSyncedCode() then if noParts then log[frame] = nil if DEBUG and (attempts ~= "1" or part > tonumber(numParts)) then - Spring.Echo('UNITLOG: "all received": frame:' .. frame .. " part:" .. part .. " parts:" .. numParts .. " attempts:" .. attempts) + SpringShared.Echo('UNITLOG: "all received": frame:' .. frame .. " part:" .. part .. " parts:" .. numParts .. " attempts:" .. attempts) end end end @@ -143,12 +143,12 @@ if not gadgetHandler:IsSyncedCode() then end local function sendLog(frame, part, attempts) - Spring.SendLuaRulesMsg("log" .. validation .. frame .. ";" .. part .. ";" .. #log[frame].participants .. ";" .. attempts .. ";" .. VFS.ZlibCompress(Json.encode(log[frame].parts[part]))) + SpringUnsynced.SendLuaRulesMsg("log" .. validation .. frame .. ";" .. part .. ";" .. #log[frame].participants .. ";" .. attempts .. ";" .. VFS.ZlibCompress(Json.encode(log[frame].parts[part]))) end function gadget:Initialize() - for ct, unitID in pairs(Spring.GetAllUnits()) do - gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID), Spring.GetUnitTeam(unitID)) + for ct, unitID in pairs(SpringShared.GetAllUnits()) do + gadget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID), SpringShared.GetUnitTeam(unitID)) end gadgetHandler:AddSyncAction("receivedPart", receivedPart) end @@ -178,7 +178,7 @@ if not gadgetHandler:IsSyncedCode() then missingUnits = missingUnits + #units end end - Spring.Echo('UNITLOG: "max attempts reached": frame:' .. frame .. " attempts:" .. log[frame].attempts .. "of " .. #log[frame].participants .. " missing parts:" .. missingParts .. " missing units:" .. missingUnits) + SpringShared.Echo('UNITLOG: "max attempts reached": frame:' .. frame .. " attempts:" .. log[frame].attempts .. "of " .. #log[frame].participants .. " missing parts:" .. missingParts .. " missing units:" .. missingUnits) end log[frame] = nil else @@ -219,7 +219,7 @@ if not gadgetHandler:IsSyncedCode() then missingUnits = missingUnits + #units end end - Spring.Echo('UNITLOG: "timeout": frame:' .. frame .. " attempts:" .. log[frame].attempts .. "of " .. #log[frame].participants .. " missing parts:" .. missingParts .. " missing units:" .. missingUnits) + SpringShared.Echo('UNITLOG: "timeout": frame:' .. frame .. " attempts:" .. log[frame].attempts .. "of " .. #log[frame].participants .. " missing parts:" .. missingParts .. " missing units:" .. missingUnits) end log[frame] = nil end @@ -231,12 +231,12 @@ if not gadgetHandler:IsSyncedCode() then -- find out which players/specs aren't lagged behind and available to send a part of all unit position data local participants = {} local myPart - for _, playerID in ipairs(Spring.GetPlayerList()) do - local name, _, _, teamID, _, ping = Spring.GetPlayerInfo(playerID, false) + for _, playerID in ipairs(SpringShared.GetPlayerList()) do + local name, _, _, teamID, _, ping = SpringShared.GetPlayerInfo(playerID, false) -- exclude lagged out players and AI -- NOTE: ping is 0 when player is catching up or playing local (local can be slightly above 0 when low fps 0.033) - local isDead = select(4, Spring.GetTeamInfo(teamID)) - if (ping > 0.01 or isSinglePlayer) and ping < pingCutoff / 1000 and not Spring.GetTeamLuaAI(teamID) and not isDead then + local isDead = select(4, SpringShared.GetTeamInfo(teamID)) + if (ping > 0.01 or isSinglePlayer) and ping < pingCutoff / 1000 and not SpringShared.GetTeamLuaAI(teamID) and not isDead then participants[#participants + 1] = playerID if playerID == myPlayerID then myPart = #participants diff --git a/luarules/gadgets/dev_replay_data.lua b/luarules/gadgets/dev_replay_data.lua index 135a9810e9b..ccd32d9a80a 100644 --- a/luarules/gadgets/dev_replay_data.lua +++ b/luarules/gadgets/dev_replay_data.lua @@ -19,7 +19,7 @@ if not gadgetHandler:IsSyncedCode() then local function hookCallIn() -- check if game is a replay or spectating - allowForwarding = Spring.IsReplay() or Spring.GetSpectatingState() + allowForwarding = SpringUnsynced.IsReplay() or SpringUnsynced.GetSpectatingState() if hooked and not allowForwarding then gadgetHandler:RemoveCallIn("UnitDamaged") hooked = false diff --git a/luarules/gadgets/feature_dead_explosion.lua b/luarules/gadgets/feature_dead_explosion.lua index 65fc768a71f..d054c4f8610 100644 --- a/luarules/gadgets/feature_dead_explosion.lua +++ b/luarules/gadgets/feature_dead_explosion.lua @@ -29,14 +29,14 @@ if gadgetHandler:IsSyncedCode() then end function gadget:FeatureDestroyed(featureID, allyTeamID) - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if isCorpse[featureDefID] then - local _, _, resurrectProgress = Spring.GetFeatureHealth(featureID) + local _, _, resurrectProgress = SpringShared.GetFeatureHealth(featureID) if resurrectProgress < 0.98 then - local x, y, z = Spring.GetFeaturePosition(featureID) + local x, y, z = SpringShared.GetFeaturePosition(featureID) local fsize = isCorpse[featureDefID] - Spring.SpawnCEG(effectsTable[fsize].ceg, x, y, z) - Spring.PlaySoundFile(effectsTable[fsize].sound, 1, x, y, z, "sfx") + SpringSynced.SpawnCEG(effectsTable[fsize].ceg, x, y, z) + SpringUnsynced.PlaySoundFile(effectsTable[fsize].sound, 1, x, y, z, "sfx") end end end diff --git a/luarules/gadgets/feature_debris_physics.lua b/luarules/gadgets/feature_debris_physics.lua index 8b02d1c7eaa..e509172aaad 100644 --- a/luarules/gadgets/feature_debris_physics.lua +++ b/luarules/gadgets/feature_debris_physics.lua @@ -21,7 +21,7 @@ for i = 1, #FeatureDefs do end function gadget:FeatureCreated(featureID) - if validFeatureDefID[Spring.GetFeatureDefID(featureID)] then - Spring.SetFeatureMoveCtrl(featureID, false, 1, 1, 1, 1, 1, 1, 1, 1, 1) + if validFeatureDefID[SpringShared.GetFeatureDefID(featureID)] then + SpringSynced.SetFeatureMoveCtrl(featureID, false, 1, 1, 1, 1, 1, 1, 1, 1, 1) end end diff --git a/luarules/gadgets/fx_atmosphere.lua b/luarules/gadgets/fx_atmosphere.lua index fd881e0de14..df6ea0a23ef 100644 --- a/luarules/gadgets/fx_atmosphere.lua +++ b/luarules/gadgets/fx_atmosphere.lua @@ -20,8 +20,8 @@ end local data = { map_sizeX = Game.mapSizeX, -- no touchies map_sizeZ = Game.mapSizeZ, -- no touchies - map_minHeight = Spring.GetGroundExtremes(), -- no touchies - map_maxHeight = select(2, Spring.GetGroundExtremes()), -- no touchies + map_minHeight = SpringShared.GetGroundExtremes(), -- no touchies + map_maxHeight = select(2, SpringShared.GetGroundExtremes()), -- no touchies map_voidWater = false, -- no touchies geo_ventPositions = {}, -- no touchies @@ -31,8 +31,8 @@ local data = { wind_lastSoundFrame = 0, -- no touchies wind_soundDelay = 60, - wind_minHeight = select(2, Spring.GetGroundExtremes()) * 0.6, - wind_maxHeight = select(2, Spring.GetGroundExtremes()), + wind_minHeight = select(2, SpringShared.GetGroundExtremes()) * 0.6, + wind_maxHeight = select(2, SpringShared.GetGroundExtremes()), wind_soundBank = { "windy1", "windy2", "windy3", "windy4", "windy5" }, wind_rareSoundBank = { "windy1", "windy2", "windy3", "windy4", "windy5" }, @@ -56,10 +56,10 @@ function UpdateAllData() end function CollectGeoVentPositions() - local allFeatures = Spring.GetAllFeatures() + local allFeatures = SpringShared.GetAllFeatures() for i = 1, #allFeatures do -- loop through all features on the map - if FeatureDefs[Spring.GetFeatureDefID(allFeatures[i])].geoThermal then -- isGeoSpot - local x, y, z = Spring.GetFeaturePosition(allFeatures[i]) + if FeatureDefs[SpringShared.GetFeatureDefID(allFeatures[i])].geoThermal then -- isGeoSpot + local x, y, z = SpringShared.GetFeaturePosition(allFeatures[i]) local allowGeo = true for i = 1, #data.geo_ventPositions do -- Check for duplicate geo vent spots, we don't want that. local posx = data.geo_ventPositions[i].x @@ -83,8 +83,8 @@ function PlayGeoVentSound() local randomposx = data.geo_ventPositions[data.geo_currentGeoVentID].x local randomposz = data.geo_ventPositions[data.geo_currentGeoVentID].z local randomposy = data.geo_ventPositions[data.geo_currentGeoVentID].y - if Spring.IsSphereInView(randomposx, randomposy, randomposz) then - Spring.PlaySoundFile("geoventshort", 0.25, randomposx, randomposy, randomposz, "sfx") + if SpringUnsynced.IsSphereInView(randomposx, randomposy, randomposz) then + SpringUnsynced.PlaySoundFile("geoventshort", 0.25, randomposx, randomposy, randomposz, "sfx") end data.geo_currentGeoVentID = data.geo_currentGeoVentID + 1 if data.geo_currentGeoVentID > data.geo_numberOfGeoVentPositions then -- we've played sound for all of them, repeat the loop. @@ -95,13 +95,13 @@ end function PlayWindSound(n) -- We want wind to play at volume depending on wind speed and height. local randomposx = math.random(0, data.map_sizeX) local randomposz = math.random(0, data.map_sizeZ) - local randomposy = Spring.GetGroundHeight(randomposx, randomposz) - if randomposy >= data.wind_minHeight and Spring.IsSphereInView(randomposx, randomposy + 400, randomposz) then - local windSpeed = select(4, Spring.GetWind()) / 25 + local randomposy = SpringShared.GetGroundHeight(randomposx, randomposz) + if randomposy >= data.wind_minHeight and SpringUnsynced.IsSphereInView(randomposx, randomposy + 400, randomposz) then + local windSpeed = select(4, SpringShared.GetWind()) / 25 if math.random() > 0.1 then - Spring.PlaySoundFile(data.wind_soundBank[math.random(1, #data.wind_soundBank)], windSpeed * 0.6, randomposx, (randomposy + 400), randomposz, "sfx") + SpringUnsynced.PlaySoundFile(data.wind_soundBank[math.random(1, #data.wind_soundBank)], windSpeed * 0.6, randomposx, (randomposy + 400), randomposz, "sfx") else - Spring.PlaySoundFile(data.wind_rareSoundBank[math.random(1, #data.wind_rareSoundBank)], windSpeed * 0.6, randomposx, (randomposy + 400), randomposz, "sfx") + SpringUnsynced.PlaySoundFile(data.wind_rareSoundBank[math.random(1, #data.wind_rareSoundBank)], windSpeed * 0.6, randomposx, (randomposy + 400), randomposz, "sfx") end data.wind_lastSoundFrame = n end @@ -110,13 +110,13 @@ end function PlaySeaSound(n) -- We want wind to play at volume depending on wind speed and height. local randomposx = math.random(0, data.map_sizeX) local randomposz = math.random(0, data.map_sizeZ) - local randomposy = Spring.GetGroundHeight(randomposx, randomposz) - if randomposy <= data.sea_minDepth and Spring.IsSphereInView(randomposx, randomposy + 400, randomposz) then - local windSpeed = select(4, Spring.GetWind()) / 25 + local randomposy = SpringShared.GetGroundHeight(randomposx, randomposz) + if randomposy <= data.sea_minDepth and SpringUnsynced.IsSphereInView(randomposx, randomposy + 400, randomposz) then + local windSpeed = select(4, SpringShared.GetWind()) / 25 if math.random() > 0.1 then - Spring.PlaySoundFile(data.sea_soundBank[math.random(1, #data.sea_soundBank)], (0.10 + (windSpeed * 0.75)), randomposx, (randomposy + 400), randomposz, "sfx") + SpringUnsynced.PlaySoundFile(data.sea_soundBank[math.random(1, #data.sea_soundBank)], (0.10 + (windSpeed * 0.75)), randomposx, (randomposy + 400), randomposz, "sfx") else - Spring.PlaySoundFile(data.sea_rareSoundBank[math.random(1, #data.sea_rareSoundBank)], (0.10 + (windSpeed * 0.75)), randomposx, (randomposy + 400), randomposz, "sfx") + SpringUnsynced.PlaySoundFile(data.sea_rareSoundBank[math.random(1, #data.sea_rareSoundBank)], (0.10 + (windSpeed * 0.75)), randomposx, (randomposy + 400), randomposz, "sfx") end data.sea_lastSoundFrame = n end @@ -125,13 +125,13 @@ end function PlayBeachSound(n) -- We want wind to play at volume depending on wind speed and height. local randomposx = math.random(0, data.map_sizeX) local randomposz = math.random(0, data.map_sizeZ) - local randomposy = Spring.GetGroundHeight(randomposx, randomposz) - if randomposy < 0 and randomposy >= data.beach_maxDepth and Spring.IsSphereInView(randomposx, randomposy, randomposz) then - local windSpeed = select(4, Spring.GetWind()) / 25 + local randomposy = SpringShared.GetGroundHeight(randomposx, randomposz) + if randomposy < 0 and randomposy >= data.beach_maxDepth and SpringUnsynced.IsSphereInView(randomposx, randomposy, randomposz) then + local windSpeed = select(4, SpringShared.GetWind()) / 25 if math.random() > 0.1 then - Spring.PlaySoundFile(data.beach_soundBank[math.random(1, #data.beach_soundBank)], (0.20 + (windSpeed * 0.6)), randomposx, (randomposy + 400), randomposz, "sfx") + SpringUnsynced.PlaySoundFile(data.beach_soundBank[math.random(1, #data.beach_soundBank)], (0.20 + (windSpeed * 0.6)), randomposx, (randomposy + 400), randomposz, "sfx") else - Spring.PlaySoundFile(data.beach_rareSoundBank[math.random(1, #data.beach_rareSoundBank)], (0.20 + (windSpeed * 0.6)), randomposx, (randomposy + 400), randomposz, "sfx") + SpringUnsynced.PlaySoundFile(data.beach_rareSoundBank[math.random(1, #data.beach_rareSoundBank)], (0.20 + (windSpeed * 0.6)), randomposx, (randomposy + 400), randomposz, "sfx") end data.beach_lastSoundFrame = n end diff --git a/luarules/gadgets/fx_depthcharge_splash.lua b/luarules/gadgets/fx_depthcharge_splash.lua index 49a8cd45741..0dbbac76ec3 100644 --- a/luarules/gadgets/fx_depthcharge_splash.lua +++ b/luarules/gadgets/fx_depthcharge_splash.lua @@ -17,7 +17,7 @@ if not gadgetHandler:IsSyncedCode() then return false end -local GetProjectilePosition = Spring.GetProjectilePosition +local GetProjectilePosition = SpringShared.GetProjectilePosition local depthChargeWeapons = {} for weaponID, weaponDef in pairs(WeaponDefs) do @@ -60,7 +60,7 @@ function gadget:GameFrame(n) local x, y, z = GetProjectilePosition(proID) if y then if y < 0 then - Spring.SpawnCEG(missiles[proID], x, 0, z) + SpringSynced.SpawnCEG(missiles[proID], x, 0, z) missiles[proID] = nil end else diff --git a/luarules/gadgets/fx_missile_smoke.lua b/luarules/gadgets/fx_missile_smoke.lua index 6efaeec0187..b0bd0e1c22d 100644 --- a/luarules/gadgets/fx_missile_smoke.lua +++ b/luarules/gadgets/fx_missile_smoke.lua @@ -20,8 +20,8 @@ if not gadgetHandler:IsSyncedCode() then return false end -local GetProjectilePosition = Spring.GetProjectilePosition -local GetProjectileDirection = Spring.GetProjectileDirection +local GetProjectilePosition = SpringShared.GetProjectilePosition +local GetProjectileDirection = SpringShared.GetProjectileDirection local missiles = {} --subMissiles that are below the surface still local missileWeapons = {} @@ -60,7 +60,7 @@ end function gadget:ProjectileCreated(proID, proOwnerID, weaponDefID) if missileWeapons[weaponDefID] then - missiles[proID] = { Spring.GetGameFrame() - 4 + Spring.GetProjectileTimeToLive(proID), missileWeapons[weaponDefID] } + missiles[proID] = { SpringShared.GetGameFrame() - 4 + SpringShared.GetProjectileTimeToLive(proID), missileWeapons[weaponDefID] } end end @@ -74,7 +74,7 @@ function gadget:GameFrame(gf) local x, y, z = GetProjectilePosition(proID) if y and y > 0 then local dirX, dirY, dirZ = GetProjectileDirection(proID) - Spring.SpawnCEG(missile[2], x, y, z, dirX, dirY, dirZ) + SpringSynced.SpawnCEG(missile[2], x, y, z, dirX, dirY, dirZ) else missiles[proID] = nil end diff --git a/luarules/gadgets/fx_missile_starburst_liftoff.lua b/luarules/gadgets/fx_missile_starburst_liftoff.lua index 7439f335ab0..21c3351783f 100644 --- a/luarules/gadgets/fx_missile_starburst_liftoff.lua +++ b/luarules/gadgets/fx_missile_starburst_liftoff.lua @@ -20,9 +20,9 @@ if not gadgetHandler:IsSyncedCode() then return false end -local GetProjectilePosition = Spring.GetProjectilePosition -local GetProjectileDirection = Spring.GetProjectileDirection -local GetGroundHeight = Spring.GetGroundHeight +local GetProjectilePosition = SpringShared.GetProjectilePosition +local GetProjectileDirection = SpringShared.GetProjectileDirection +local GetGroundHeight = SpringShared.GetGroundHeight local missiles = {} --subMissiles that are below the surface still local missileWeapons = {} @@ -137,7 +137,7 @@ function gadget:ProjectileCreated(proID, proOwnerID, weaponDefID) if groundHeight < 0 then groundHeight = 0 end - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() missiles[proID] = { weaponDefID, groundHeight + missileWeapons[weaponDefID][1], @@ -169,14 +169,14 @@ function gadget:GameFrame(gf) local dirX, dirY, dirZ = GetProjectileDirection(proID) if gf <= missile[5] or gf % 2 == 1 then -- add extra missiletrail - Spring.SpawnCEG(missile[4], x, y, z, dirX, dirY, dirZ) + SpringSynced.SpawnCEG(missile[4], x, y, z, dirX, dirY, dirZ) if y <= missile[8] or (y <= missile[9] and gf % 2 == 1) then -- add ground dust - Spring.SpawnCEG(missile[7], x, missile[2], z, dirX, dirY, dirZ) + SpringSynced.SpawnCEG(missile[7], x, missile[2], z, dirX, dirY, dirZ) end if y <= missile[11] or (y <= missile[12] and gf % 2 == 1) then --add ground fire - Spring.SpawnCEG(missile[10], x, missile[2], z, dirX, dirY, dirZ) + SpringSynced.SpawnCEG(missile[10], x, missile[2], z, dirX, dirY, dirZ) end end else diff --git a/luarules/gadgets/fx_projectile_effects.lua b/luarules/gadgets/fx_projectile_effects.lua index e63c6e2bc2d..6ed07ddfa7b 100644 --- a/luarules/gadgets/fx_projectile_effects.lua +++ b/luarules/gadgets/fx_projectile_effects.lua @@ -24,12 +24,12 @@ if not gadgetHandler:IsSyncedCode() then return false end -local GetProjectilePosition = Spring.GetProjectilePosition -local GetProjectileDirection = Spring.GetProjectileDirection -local GetProjectileTimeToLive = Spring.GetProjectileTimeToLive -local GetGroundHeight = Spring.GetGroundHeight -local GetGameFrame = Spring.GetGameFrame -local SpawnCEG = Spring.SpawnCEG +local GetProjectilePosition = SpringShared.GetProjectilePosition +local GetProjectileDirection = SpringShared.GetProjectileDirection +local GetProjectileTimeToLive = SpringShared.GetProjectileTimeToLive +local GetGroundHeight = SpringShared.GetGroundHeight +local GetGameFrame = SpringShared.GetGameFrame +local SpawnCEG = SpringSynced.SpawnCEG local mathMax = math.max -- Helpful debug wrapper: @@ -180,7 +180,7 @@ local allWatchedWeaponDefIDs = {} local allWatchedProjectileIDs = {} function gadget:Initialize() - local minheight, maxheight = Spring.GetGroundExtremes() + local minheight, maxheight = SpringShared.GetGroundExtremes() if minheight > 100 then mapHasWater = false end diff --git a/luarules/gadgets/fx_reclaim_shards.lua b/luarules/gadgets/fx_reclaim_shards.lua index c423bf6d28b..0531742fa93 100644 --- a/luarules/gadgets/fx_reclaim_shards.lua +++ b/luarules/gadgets/fx_reclaim_shards.lua @@ -16,8 +16,8 @@ if not gadgetHandler:IsSyncedCode() then return end -local GetFeaturePosition = Spring.GetFeaturePosition -local SpawnCEG = Spring.SpawnCEG +local GetFeaturePosition = SpringShared.GetFeaturePosition +local SpawnCEG = SpringSynced.SpawnCEG local random = math.random local cegs = { "reclaimshards1", "reclaimshards2", "reclaimshards3" } diff --git a/luarules/gadgets/fx_submissile_splash.lua b/luarules/gadgets/fx_submissile_splash.lua index cf3a04640df..b335341e311 100644 --- a/luarules/gadgets/fx_submissile_splash.lua +++ b/luarules/gadgets/fx_submissile_splash.lua @@ -17,8 +17,8 @@ if not gadgetHandler:IsSyncedCode() then return false end -local GetProjectilePosition = Spring.GetProjectilePosition -local GetProjectileDirection = Spring.GetProjectileDirection +local GetProjectilePosition = SpringShared.GetProjectilePosition +local GetProjectileDirection = SpringShared.GetProjectileDirection local random = math.random local splashCEG = "torpedo-launch" @@ -51,7 +51,7 @@ function gadget:ProjectileCreated(proID, proOwnerID, weaponDefID) if subMissileWeapons[weaponDefID] then missiles[proID] = subMissileWeapons[weaponDefID] local x, _, z = GetProjectilePosition(proID) - Spring.SpawnCEG(splashCEG, x, 0, z) + SpringSynced.SpawnCEG(splashCEG, x, 0, z) end end @@ -65,7 +65,7 @@ function gadget:GameFrame(n) if y then if y < 0 and random() < 0.95 then local dirX, dirY, dirZ = GetProjectileDirection(proID) - Spring.SpawnCEG(CEG, x, y, z, dirX, dirY, dirZ) + SpringSynced.SpawnCEG(CEG, x, y, z, dirX, dirY, dirZ) end else missiles[proID] = nil diff --git a/luarules/gadgets/fx_watersplash.lua b/luarules/gadgets/fx_watersplash.lua index e87cb3f7a27..70b5a489480 100644 --- a/luarules/gadgets/fx_watersplash.lua +++ b/luarules/gadgets/fx_watersplash.lua @@ -19,7 +19,7 @@ if not gadgetHandler:IsSyncedCode() then end local abs = math.abs -local GetGroundBlocked = Spring.GetGroundBlocked +local GetGroundBlocked = SpringShared.GetGroundBlocked local nonexplosiveWeapons = { LaserCannon = true, BeamLaser = true, @@ -111,12 +111,12 @@ for weaponDefID, def in pairs(WeaponDefs) do end function gadget:Explosion(weaponID, px, py, pz, ownerID) - if Spring.GetGroundHeight(px, pz) < 0 then + if SpringShared.GetGroundHeight(px, pz) < 0 then local aoe = weaponAoe[weaponID] if not weaponNoSplash[weaponID] and abs(py) <= aoe and (not GetGroundBlocked(px, pz)) then local splashCEG = weaponSplashCEG[weaponID] if splashCEG then - Spring.SpawnCEG(splashCEG, px, 0, pz) + SpringSynced.SpawnCEG(splashCEG, px, 0, pz) end return true else @@ -128,7 +128,7 @@ function gadget:Explosion(weaponID, px, py, pz, ownerID) end function gadget:Initialize() - local minHeight, maxHeight = Spring.GetGroundExtremes() + local minHeight, maxHeight = SpringShared.GetGroundExtremes() if minHeight < 100 then for wDefID, wDef in pairs(WeaponDefs) do if wDef.damageAreaOfEffect ~= nil and wDef.damageAreaOfEffect > 8 and not weaponNoSplash[wDefID] then diff --git a/luarules/gadgets/gaia_critters.lua b/luarules/gadgets/gaia_critters.lua index 86512901e0a..7ce777a652b 100644 --- a/luarules/gadgets/gaia_critters.lua +++ b/luarules/gadgets/gaia_critters.lua @@ -43,11 +43,11 @@ local companionRadiusStart = 140 -- if mapcritter is spawned this close it will local companionRadiusAfterStart = 13 local companionPatrolRadius = 200 -local amountMultiplier = Spring.GetModOptions().critters +local amountMultiplier = SpringShared.GetModOptions().critters local minMulti = 0.2 local maxMulti = 5 -local GaiaTeamID = Spring.GetGaiaTeamID() +local GaiaTeamID = SpringShared.GetGaiaTeamID() local critterConfig = include("LuaRules/configs/critters.lua") local critterUnits = {} --critter units that are currently alive @@ -56,13 +56,13 @@ local companionCritters = {} local sceduledOrders = {} local commanders = {} -local GetGroundHeight = Spring.GetGroundHeight -local GetUnitPosition = Spring.GetUnitPosition -local GetUnitDefID = Spring.GetUnitDefID -local GiveOrderToUnit = Spring.GiveOrderToUnit -local CreateUnit = Spring.CreateUnit -local GetUnitTeam = Spring.GetUnitTeam -local ValidUnitID = Spring.ValidUnitID +local GetGroundHeight = SpringShared.GetGroundHeight +local GetUnitPosition = SpringShared.GetUnitPosition +local GetUnitDefID = SpringShared.GetUnitDefID +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit +local CreateUnit = SpringSynced.CreateUnit +local GetUnitTeam = SpringShared.GetUnitTeam +local ValidUnitID = SpringShared.ValidUnitID local random = math.random local sin, cos, abs, rad = math.sin, math.cos, math.abs, math.rad @@ -212,18 +212,18 @@ local function randomPatrolInCircle(unitID, ux, uz, ur, minWaterDepth) -- only d end local function setGaiaUnitSpecifics(unitID) - Spring.SetUnitNeutral(unitID, true) - Spring.SetUnitNoSelect(unitID, true) - Spring.SetUnitStealth(unitID, true) - Spring.SetUnitNoMinimap(unitID, true) - Spring.SetUnitMaxHealth(unitID, 2) - Spring.SetUnitBlocking(unitID, false) - Spring.SetUnitSensorRadius(unitID, "los", 0) - Spring.SetUnitSensorRadius(unitID, "airLos", 0) - Spring.SetUnitSensorRadius(unitID, "radar", 0) - Spring.SetUnitSensorRadius(unitID, "sonar", 0) + SpringSynced.SetUnitNeutral(unitID, true) + SpringUnsynced.SetUnitNoSelect(unitID, true) + SpringSynced.SetUnitStealth(unitID, true) + SpringUnsynced.SetUnitNoMinimap(unitID, true) + SpringSynced.SetUnitMaxHealth(unitID, 2) + SpringSynced.SetUnitBlocking(unitID, false) + SpringSynced.SetUnitSensorRadius(unitID, "los", 0) + SpringSynced.SetUnitSensorRadius(unitID, "airLos", 0) + SpringSynced.SetUnitSensorRadius(unitID, "radar", 0) + SpringSynced.SetUnitSensorRadius(unitID, "sonar", 0) for weaponID, _ in pairs(UnitDefs[GetUnitDefID(unitID)].weapons) do - Spring.GiveOrderToUnit(unitID, CMD.FIRE_STATE, { 0 }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.FIRE_STATE, { 0 }, 0) --Spring.UnitWeaponHoldFire(unitID, weaponID) -- doesnt seem to work :S (maybe because they still patrol) end end @@ -239,7 +239,7 @@ local mapConfig function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD.ATTACK) - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for _, unitID in pairs(allUnits) do local unitDefID = GetUnitDefID(unitID) if unitDefID and isCommander[unitDefID] then @@ -257,13 +257,13 @@ function gadget:Initialize() end if amountMultiplier == 0 then - Spring.Echo("[Gaia Critters] Critters disabled via ModOption") + SpringShared.Echo("[Gaia Critters] Critters disabled via ModOption") gadgetHandler:RemoveGadget(self) end - Spring.Echo("[Gaia Critters] gadget:Initialize() Game.mapName=" .. Game.mapName) + SpringShared.Echo("[Gaia Critters] gadget:Initialize() Game.mapName=" .. Game.mapName) if mapConfig then - Spring.Echo("[Gaia Critters] No critter config for this map") + SpringShared.Echo("[Gaia Critters] No critter config for this map") --gadgetHandler:RemoveGadget(self) -- disabled so if you /give critters they still will be auto patrolled end @@ -286,13 +286,13 @@ end -- excluding gaia units local function getTotalUnits() local totalUnits = 0 - local allyTeamList = Spring.GetAllyTeamList() + local allyTeamList = SpringShared.GetAllyTeamList() for allyTeamListIndex = 1, #allyTeamList do local allyID = allyTeamList[allyTeamListIndex] - local teamList = Spring.GetTeamList(allyID) + local teamList = SpringShared.GetTeamList(allyID) for _, teamID in pairs(teamList) do if teamID ~= GaiaTeamID then - totalUnits = totalUnits + Spring.GetTeamUnitCount(teamID) + totalUnits = totalUnits + SpringShared.GetTeamUnitCount(teamID) end end end @@ -334,7 +334,7 @@ local function adjustCritters(newAliveCritters) critterBackup[unitID].y = y critterBackup[unitID].z = z - Spring.DestroyUnit(unitID, false, true) -- reclaimed + SpringSynced.DestroyUnit(unitID, false, true) -- reclaimed totalCritters = totalCritters + 1 -- DestroyUnit callin substracts 1 here but we want to keep it constant, so re-adding changed = true @@ -441,7 +441,7 @@ local function addMapCritters() --makeUnitCritter(unitID) critterUnits[unitID].unitName = unitName else - Spring.Echo("[Gaia Critters] Failed to create " .. unitName) + SpringShared.Echo("[Gaia Critters] Failed to create " .. unitName) end end end @@ -484,7 +484,7 @@ local function addMapCritters() --makeUnitCritter(unitID) critterUnits[unitID].unitName = unitName else - Spring.Echo("[Gaia Critters] Failed to create " .. unitName) + SpringShared.Echo("[Gaia Critters] Failed to create " .. unitName) end end end @@ -593,7 +593,7 @@ function gadget:UnitIdle(unitID, unitDefID, unitTeam) end local function getTeamCommanderUnitID(teamID) - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for i = 1, #allUnits do local unitID = allUnits[i] if GetUnitTeam(unitID) == teamID then diff --git a/luarules/gadgets/game_allyteam_ranking.lua b/luarules/gadgets/game_allyteam_ranking.lua index 51459d45e1e..4bb0540acca 100644 --- a/luarules/gadgets/game_allyteam_ranking.lua +++ b/luarules/gadgets/game_allyteam_ranking.lua @@ -24,21 +24,21 @@ local prevRanking = {} local allyteamCost = {} local unfinishedUnits = {} local teamAllyteam = {} -local teamList = Spring.GetTeamList() -local GaiaTeamID = Spring.GetGaiaTeamID() +local teamList = SpringShared.GetTeamList() +local GaiaTeamID = SpringShared.GetGaiaTeamID() for i = 1, #teamList do local teamID = teamList[i] if teamID ~= GaiaTeamID then - local allyTeamID = select(6, Spring.GetTeamInfo(teamID)) + local allyTeamID = select(6, SpringShared.GetTeamInfo(teamID)) teamAllyteam[teamID] = allyTeamID allyteamCost[allyTeamID] = 0 unfinishedUnits[allyTeamID] = {} end end -local spGetTeamResources = Spring.GetTeamResources -local spGetTeamList = Spring.GetTeamList -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt +local spGetTeamResources = SpringShared.GetTeamResources +local spGetTeamList = SpringShared.GetTeamList +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt local mathFloor = math.floor local tableSort = table.sort local rankSortFunc = function(m1, m2) @@ -118,8 +118,8 @@ function gadget:UnitTaken(unitID, unitDefID, unitTeam, oldTeam) end function gadget:Initialize() - for _, unitID in ipairs(Spring.GetAllUnits()) do - gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID), Spring.GetUnitTeam(unitID)) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + gadget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID), SpringShared.GetUnitTeam(unitID)) end end diff --git a/luarules/gadgets/game_apm_broadcast.lua b/luarules/gadgets/game_apm_broadcast.lua index 8184ce5da16..b8369d31de7 100644 --- a/luarules/gadgets/game_apm_broadcast.lua +++ b/luarules/gadgets/game_apm_broadcast.lua @@ -16,12 +16,12 @@ if gadgetHandler:IsSyncedCode() then local teamAddedActionFrame = {} local ignoreUnits = {} - local gameFrame = Spring.GetGameFrame() - local startFrame = Spring.GetGameFrame() -- used in case of luarules reload - local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt + local gameFrame = SpringShared.GetGameFrame() + local startFrame = SpringShared.GetGameFrame() -- used in case of luarules reload + local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt local totalTeamActions = {} - local teamList = Spring.GetTeamList() + local teamList = SpringShared.GetTeamList() for i = 1, #teamList do totalTeamActions[teamList[i]] = 0 end diff --git a/luarules/gadgets/game_assistdronespawn.lua b/luarules/gadgets/game_assistdronespawn.lua index 94cb1f076e6..19c02f30805 100644 --- a/luarules/gadgets/game_assistdronespawn.lua +++ b/luarules/gadgets/game_assistdronespawn.lua @@ -1,4 +1,4 @@ -if not (Spring.GetModOptions().assistdronesenabled == "enabled" or (Spring.GetModOptions().assistdronesenabled == "pve_only" and Spring.Utilities.Gametype.IsPvE())) then +if not (SpringShared.GetModOptions().assistdronesenabled == "enabled" or (SpringShared.GetModOptions().assistdronesenabled == "pve_only" and Spring.Utilities.Gametype.IsPvE())) then return end @@ -20,10 +20,10 @@ if not gadgetHandler:IsSyncedCode() then return false end -local droneCount = Spring.GetModOptions().assistdronescount +local droneCount = SpringShared.GetModOptions().assistdronescount local teamIDDroneList = {} -local teamsList = Spring.GetTeamList() +local teamsList = SpringShared.GetTeamList() function CountItemsInArray(array) local count = 0 @@ -35,7 +35,7 @@ end local drones = {} --local UDN = UnitDefNames -if Spring.GetModOptions().assistdronesair == true then +if SpringShared.GetModOptions().assistdronesair == true then --drones = { -- [UDN.armcom.id] = "armassistdrone", -- [UDN.corcom.id] = "corassistdrone", @@ -65,13 +65,13 @@ function SpawnAssistDrone(unitID, unitDefID, unitTeam) end local droneunit = drones[unitDefID] if CountItemsInArray(teamIDDroneList[unitTeam]) < droneCount then - local posx, posy, posz = Spring.GetUnitPosition(unitID) - local droneID = Spring.CreateUnit(droneunit, posx, posy + 100, posz, 0, unitTeam) + local posx, posy, posz = SpringShared.GetUnitPosition(unitID) + local droneID = SpringSynced.CreateUnit(droneunit, posx, posy + 100, posz, 0, unitTeam) if droneID then GG.ScavengersSpawnEffectUnitID(droneID) - Spring.GiveOrderToUnit(droneID, CMD.GUARD, unitID, {}) + SpringSynced.GiveOrderToUnit(droneID, CMD.GUARD, unitID, {}) teamIDDroneList[unitTeam][droneID] = true - Spring.SetUnitCosts(droneID, { buildTime = 500, metalCost = 1, energyCost = 1 }) + SpringSynced.SetUnitCosts(droneID, { buildTime = 500, metalCost = 1, energyCost = 1 }) end end end @@ -98,8 +98,8 @@ end function gadget:GameFrame(n) if n == 150 or n > 150 and n % 1800 == 0 then -- Drone respawn for comID, _ in pairs(commandersList) do - local comDefID = Spring.GetUnitDefID(comID) - local comTeam = Spring.GetUnitTeam(comID) + local comDefID = SpringShared.GetUnitDefID(comID) + local comTeam = SpringShared.GetUnitTeam(comID) SpawnAssistDrone(comID, comDefID, comTeam) end end diff --git a/luarules/gadgets/game_autocolors.lua b/luarules/gadgets/game_autocolors.lua index 42beaa16bc7..9ecfd043ca4 100644 --- a/luarules/gadgets/game_autocolors.lua +++ b/luarules/gadgets/game_autocolors.lua @@ -12,10 +12,10 @@ function gadget:GetInfo() } end -local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode -local gaiaTeamID = Spring.GetGaiaTeamID() -local teamList = Spring.GetTeamList() -local allyTeamList = Spring.GetAllyTeamList() +local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode +local gaiaTeamID = SpringShared.GetGaiaTeamID() +local teamList = SpringShared.GetTeamList() +local allyTeamList = SpringShared.GetAllyTeamList() local allyTeamCount = #allyTeamList - 1 local isSurvival = Spring.Utilities.Gametype.IsPvE() @@ -402,7 +402,7 @@ local iconDevModeColors = { gaiagray = gaiaGrayColor, leggren = legGreenColor, } -local iconDevMode = Spring.GetModOptions().teamcolors_icon_dev_mode +local iconDevMode = SpringShared.GetModOptions().teamcolors_icon_dev_mode local iconDevModeColor = iconDevModeColors[iconDevMode] local function shuffleTable(Table) @@ -456,30 +456,30 @@ local function setupTeamColor(teamID, allyTeamID, isAI, localRun) } -- Simple Team Colors - elseif localRun and (Spring.GetConfigInt("SimpleTeamColors", 0) == 1 or (anonymousMode == "allred" and not mySpecState)) then + elseif localRun and (SpringUnsynced.GetConfigInt("SimpleTeamColors", 0) == 1 or (anonymousMode == "allred" and not mySpecState)) then local brightnessVariation = 0 local maxColorVariation = 0 - if Spring.GetConfigInt("SimpleTeamColorsUseGradient", 0) == 1 then + if SpringUnsynced.GetConfigInt("SimpleTeamColorsUseGradient", 0) == 1 then local totalEnemyDimmingCount = 0 for allyTeamID, count in pairs(dimmingCount) do if allyTeamID ~= myAllyTeamID then totalEnemyDimmingCount = totalEnemyDimmingCount + count end end - brightnessVariation = (0.7 - ((1 / #Spring.GetTeamList(allyTeamID)) * dimmingCount[allyTeamID])) * 255 - brightnessVariation = brightnessVariation * math.min((#Spring.GetTeamList(allyTeamID) * 0.8) - 1, 1) -- dont change brightness too much in tiny teams + brightnessVariation = (0.7 - ((1 / #SpringShared.GetTeamList(allyTeamID)) * dimmingCount[allyTeamID])) * 255 + brightnessVariation = brightnessVariation * math.min((#SpringShared.GetTeamList(allyTeamID) * 0.8) - 1, 1) -- dont change brightness too much in tiny teams maxColorVariation = 60 end local color = hex2RGB(ffaColors[allyTeamID + 1] or "#333333") - if Spring.GetConfigInt("SimpleTeamColorsFactionSpecific", 0) == 1 then + if SpringUnsynced.GetConfigInt("SimpleTeamColorsFactionSpecific", 0) == 1 then if isAI and string.find(isAI, "Scavenger") then color = hex2RGB(scavPurpColor) elseif isAI and string.find(isAI, "Raptor") then color = hex2RGB(raptorOrangeColor) elseif teamID == gaiaTeamID then color = hex2RGB(gaiaGrayColor) - elseif Spring.GetTeamRulesParam(teamID, "startUnit") and anonymousMode ~= "allred" then - local side = string.sub(UnitDefs[Spring.GetTeamRulesParam(teamID, "startUnit")].name, 1, 3) + elseif SpringShared.GetTeamRulesParam(teamID, "startUnit") and anonymousMode ~= "allred" then + local side = string.sub(UnitDefs[SpringShared.GetTeamRulesParam(teamID, "startUnit")].name, 1, 3) if side == "arm" then color = hex2RGB(armBlueColor) elseif side == "cor" then @@ -495,11 +495,11 @@ local function setupTeamColor(teamID, allyTeamID, isAI, localRun) elseif teamID == myTeamID then brightnessVariation = 0 maxColorVariation = 0 - color = { Spring.GetConfigInt("SimpleTeamColorsPlayerR", 0), Spring.GetConfigInt("SimpleTeamColorsPlayerG", 77), Spring.GetConfigInt("SimpleTeamColorsPlayerB", 255) } + color = { SpringUnsynced.GetConfigInt("SimpleTeamColorsPlayerR", 0), SpringUnsynced.GetConfigInt("SimpleTeamColorsPlayerG", 77), SpringUnsynced.GetConfigInt("SimpleTeamColorsPlayerB", 255) } elseif allyTeamID == myAllyTeamID then - color = { Spring.GetConfigInt("SimpleTeamColorsAllyR", 0), Spring.GetConfigInt("SimpleTeamColorsAllyG", 255), Spring.GetConfigInt("SimpleTeamColorsAllyB", 0) } + color = { SpringUnsynced.GetConfigInt("SimpleTeamColorsAllyR", 0), SpringUnsynced.GetConfigInt("SimpleTeamColorsAllyG", 255), SpringUnsynced.GetConfigInt("SimpleTeamColorsAllyB", 0) } elseif allyTeamID ~= myAllyTeamID then - color = { Spring.GetConfigInt("SimpleTeamColorsEnemyR", 255), Spring.GetConfigInt("SimpleTeamColorsEnemyG", 16), Spring.GetConfigInt("SimpleTeamColorsEnemyB", 5) } + color = { SpringUnsynced.GetConfigInt("SimpleTeamColorsEnemyR", 255), SpringUnsynced.GetConfigInt("SimpleTeamColorsEnemyG", 16), SpringUnsynced.GetConfigInt("SimpleTeamColorsEnemyB", 5) } end color[1] = math.min(color[1] + brightnessVariation, 255) + ((teamRandoms[teamID][1] * (maxColorVariation * 2)) - maxColorVariation) color[2] = math.min(color[2] + brightnessVariation, 255) + ((teamRandoms[teamID][2] * (maxColorVariation * 2)) - maxColorVariation) @@ -529,7 +529,7 @@ local function setupTeamColor(teamID, allyTeamID, isAI, localRun) b = hex2RGB(gaiaGrayColor)[3], } - elseif isSurvival and survivalColors[(#Spring.GetTeamList()) - 2] then + elseif isSurvival and survivalColors[(#SpringShared.GetTeamList()) - 2] then teamColorsTable[teamID] = { r = hex2RGB(survivalColors[survivalColorNum])[1] + math.random(-survivalColorVariation, survivalColorVariation), g = hex2RGB(survivalColors[survivalColorNum])[2] + math.random(-survivalColorVariation, survivalColorVariation), @@ -538,13 +538,13 @@ local function setupTeamColor(teamID, allyTeamID, isAI, localRun) survivalColorNum = survivalColorNum + 1 -- Will start from the next color next time -- auto ffa gradient colored for huge player games - elseif useFFAColors or (#Spring.GetTeamList(allyTeamCount - 1) > 1 and (not teamColors[allyTeamCount] or not teamColors[allyTeamCount][1][#Spring.GetTeamList(allyTeamCount - 1)])) or #Spring.GetTeamList() > 30 or (#Spring.GetTeamList(allyTeamCount - 1) == 1 and not ffaColors[allyTeamCount]) then + elseif useFFAColors or (#SpringShared.GetTeamList(allyTeamCount - 1) > 1 and (not teamColors[allyTeamCount] or not teamColors[allyTeamCount][1][#SpringShared.GetTeamList(allyTeamCount - 1)])) or #SpringShared.GetTeamList() > 30 or (#SpringShared.GetTeamList(allyTeamCount - 1) == 1 and not ffaColors[allyTeamCount]) then local color = hex2RGB(ffaColors[allyTeamID + 1] or "#333333") local maxIterations = math.floor((#teamList - 1) / #ffaColors) - local brightnessVariation = (0.6 - ((1 / #Spring.GetTeamList(allyTeamID)) * dimmingCount[allyTeamID])) * 255 - brightnessVariation = brightnessVariation * math.min((#Spring.GetTeamList(allyTeamID) * 0.7) - 1, 1) -- dont change brightness too much in tiny teams + local brightnessVariation = (0.6 - ((1 / #SpringShared.GetTeamList(allyTeamID)) * dimmingCount[allyTeamID])) * 255 + brightnessVariation = brightnessVariation * math.min((#SpringShared.GetTeamList(allyTeamID) * 0.7) - 1, 1) -- dont change brightness too much in tiny teams local maxColorVariation = (120 / math.max(1, allyTeamCount - 1)) - if #Spring.GetTeamList(allyTeamID) == 1 then + if #SpringShared.GetTeamList(allyTeamID) == 1 then brightnessVariation = 0 maxColorVariation = 0 end @@ -605,7 +605,7 @@ local function setupTeamColor(teamID, allyTeamID, isAI, localRun) teamSizes[allyTeamID][2] = teamSizes[allyTeamID][2] + 1 -- Will start from the next color next time else - Spring.Echo("[AUTOCOLORS] Error: Team Colors Table is broken or missing for this allyteam set") + SpringShared.Echo("[AUTOCOLORS] Error: Team Colors Table is broken or missing for this allyteam set") teamColorsTable[teamID] = { r = 255, g = 255, @@ -622,14 +622,14 @@ local function setupAllTeamColors(localRun) teamSizes = {} dimmingCount = {} - for _, allyTeamID in ipairs(Spring.GetAllyTeamList()) do + for _, allyTeamID in ipairs(SpringShared.GetAllyTeamList()) do dimmingCount[allyTeamID] = 0 end for i = 1, #teamList do local teamID = teamList[i] - local allyTeamID = select(6, Spring.GetTeamInfo(teamID)) + local allyTeamID = select(6, SpringShared.GetTeamInfo(teamID)) dimmingCount[allyTeamID] = dimmingCount[allyTeamID] + 1 - local isAI = Spring.GetTeamLuaAI(teamID) + local isAI = SpringShared.GetTeamLuaAI(teamID) setupTeamColor(teamID, allyTeamID, isAI, localRun) end end @@ -648,17 +648,17 @@ if gadgetHandler:IsSyncedCode() then --- NOTE: STUFF DONE IN SYNCED IS FOR REPLA b = trueTeamColorsTable[teamID].b, } end - Spring.SendLuaRulesMsg("AutoColors" .. Json.encode(AutoColors)) + SpringUnsynced.SendLuaRulesMsg("AutoColors" .. Json.encode(AutoColors)) else -- UNSYNCED - local myPlayerID = Spring.GetLocalPlayerID() - local mySpecState = Spring.GetSpectatingState() + local myPlayerID = SpringUnsynced.GetLocalPlayerID() + local mySpecState = SpringUnsynced.GetSpectatingState() if anonymousMode == "local" then shuffleAllColors() end - if anonymousMode == "local" or Spring.GetConfigInt("SimpleTeamColors", 0) == 1 then + if anonymousMode == "local" or SpringUnsynced.GetConfigInt("SimpleTeamColors", 0) == 1 then setupAllTeamColors(true) end @@ -694,7 +694,7 @@ else -- UNSYNCED discoShuffle(Spring.GetMyTeamID()) end for teamID, color in pairs(teamColorsTable) do - Spring.SetTeamColor(teamID, color.r / 255, color.g / 255, color.b / 255) + SpringUnsynced.SetTeamColor(teamID, color.r / 255, color.g / 255, color.b / 255) end end updateTeamColors() @@ -703,18 +703,18 @@ else -- UNSYNCED local discoTimerThreshold = 2 * 60 -- shuffle every 2 minutes with disco mode enabled function gadget:Update() if isDiscoEnabled() then - discoTimer = discoTimer + Spring.GetLastUpdateSeconds() + discoTimer = discoTimer + SpringUnsynced.GetLastUpdateSeconds() if discoTimer > discoTimerThreshold then discoTimer = 0 updateTeamColors() end - elseif Spring.GetConfigInt("UpdateTeamColors", 0) == 1 then + elseif SpringUnsynced.GetConfigInt("UpdateTeamColors", 0) == 1 then setupAllTeamColors(true) updateTeamColors() - Spring.SetConfigInt("UpdateTeamColors", 0) - Spring.SetConfigInt("SimpleTeamColors_Reset", 0) - elseif Spring.GetConfigInt("SimpleTeamColors", 0) == 1 and Spring.GetConfigInt("SimpleTeamColorsFactionSpecific", 0) == 1 and Spring.GetGameFrame() < 300 then - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 0) + SpringUnsynced.SetConfigInt("SimpleTeamColors_Reset", 0) + elseif SpringUnsynced.GetConfigInt("SimpleTeamColors", 0) == 1 and SpringUnsynced.GetConfigInt("SimpleTeamColorsFactionSpecific", 0) == 1 and SpringShared.GetGameFrame() < 300 then + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end end @@ -725,15 +725,15 @@ else -- UNSYNCED myAllyTeamID = Spring.GetMyAllyTeamID() local prevMyTeamID = myTeamID myTeamID = Spring.GetMyTeamID() - if mySpecState and prevMyTeamID ~= myTeamID and Spring.GetConfigInt("SimpleTeamColors", 0) == 1 then - Spring.SetConfigInt("UpdateTeamColors", 1) + if mySpecState and prevMyTeamID ~= myTeamID and SpringUnsynced.GetConfigInt("SimpleTeamColors", 0) == 1 then + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end - if mySpecState ~= Spring.GetSpectatingState() then - mySpecState = Spring.GetSpectatingState() + if mySpecState ~= SpringUnsynced.GetSpectatingState() then + mySpecState = SpringUnsynced.GetSpectatingState() teamColorsTable = table.copy(trueTeamColorsTable) ffaColors = table.copy(trueFfaColors) survivalColors = table.copy(trueSurvivalColors) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end end end diff --git a/luarules/gadgets/game_commander_builder.lua b/luarules/gadgets/game_commander_builder.lua index cef40b34ed0..dc629c35e68 100644 --- a/luarules/gadgets/game_commander_builder.lua +++ b/luarules/gadgets/game_commander_builder.lua @@ -1,6 +1,6 @@ local spawnpadSpawnEnabled = false local PvEEnabled = Spring.Utilities.Gametype.IsPvE() -if Spring.GetModOptions().commanderbuildersenabled == "enabled" or (Spring.GetModOptions().commanderbuildersenabled == "pve_only" and PvEEnabled) then +if SpringShared.GetModOptions().commanderbuildersenabled == "enabled" or (SpringShared.GetModOptions().commanderbuildersenabled == "pve_only" and PvEEnabled) then spawnpadSpawnEnabled = true end @@ -38,20 +38,20 @@ local spawnpads = { [UDN.armcom.id] = "armrespawn", [UDN.corcom.id] = "correspawn", } -if Spring.GetModOptions().experimentallegionfaction then +if SpringShared.GetModOptions().experimentallegionfaction then spawnpads[UDN.legcom.id] = "legnanotcbase" end local spawnFrame = Game.spawnWarpInFrame + Game.gameSpeed * 2 -- add time to deconflict initial build orders function SpawnAssistTurret(unitID, unitDefID, unitTeam) - local posx, posy, posz = Spring.GetUnitPosition(unitID) + local posx, posy, posz = SpringShared.GetUnitPosition(unitID) local spawnpadunit = spawnpads[unitDefID] local spawnpadID for k = 1, 10000 do posx = math.ceil((posx + math.random(-k - 64, k + 64)) / 16) * 16 posz = math.ceil((posz + math.random(-k - 64, k + 64)) / 16) * 16 - posy = Spring.GetGroundHeight(posx, posz) + posy = SpringShared.GetGroundHeight(posx, posz) local canSpawnTurret = positionCheckLibrary.FlatAreaCheck(posx, posy, posz, 96) if canSpawnTurret then canSpawnTurret = positionCheckLibrary.OccupancyCheck(posx, posy, posz, 96) @@ -60,14 +60,14 @@ function SpawnAssistTurret(unitID, unitDefID, unitTeam) canSpawnTurret = positionCheckLibrary.ResourceCheck(posx, posz, 96) end if canSpawnTurret then - spawnpadID = Spring.CreateUnit(spawnpadunit, posx, posy, posz, 0, unitTeam) + spawnpadID = SpringSynced.CreateUnit(spawnpadunit, posx, posy, posz, 0, unitTeam) break end end if spawnpadID then GG.ScavengersSpawnEffectUnitID(spawnpadID) - Spring.GiveOrderToUnit(spawnpadID, CMD.GUARD, unitID, {}) - Spring.SetUnitCosts(spawnpadID, { buildTime = 20000, metalCost = 100, energyCost = 1000 }) + SpringSynced.GiveOrderToUnit(spawnpadID, CMD.GUARD, unitID, {}) + SpringSynced.SetUnitCosts(spawnpadID, { buildTime = 20000, metalCost = 100, energyCost = 1000 }) --Spring.SetUnitBlocking(spawnpadID, false) end end @@ -88,8 +88,8 @@ end function gadget:GameFrame(n) if n == spawnFrame then for comID, _ in pairs(commandersList) do - local comDefID = Spring.GetUnitDefID(comID) - local comTeam = Spring.GetUnitTeam(comID) + local comDefID = SpringShared.GetUnitDefID(comID) + local comTeam = SpringShared.GetUnitTeam(comID) SpawnAssistTurret(comID, comDefID, comTeam) end end diff --git a/luarules/gadgets/game_custom_map_tidal.lua b/luarules/gadgets/game_custom_map_tidal.lua index ccec5aa4a7c..154b9e7a689 100644 --- a/luarules/gadgets/game_custom_map_tidal.lua +++ b/luarules/gadgets/game_custom_map_tidal.lua @@ -17,7 +17,7 @@ function gadget:GetInfo() end function gadget:Initialize() - local newTidal = Spring.GetModOptions().map_tidal + local newTidal = SpringShared.GetModOptions().map_tidal local tidalSpeeds = { high = 23, medium = 18, @@ -26,6 +26,6 @@ function gadget:Initialize() } local newValue = tidalSpeeds[newTidal] if newValue then - Spring.SetTidal(newValue) + SpringSynced.SetTidal(newValue) end end diff --git a/luarules/gadgets/game_disable_assist_ally.lua b/luarules/gadgets/game_disable_assist_ally.lua index 96816413f63..422980cd8da 100644 --- a/luarules/gadgets/game_disable_assist_ally.lua +++ b/luarules/gadgets/game_disable_assist_ally.lua @@ -8,7 +8,7 @@ function gadget:GetInfo() date = "April 2024", license = "GNU GPL, v2 or later", layer = 1, -- after unit_mex_upgrade_reclaimer and unit_geo_upgrade_reclaimer - enabled = Spring.GetModOptions().disable_assist_ally_construction or Spring.GetModOptions().easytax, + enabled = SpringShared.GetModOptions().disable_assist_ally_construction or SpringShared.GetModOptions().easytax, } end @@ -16,12 +16,12 @@ if not gadgetHandler:IsSyncedCode() then return false end -local spAreTeamsAllied = Spring.AreTeamsAllied -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder local mathRandom = math.random local CMD_GUARD = CMD.GUARD @@ -41,7 +41,7 @@ local builderMoveStateCmdDesc = { }, } -local gaiaTeam = Spring.GetGaiaTeamID() +local gaiaTeam = SpringShared.GetGaiaTeamID() local isFactory = {} local canBuildStep = {} -- i.e. anything that spends resources when assisted @@ -55,12 +55,12 @@ local checkUnitCommandList = {} -- Delay validating given units so the order of -- Local functions local function removeRoamMoveState(unitID) - local index = Spring.FindUnitCmdDesc(unitID, CMD_MOVESTATE) + local index = SpringShared.FindUnitCmdDesc(unitID, CMD_MOVESTATE) if index then - local moveState = select(2, Spring.GetUnitStates(unitID, false)) + local moveState = select(2, SpringShared.GetUnitStates(unitID, false)) local params = builderMoveStateCmdDesc.params params[1] = math.min(moveState or 1, MOVESTATE_ROAM - 1) - Spring.EditUnitCmdDesc(unitID, index, builderMoveStateCmdDesc) + SpringSynced.EditUnitCmdDesc(unitID, index, builderMoveStateCmdDesc) end end @@ -94,7 +94,7 @@ local function validateCommands(unitID, unitTeam) local GetUnitCurrentCommand = spGetUnitCurrentCommand local tags, count = {}, 0 - for index = 1, Spring.GetUnitCommandCount(unitID) do + for index = 1, SpringShared.GetUnitCommandCount(unitID) do local command, _, tag, p1, p2, _, _, p5, p6 = GetUnitCurrentCommand(unitID, index) if not isBuilderAllowedCommand(command, p1, p2, p5, p6, unitTeam) then count = count + 1 @@ -103,7 +103,7 @@ local function validateCommands(unitID, unitTeam) end if count > 0 then - Spring.GiveOrderToUnit(unitID, CMD.REMOVE, tags) + SpringSynced.GiveOrderToUnit(unitID, CMD.REMOVE, tags) end end @@ -159,7 +159,7 @@ function gadget:UnitGiven(unitID, unitDefID, newTeam, oldTeam) end local function _GameFramePost(unitList) - local GetUnitIsDead = Spring.GetUnitIsDead + local GetUnitIsDead = SpringShared.GetUnitIsDead for unitID, newTeam in pairs(unitList) do unitList[unitID] = nil if GetUnitIsDead(unitID) == false then diff --git a/luarules/gadgets/game_disable_unit_sharing.lua b/luarules/gadgets/game_disable_unit_sharing.lua index d1691c7975e..b74adc8c948 100644 --- a/luarules/gadgets/game_disable_unit_sharing.lua +++ b/luarules/gadgets/game_disable_unit_sharing.lua @@ -19,7 +19,7 @@ if not gadgetHandler:IsSyncedCode() then return false end -if not Spring.GetModOptions().disable_unit_sharing then +if not SpringShared.GetModOptions().disable_unit_sharing then return false end diff --git a/luarules/gadgets/game_draft_spawn_order.lua b/luarules/gadgets/game_draft_spawn_order.lua index 7b7224a3ccb..2018912b449 100644 --- a/luarules/gadgets/game_draft_spawn_order.lua +++ b/luarules/gadgets/game_draft_spawn_order.lua @@ -5,10 +5,10 @@ -- The reason it's not its own gadget is that its just a mod for game_initail_spawn. -- And its only meant to work if Game.startPosType is 2. -local draftMode = Spring.GetModOptions().draft_mode +local draftMode = SpringShared.GetModOptions().draft_mode -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetTeamInfo = Spring.GetTeamInfo +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetTeamInfo = SpringShared.GetTeamInfo local allyTeamSpawnOrder = {} -- [allyTeam] = [teamID,teamID,...] - used for random/skill draft - placement order local allyTeamSpawnOrderPlaced = {} -- [allyTeam] = 1,..,#TeamsinAllyTeam - whose order to place right now @@ -19,7 +19,7 @@ local votedToForceStartDraft = {} -- [allyTeam][teamID] - if more than 50% vote local VOTE_QUORUM = 2 -- if there is less than 2 players in the game - the votes don't count -- TODO consider making it 3, can't have proper quorum with just two nodes, but it might be ok for now. local VOTE_YES_PRCTN_REQ = 51 -- default: 51 local announceVoteResults = false -- "secret" voting -local gaiaAllyTeamID = select(6, spGetTeamInfo(Spring.GetGaiaTeamID(), false)) +local gaiaAllyTeamID = select(6, spGetTeamInfo(SpringShared.GetGaiaTeamID(), false)) local waitIsMandatory = false -- if true - you will wait for late-joiners, and conneectionTimeOut timer won't be shown local canVoteSkipTurn = false local canVoteForceStartDraft = false @@ -29,7 +29,7 @@ local function FindPlayerID(teamID) return teamPlayerData[teamID].id else -- Fallback: Search for player ID using Spring functions (no skill data available) - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() for _, playerID in ipairs(players) do local playerTeamID = select(4, spGetPlayerInfo(playerID, false)) if playerTeamID == teamID then @@ -44,7 +44,7 @@ local function FindPlayerName(teamID) if teamPlayerData and teamPlayerData[teamID] and teamPlayerData[teamID].name then return teamPlayerData[teamID].name else - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() for _, playerID in ipairs(players) do local name, _, _, playerTeamID = spGetPlayerInfo(playerID, false) if playerTeamID == teamID and name then @@ -99,7 +99,7 @@ local function compareSkills(teamA, teamB) end local function isAllyTeamSkillZero(allyTeamID) - local tteams = Spring.GetTeamList(allyTeamID) + local tteams = SpringShared.GetTeamList(allyTeamID) for _, teamID in ipairs(tteams) do local _, _, _, isAiTeam = spGetTeamInfo(teamID, false) if not isAiTeam and gaiaAllyTeamID ~= allyTeamID then @@ -137,9 +137,9 @@ local function sendTeamOrder(teamOrder, allyTeamID_ready, log) end end if log and not alone then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Order [id:" .. allyTeamID_ready .. "]: " .. orderMsg) + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Order [id:" .. allyTeamID_ready .. "]: " .. orderMsg) end - Spring.SendLuaUIMsg("DraftOrderPlayersOrder " .. allyTeamID_ready .. " " .. orderIds) + SpringUnsynced.SendLuaUIMsg("DraftOrderPlayersOrder " .. allyTeamID_ready .. " " .. orderIds) end local function calculateVotedPercentage(allyTeamID, votesArray) @@ -161,7 +161,7 @@ end local function SendDraftMessageToPlayer(allyTeamID, target_num) -- technically do not care if it overflows here, on the clientside there just won't be anyone in the queue left - Spring.SendLuaUIMsg("DraftOrderPlayerTurn " .. allyTeamID .. " " .. target_num) -- we send allyTeamID orderIndex + SpringUnsynced.SendLuaUIMsg("DraftOrderPlayerTurn " .. allyTeamID .. " " .. target_num) -- we send allyTeamID orderIndex end local function checkVotesAndAdvanceTurn(allyTeamID) @@ -171,7 +171,7 @@ local function checkVotesAndAdvanceTurn(allyTeamID) local votedPercentage = calculateVotedPercentage(allyTeamID, votedToForceSkipTurn) if votedPercentage >= VOTE_YES_PRCTN_REQ then if announceVoteResults then - Spring.Echo("" .. votedPercentage .. "% (req: " .. VOTE_YES_PRCTN_REQ .. "%) of players on ally team " .. allyTeamID .. " have voted to skip current player turn.") + SpringShared.Echo("" .. votedPercentage .. "% (req: " .. VOTE_YES_PRCTN_REQ .. "%) of players on ally team " .. allyTeamID .. " have voted to skip current player turn.") end for teamID, _ in pairs(votedToForceSkipTurn[allyTeamID]) do votedToForceSkipTurn[allyTeamID][teamID] = false -- reset vote @@ -217,7 +217,7 @@ end -- Tom: order is generated after the entire ally team is in game, -- now we can force it to generate before everyone connects too! (late-joiners get last spots) local function PreInitDraftOrderData() - local tteams = Spring.GetTeamList() + local tteams = SpringShared.GetTeamList() for _, teamID in ipairs(tteams) do local _, _, _, isAiTeam, _, allyTeamID = spGetTeamInfo(teamID, false) if not isAiTeam and gaiaAllyTeamID ~= allyTeamID then @@ -287,7 +287,7 @@ local function InitDraftOrderData(allyTeamID_ready) end -- already started allyTeamIsInGame[allyTeamID_ready] = true if draftMode == "random" or draftMode == "captain" then - local tteams = Spring.GetTeamList() + local tteams = SpringShared.GetTeamList() for _, teamID in ipairs(tteams) do local _, _, _, isAiTeam, _, allyTeamID = spGetTeamInfo(teamID, false) if not isAiTeam and allyTeamID_ready == allyTeamID and gaiaAllyTeamID ~= allyTeamID then @@ -311,7 +311,7 @@ local function InitDraftOrderData(allyTeamID_ready) end putLateJoinersLast(allyTeamSpawnOrder[allyTeamID_ready]) elseif draftMode == "skill" then - local tteams = Spring.GetTeamList() + local tteams = SpringShared.GetTeamList() table.sort(tteams, compareSkills) -- Sort teams based on skill -- Assign sorted teams to allyTeamSpawnOrder for _, teamID in ipairs(tteams) do @@ -340,7 +340,7 @@ local function InitDraftOrderData(allyTeamID_ready) end putLateJoinersLast(allyTeamSpawnOrder[allyTeamID_ready]) end - Spring.SendLuaUIMsg("DraftOrderAllyTeamJoined " .. allyTeamID_ready) + SpringUnsynced.SendLuaUIMsg("DraftOrderAllyTeamJoined " .. allyTeamID_ready) if draftMode == "skill" or draftMode == "random" or draftMode == "captain" then canVoteSkipTurn = true allyTeamSpawnOrderPlaced[allyTeamID_ready] = 1 -- First team in the order queue must place now @@ -353,7 +353,7 @@ local function checkVotesAndStartDraft(allyTeamID) local votedPercentage = calculateVotedPercentage(allyTeamID, votedToForceStartDraft) if votedPercentage >= VOTE_YES_PRCTN_REQ then if announceVoteResults then - Spring.Echo("" .. votedPercentage .. "% (req: " .. VOTE_YES_PRCTN_REQ .. "%) of players on ally team " .. allyTeamID .. " have voted to skip wait for late-joiners.") + SpringShared.Echo("" .. votedPercentage .. "% (req: " .. VOTE_YES_PRCTN_REQ .. "%) of players on ally team " .. allyTeamID .. " have voted to skip wait for late-joiners.") end for teamID, _ in pairs(votedToForceStartDraft[allyTeamID]) do votedToForceStartDraft[allyTeamID][teamID] = false -- reset vote @@ -367,13 +367,13 @@ end function draftModeInitialize() PreInitDraftOrderData() if draftMode == "random" then -- Random draft - Spring.SendLuaUIMsg("DraftOrder_Random") -- Discord: https://discord.com/channels/549281623154229250/1163844303735500860 + SpringUnsynced.SendLuaUIMsg("DraftOrder_Random") -- Discord: https://discord.com/channels/549281623154229250/1163844303735500860 elseif draftMode == "captain" then -- Fair mod - Spring.SendLuaUIMsg("DraftOrder_Captain") -- Discord: https://discord.com/channels/549281623154229250/1163844303735500860 + SpringUnsynced.SendLuaUIMsg("DraftOrder_Captain") -- Discord: https://discord.com/channels/549281623154229250/1163844303735500860 elseif draftMode == "skill" then -- Skill-based placement order - Spring.SendLuaUIMsg("DraftOrder_Skill") -- Discord: https://discord.com/channels/549281623154229250/1134886429361713252 + SpringUnsynced.SendLuaUIMsg("DraftOrder_Skill") -- Discord: https://discord.com/channels/549281623154229250/1134886429361713252 elseif draftMode == "fair" then -- Fair mod - Spring.SendLuaUIMsg("DraftOrder_Fair") -- Discord: https://discord.com/channels/549281623154229250/1123310748236529715 + SpringUnsynced.SendLuaUIMsg("DraftOrder_Fair") -- Discord: https://discord.com/channels/549281623154229250/1123310748236529715 end end @@ -432,7 +432,7 @@ function DraftRecvLuaMsg(msg, playerID, playerIsSpec, playerTeam, allyTeamID) -- Check if all allies have joined and start the draft automatically if allyTeamIsInGame[allyTeamID] ~= true then local allAlliesJoined = true - local teamList = Spring.GetTeamList(allyTeamID) + local teamList = SpringShared.GetTeamList(allyTeamID) local count = 0 local tcount = 0 for _, team in ipairs(teamList) do @@ -450,12 +450,12 @@ function DraftRecvLuaMsg(msg, playerID, playerIsSpec, playerTeam, allyTeamID) InitDraftOrderData(allyTeamID) end if not waitIsMandatory and tcount >= VOTE_QUORUM and count > 0 and tcount > 0 and (((count / tcount) * 100) >= VOTE_YES_PRCTN_REQ) then - Spring.SendLuaUIMsg("DraftOrderShowCountdown " .. allyTeamID) + SpringUnsynced.SendLuaUIMsg("DraftOrderShowCountdown " .. allyTeamID) end end elseif msg == "send_me_the_info_again" then -- someone luaui /reload'ed, send them the queue and index again if allyTeamIsInGame[allyTeamID] then - Spring.SendLuaUIMsg("DraftOrderAllyTeamJoined " .. allyTeamID) + SpringUnsynced.SendLuaUIMsg("DraftOrderAllyTeamJoined " .. allyTeamID) if draftMode ~= "fair" and allyTeamSpawnOrderPlaced[allyTeamID] then sendTeamOrder(allyTeamSpawnOrder[allyTeamID], allyTeamID, false) -- Send order FIRST SendDraftMessageToPlayer(allyTeamID, allyTeamSpawnOrderPlaced[allyTeamID]) diff --git a/luarules/gadgets/game_dynamic_maxunits.lua b/luarules/gadgets/game_dynamic_maxunits.lua index 06145bfda2f..0e8cc41c4de 100644 --- a/luarules/gadgets/game_dynamic_maxunits.lua +++ b/luarules/gadgets/game_dynamic_maxunits.lua @@ -1,5 +1,5 @@ -if not Spring.TransferTeamMaxUnits then +if not SpringSynced.TransferTeamMaxUnits then return end @@ -59,7 +59,7 @@ end ]] -- -local maxunits = tonumber(Spring.GetModOptions().maxunits) or 2000 +local maxunits = tonumber(SpringShared.GetModOptions().maxunits) or 2000 local engineLimit = 32000 local gaiaLimit = 500 local scavengerRaptorLimit = 3500 -- Minimum maxunits for Scavenger/Raptor teams @@ -73,7 +73,7 @@ local allyTeamTargetMaxUnits = {} -- Check if a team is a Scavenger or Raptor AI team local function isScavengerOrRaptor(teamID) - local luaAI = Spring.GetTeamLuaAI(teamID) + local luaAI = SpringShared.GetTeamLuaAI(teamID) if luaAI then return string.find(luaAI, "Scavenger") or string.find(luaAI, "Raptor") end @@ -81,18 +81,18 @@ local function isScavengerOrRaptor(teamID) end function gadget:Initialize() - if Spring.GetGameFrame() > 0 then + if SpringShared.GetGameFrame() > 0 then return end -- Ensure Gaia team always get their maxunits - local gaiaTeamID = Spring.GetGaiaTeamID() - local gaiaAllyTeamID = select(6, Spring.GetTeamInfo(gaiaTeamID, false)) + local gaiaTeamID = SpringShared.GetGaiaTeamID() + local gaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(gaiaTeamID, false)) local totalMaxUnits = engineLimit - gaiaLimit -- Get all allyteams and their teams (excluding Gaia, including Scavenger/Raptor) - local allyTeamList = Spring.GetAllyTeamList() + local allyTeamList = SpringShared.GetAllyTeamList() local allyTeamSizes = {} local allyTeamTeams = {} local scavengerRaptorTeams = {} @@ -101,12 +101,12 @@ function gadget:Initialize() for _, allyID in ipairs(allyTeamList) do if allyID ~= gaiaAllyTeamID then - local teams = Spring.GetTeamList(allyID) + local teams = SpringShared.GetTeamList(allyID) local aliveTeams = {} local hasScavRaptor = false for _, teamID in ipairs(teams) do if teamID ~= gaiaTeamID then - local _, _, isDead = Spring.GetTeamInfo(teamID, false) + local _, _, isDead = SpringShared.GetTeamInfo(teamID, false) if not isDead then aliveTeams[#aliveTeams + 1] = teamID if isScavengerOrRaptor(teamID) then @@ -166,7 +166,7 @@ function gadget:Initialize() -- Set targets for Scav/Raptor teams (fixed allocation) for _, teamID in ipairs(scavengerRaptorTeams) do - local currentMaxUnits = Spring.GetTeamMaxUnits(teamID) + local currentMaxUnits = SpringShared.GetTeamMaxUnits(teamID) adjustments[teamID] = { current = currentMaxUnits, target = scavengerRaptorLimit, @@ -191,7 +191,7 @@ function gadget:Initialize() allyTeamTargetMaxUnits[allyID] = adjustedShare for _, teamID in ipairs(teams) do - local currentMaxUnits = Spring.GetTeamMaxUnits(teamID) + local currentMaxUnits = SpringShared.GetTeamMaxUnits(teamID) adjustments[teamID] = { current = currentMaxUnits, target = adjustedShare, @@ -214,15 +214,15 @@ function gadget:Initialize() table.sort(sortedTeamIDs) -- First collect from Gaia to get the full pool - local gaiaInitial = Spring.GetTeamMaxUnits(gaiaTeamID) + local gaiaInitial = SpringShared.GetTeamMaxUnits(gaiaTeamID) local totalAvailable = gaiaInitial -- Then collect from all player teams local totalCollected = 0 for _, teamID in ipairs(sortedTeamIDs) do - local currentMaxUnits = Spring.GetTeamMaxUnits(teamID) + local currentMaxUnits = SpringShared.GetTeamMaxUnits(teamID) if currentMaxUnits > 0 then - Spring.TransferTeamMaxUnits(teamID, gaiaTeamID, currentMaxUnits) + SpringSynced.TransferTeamMaxUnits(teamID, gaiaTeamID, currentMaxUnits) totalCollected = totalCollected + currentMaxUnits end end @@ -232,12 +232,12 @@ function gadget:Initialize() for _, teamID in ipairs(sortedTeamIDs) do local adj = adjustments[teamID] if adj.target > 0 then - Spring.TransferTeamMaxUnits(gaiaTeamID, teamID, adj.target) + SpringSynced.TransferTeamMaxUnits(gaiaTeamID, teamID, adj.target) end end -- Set Gaia to exactly their defined limit from the total pool - local gaiaCurrentMax = Spring.GetTeamMaxUnits(gaiaTeamID) + local gaiaCurrentMax = SpringShared.GetTeamMaxUnits(gaiaTeamID) local gaiaExpected = gaiaLimit if gaiaCurrentMax < gaiaExpected then @@ -259,9 +259,9 @@ function gadget:Initialize() for _, teamID in ipairs(regularTeams) do if remaining > 0 then - local takeAmount = mathMin(perTeam, remaining, Spring.GetTeamMaxUnits(teamID)) + local takeAmount = mathMin(perTeam, remaining, SpringShared.GetTeamMaxUnits(teamID)) if takeAmount > 0 then - Spring.TransferTeamMaxUnits(teamID, gaiaTeamID, takeAmount) + SpringSynced.TransferTeamMaxUnits(teamID, gaiaTeamID, takeAmount) remaining = remaining - takeAmount end end @@ -273,9 +273,9 @@ function gadget:Initialize() if remaining <= 0 then break end - local currentMax = Spring.GetTeamMaxUnits(teamID) + local currentMax = SpringShared.GetTeamMaxUnits(teamID) if currentMax > 0 then - Spring.TransferTeamMaxUnits(teamID, gaiaTeamID, 1) + SpringSynced.TransferTeamMaxUnits(teamID, gaiaTeamID, 1) remaining = remaining - 1 end end @@ -302,10 +302,10 @@ function gadget:Initialize() -- Give each team their fair share (respecting maxunits cap) for _, teamID in ipairs(regularTeams) do if remaining > 0 then - local currentMaxUnits = Spring.GetTeamMaxUnits(teamID) + local currentMaxUnits = SpringShared.GetTeamMaxUnits(teamID) local transferAmount = mathMin(perTeam, remaining, maxunits - currentMaxUnits) if transferAmount > 0 then - Spring.TransferTeamMaxUnits(gaiaTeamID, teamID, transferAmount) + SpringSynced.TransferTeamMaxUnits(gaiaTeamID, teamID, transferAmount) remaining = remaining - transferAmount end end @@ -317,9 +317,9 @@ function gadget:Initialize() if remaining <= 0 then break end - local currentMaxUnits = Spring.GetTeamMaxUnits(teamID) + local currentMaxUnits = SpringShared.GetTeamMaxUnits(teamID) if currentMaxUnits < maxunits then - Spring.TransferTeamMaxUnits(gaiaTeamID, teamID, 1) + SpringSynced.TransferTeamMaxUnits(gaiaTeamID, teamID, 1) remaining = remaining - 1 end end @@ -329,36 +329,36 @@ function gadget:Initialize() end function gadget:TeamDied(teamID) - local gaiaTeamID = Spring.GetGaiaTeamID() + local gaiaTeamID = SpringShared.GetGaiaTeamID() -- Don't redistribute if Gaia dies if teamID == gaiaTeamID then return end - local redistributionAmount = Spring.GetTeamMaxUnits(teamID) + local redistributionAmount = SpringShared.GetTeamMaxUnits(teamID) -- redistribute to teammates (respecting per-team maxunits limit) - local allyID = select(6, Spring.GetTeamInfo(teamID, false)) - local teams = Spring.GetTeamList(allyID) + local allyID = select(6, SpringShared.GetTeamInfo(teamID, false)) + local teams = SpringShared.GetTeamList(allyID) local aliveTeams = 0 for i = 1, #teams do - if teams[i] ~= teamID and teams[i] ~= gaiaTeamID and not isScavengerOrRaptor(teams[i]) and not select(3, Spring.GetTeamInfo(teams[i], false)) then -- not dead, not gaia, not scav/raptor + if teams[i] ~= teamID and teams[i] ~= gaiaTeamID and not isScavengerOrRaptor(teams[i]) and not select(3, SpringShared.GetTeamInfo(teams[i], false)) then -- not dead, not gaia, not scav/raptor aliveTeams = aliveTeams + 1 end end if aliveTeams > 0 then for i = 1, #teams do - if teams[i] ~= teamID and teams[i] ~= gaiaTeamID and not isScavengerOrRaptor(teams[i]) and not select(3, Spring.GetTeamInfo(teams[i], false)) then -- not dead, not gaia, not scav/raptor + if teams[i] ~= teamID and teams[i] ~= gaiaTeamID and not isScavengerOrRaptor(teams[i]) and not select(3, SpringShared.GetTeamInfo(teams[i], false)) then -- not dead, not gaia, not scav/raptor local targetTeamID = teams[i] - local currentMaxUnits = Spring.GetTeamMaxUnits(targetTeamID) + local currentMaxUnits = SpringShared.GetTeamMaxUnits(targetTeamID) local portionSize = mathFloor(redistributionAmount / aliveTeams) -- Respect the per-team maxunits limit local transferAmount = mathMin(portionSize, maxunits - currentMaxUnits) if transferAmount > 0 then - Spring.TransferTeamMaxUnits(teamID, targetTeamID, transferAmount) + SpringSynced.TransferTeamMaxUnits(teamID, targetTeamID, transferAmount) end end end @@ -366,25 +366,25 @@ function gadget:TeamDied(teamID) -- redistribute to enemies if no teammates alive (respecting per-team maxunits limit) if aliveTeams == 0 then - teams = Spring.GetTeamList() + teams = SpringShared.GetTeamList() aliveTeams = 0 for i = 1, #teams do - if teams[i] ~= teamID and teams[i] ~= gaiaTeamID and not isScavengerOrRaptor(teams[i]) and not select(3, Spring.GetTeamInfo(teams[i], false)) then -- not dead, not gaia, not scav/raptor + if teams[i] ~= teamID and teams[i] ~= gaiaTeamID and not isScavengerOrRaptor(teams[i]) and not select(3, SpringShared.GetTeamInfo(teams[i], false)) then -- not dead, not gaia, not scav/raptor aliveTeams = aliveTeams + 1 end end if aliveTeams > 0 then for i = 1, #teams do - if teams[i] ~= teamID and teams[i] ~= gaiaTeamID and not isScavengerOrRaptor(teams[i]) and not select(3, Spring.GetTeamInfo(teams[i], false)) then -- not dead, not gaia, not scav/raptor + if teams[i] ~= teamID and teams[i] ~= gaiaTeamID and not isScavengerOrRaptor(teams[i]) and not select(3, SpringShared.GetTeamInfo(teams[i], false)) then -- not dead, not gaia, not scav/raptor local targetTeamID = teams[i] - local currentMaxUnits = Spring.GetTeamMaxUnits(targetTeamID) + local currentMaxUnits = SpringShared.GetTeamMaxUnits(targetTeamID) local portionSize = mathFloor(redistributionAmount / aliveTeams) -- Respect the per-team maxunits limit local transferAmount = mathMin(portionSize, maxunits - currentMaxUnits) if transferAmount > 0 then - Spring.TransferTeamMaxUnits(teamID, targetTeamID, transferAmount) + SpringSynced.TransferTeamMaxUnits(teamID, targetTeamID, transferAmount) end end end @@ -393,19 +393,19 @@ function gadget:TeamDied(teamID) end function gadget:TeamChanged(teamID) - local gaiaTeamID = Spring.GetGaiaTeamID() + local gaiaTeamID = SpringShared.GetGaiaTeamID() -- Don't handle Gaia or Scavenger/Raptor teams if teamID == gaiaTeamID or isScavengerOrRaptor(teamID) then return end - local _, _, isDead = Spring.GetTeamInfo(teamID, false) + local _, _, isDead = SpringShared.GetTeamInfo(teamID, false) -- If team is now alive (player rejoined), redistribute unit limits within allyteam if not isDead then - local allyID = select(6, Spring.GetTeamInfo(teamID, false)) - local currentMaxUnits = Spring.GetTeamMaxUnits(teamID) + local allyID = select(6, SpringShared.GetTeamInfo(teamID, false)) + local currentMaxUnits = SpringShared.GetTeamMaxUnits(teamID) -- Get the target maxunits for this allyteam (calculated during initialization) local targetMaxUnits = allyTeamTargetMaxUnits[allyID] @@ -415,10 +415,10 @@ function gadget:TeamChanged(teamID) end -- Get all alive teams in the allyteam (including the one that just rejoined) - local teams = Spring.GetTeamList(allyID) + local teams = SpringShared.GetTeamList(allyID) local aliveTeams = {} for i = 1, #teams do - if teams[i] ~= gaiaTeamID and not isScavengerOrRaptor(teams[i]) and not select(3, Spring.GetTeamInfo(teams[i], false)) then + if teams[i] ~= gaiaTeamID and not isScavengerOrRaptor(teams[i]) and not select(3, SpringShared.GetTeamInfo(teams[i], false)) then aliveTeams[#aliveTeams + 1] = teams[i] end end @@ -430,7 +430,7 @@ function gadget:TeamChanged(teamID) -- Collect all maxunits from the allyteam into a pool local totalPool = 0 for i = 1, #aliveTeams do - local teamMaxUnits = Spring.GetTeamMaxUnits(aliveTeams[i]) + local teamMaxUnits = SpringShared.GetTeamMaxUnits(aliveTeams[i]) totalPool = totalPool + teamMaxUnits end @@ -447,9 +447,9 @@ function gadget:TeamChanged(teamID) local poolTeamID = aliveTeams[1] for i = 2, #aliveTeams do local donorID = aliveTeams[i] - local donorAmount = Spring.GetTeamMaxUnits(donorID) + local donorAmount = SpringShared.GetTeamMaxUnits(donorID) if donorAmount > 0 then - Spring.TransferTeamMaxUnits(donorID, poolTeamID, donorAmount) + SpringSynced.TransferTeamMaxUnits(donorID, poolTeamID, donorAmount) end end @@ -457,7 +457,7 @@ function gadget:TeamChanged(teamID) for i = 1, #aliveTeams do local targetID = aliveTeams[i] if targetID ~= poolTeamID then - Spring.TransferTeamMaxUnits(poolTeamID, targetID, perTeamTarget) + SpringSynced.TransferTeamMaxUnits(poolTeamID, targetID, perTeamTarget) end end diff --git a/luarules/gadgets/game_easter_eggs.lua b/luarules/gadgets/game_easter_eggs.lua index 62d77c63267..2744c65e396 100644 --- a/luarules/gadgets/game_easter_eggs.lua +++ b/luarules/gadgets/game_easter_eggs.lua @@ -44,10 +44,10 @@ function spawnRandomEggField(x, y, z, spread) y = y + 20 z = z + math.random(-spread, spread) if x > 0 and x < Game.mapSizeX and z > 0 and z < Game.mapSizeZ then - local egg = Spring.CreateFeature("raptor_egg_" .. size .. "_" .. color, x, y, z, math.random(-999999, 999999), Spring.GetGaiaTeamID()) + local egg = SpringSynced.CreateFeature("raptor_egg_" .. size .. "_" .. color, x, y, z, math.random(-999999, 999999), SpringShared.GetGaiaTeamID()) if egg then - Spring.SetFeatureMoveCtrl(egg, false, 1, 1, 1, 1, 1, 1, 1, 1, 1) - Spring.SetFeatureResources(egg, featureValueMetal, featureValueEnergy, featureValueMetal * 10, 1.0, featureValueMetal, featureValueEnergy) + SpringSynced.SetFeatureMoveCtrl(egg, false, 1, 1, 1, 1, 1, 1, 1, 1, 1) + SpringSynced.SetFeatureResources(egg, featureValueMetal, featureValueEnergy, featureValueMetal * 10, 1.0, featureValueMetal, featureValueEnergy) end end @@ -62,14 +62,14 @@ function gadget:GameFrame(frame) for i = 1, #metalSpots do local spot = metalSpots[i] if spot then - spawnRandomEggField(spot.x, Spring.GetGroundHeight(spot.x, spot.z), spot.z, 600) + spawnRandomEggField(spot.x, SpringShared.GetGroundHeight(spot.x, spot.z), spot.z, 600) end end else for i = 1, 100 do local x = math.random(0, Game.mapSizeX) local z = math.random(0, Game.mapSizeZ) - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) spawnRandomEggField(x, y, z, 1000) end end diff --git a/luarules/gadgets/game_end.lua b/luarules/gadgets/game_end.lua index a53ecc35869..ddcbed478bb 100644 --- a/luarules/gadgets/game_end.lua +++ b/luarules/gadgets/game_end.lua @@ -21,11 +21,11 @@ end ]] if gadgetHandler:IsSyncedCode() then - local sharedDynamicAllianceVictory = Spring.GetModOptions().shareddynamicalliancevictory - local fixedallies = Spring.GetModOptions().fixedallies + local sharedDynamicAllianceVictory = SpringShared.GetModOptions().shareddynamicalliancevictory + local fixedallies = SpringShared.GetModOptions().fixedallies - local gaiaTeamID = Spring.GetGaiaTeamID() - local gaiaAllyTeamID = select(6, Spring.GetTeamInfo(gaiaTeamID, false)) + local gaiaTeamID = SpringShared.GetGaiaTeamID() + local gaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(gaiaTeamID, false)) local earlyDropGrace = Game.gameSpeed * 60 * 1 -- in frames @@ -33,16 +33,16 @@ if gadgetHandler:IsSyncedCode() then local ignoredTeams = { [gaiaTeamID] = true, } - local allyteamList = Spring.GetAllyTeamList() - local teamList = Spring.GetTeamList() + local allyteamList = SpringShared.GetAllyTeamList() + local teamList = SpringShared.GetTeamList() for i = 1, #teamList do - local luaAI = Spring.GetTeamLuaAI(teamList[i]) + local luaAI = SpringShared.GetTeamLuaAI(teamList[i]) if luaAI and (luaAI:find("Raptors") or luaAI:find("Scavengers")) then ignoredTeams[teamList[i]] = true -- ignore all other teams in this allyteam as well - local allyTeamID = select(6, Spring.GetTeamInfo(teamList[i], false)) - local teammates = Spring.GetTeamList(allyTeamID) + local allyTeamID = select(6, SpringShared.GetTeamInfo(teamList[i], false)) + local teammates = SpringShared.GetTeamList(allyTeamID) for j = 1, #teammates do ignoredTeams[teammates[j]] = true end @@ -60,16 +60,16 @@ if gadgetHandler:IsSyncedCode() then end end - local KillTeam = Spring.KillTeam - local GetPlayerInfo = Spring.GetPlayerInfo - local GetPlayerList = Spring.GetPlayerList - local GetTeamInfo = Spring.GetTeamInfo - local GetTeamUnitCount = Spring.GetTeamUnitCount - local GetAIInfo = Spring.GetAIInfo - local GetTeamLuaAI = Spring.GetTeamLuaAI - local GameOver = Spring.GameOver - local AreTeamsAllied = Spring.AreTeamsAllied - local GetGameFrame = Spring.GetGameFrame + local KillTeam = SpringSynced.KillTeam + local GetPlayerInfo = SpringShared.GetPlayerInfo + local GetPlayerList = SpringShared.GetPlayerList + local GetTeamInfo = SpringShared.GetTeamInfo + local GetTeamUnitCount = SpringShared.GetTeamUnitCount + local GetAIInfo = SpringShared.GetAIInfo + local GetTeamLuaAI = SpringShared.GetTeamLuaAI + local GameOver = SpringSynced.GameOver + local AreTeamsAllied = SpringShared.AreTeamsAllied + local GetGameFrame = SpringShared.GetGameFrame local playerQuitIsDead = true -- gets turned off for 1v1's local oneTeamWasActive = false @@ -123,9 +123,9 @@ if gadgetHandler:IsSyncedCode() then if wipeout and not allyTeamInfos[allyTeamID].dead then if isFFA and gf < earlyDropGrace then for teamID, team in pairs(allyTeamInfos[allyTeamID].teams) do - local teamUnits = Spring.GetTeamUnits(teamID) + local teamUnits = SpringShared.GetTeamUnits(teamID) for i = 1, #teamUnits do - Spring.DestroyUnit(teamUnits[i], false, true) -- reclaim, dont want to leave FFA comwreck for idling starts + SpringSynced.DestroyUnit(teamUnits[i], false, true) -- reclaim, dont want to leave FFA comwreck for idling starts end end else @@ -204,7 +204,7 @@ if gadgetHandler:IsSyncedCode() then end function gadget:Initialize() - if Spring.GetModOptions().deathmode == "neverend" then + if SpringShared.GetModOptions().deathmode == "neverend" then gadgetHandler:RemoveGadget(self) return end @@ -225,7 +225,7 @@ if gadgetHandler:IsSyncedCode() then -- at start, fill in the table of all alive allyteams for _, allyTeamID in ipairs(allyteamList) do if allyTeamID ~= gaiaAllyTeamID then - local allyteamTeams = Spring.GetTeamList(allyTeamID) + local allyteamTeams = SpringShared.GetTeamList(allyTeamID) local allyTeamInfo = { unitCount = 0, unitDecorationCount = 0, @@ -255,9 +255,9 @@ if gadgetHandler:IsSyncedCode() then teamInfo.unitCount = GetTeamUnitCount(teamID) allyTeamInfo.unitCount = allyTeamInfo.unitCount + teamInfo.unitCount - local units = Spring.GetTeamUnits(teamID) + local units = SpringShared.GetTeamUnits(teamID) for u = 1, #units do - if unitDecoration[Spring.GetUnitDefID(units[u])] then + if unitDecoration[SpringShared.GetUnitDefID(units[u])] then allyTeamInfo.unitDecorationCount = allyTeamInfo.unitDecorationCount + 1 end end @@ -335,7 +335,7 @@ if gadgetHandler:IsSyncedCode() then if gameoverFrame then if not globalLosGranted then for _, allyTeamId in ipairs(gameoverWinners) do - Spring.SetGlobalLos(allyTeamId, true) + SpringSynced.SetGlobalLos(allyTeamId, true) end globalLosGranted = true @@ -347,13 +347,13 @@ if gadgetHandler:IsSyncedCode() then if gf == gameoverAnimFrame then for unitID, _ in pairs(gameoverAnimUnits) do - if Spring.ValidUnitID(unitID) then - if Spring.GetCOBScriptID(unitID, "GameOverAnim") then - Spring.CallCOBScript(unitID, "GameOverAnim", 0, true) + if SpringShared.ValidUnitID(unitID) then + if SpringSynced.GetCOBScriptID(unitID, "GameOverAnim") then + SpringSynced.CallCOBScript(unitID, "GameOverAnim", 0, true) else - local scriptEnv = Spring.UnitScript.GetScriptEnv(unitID) + local scriptEnv = SpringSynced.UnitScript.GetScriptEnv(unitID) if scriptEnv and scriptEnv["GameOverAnim"] then - Spring.UnitScript.CallAsUnit(unitID, scriptEnv["GameOverAnim"], true) + SpringSynced.UnitScript.CallAsUnit(unitID, scriptEnv["GameOverAnim"], true) end end end @@ -374,8 +374,8 @@ if gadgetHandler:IsSyncedCode() then end if winners then - if Spring.GetModOptions().scenariooptions then - Spring.Echo("winners", winners[1]) + if SpringShared.GetModOptions().scenariooptions then + SpringShared.Echo("winners", winners[1]) SendToUnsynced("scenariogameend", winners[1]) end @@ -392,11 +392,11 @@ if gadgetHandler:IsSyncedCode() then for u = 1, #winners do winnerSet[winners[u]] = true end - local units = Spring.GetAllUnits() + local units = SpringShared.GetAllUnits() for i = 1, #units do local unitID = units[i] - if isCommander[Spring.GetUnitDefID(unitID)] and winnerSet[Spring.GetUnitAllyTeam(unitID)] then - Spring.GiveOrderToUnit(unitID, CMD.STOP, 0, 0) -- give stop cmd so commanders can animate in place + if isCommander[SpringShared.GetUnitDefID(unitID)] and winnerSet[SpringShared.GetUnitAllyTeam(unitID)] then + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, 0, 0) -- give stop cmd so commanders can animate in place gameoverAnimUnits[unitID] = true end end @@ -481,14 +481,14 @@ else -- Unsynced local sec = 0 local cheated = false - local IsCheatingEnabled = Spring.IsCheatingEnabled + local IsCheatingEnabled = SpringShared.IsCheatingEnabled function gadget:Update(dt) - if Spring.GetGameFrame() == 0 then - sec = sec + Spring.GetLastUpdateSeconds() + if SpringShared.GetGameFrame() == 0 then + sec = sec + SpringUnsynced.GetLastUpdateSeconds() if sec > 3 then sec = 0 - Spring.SendLuaRulesMsg("pc") + SpringUnsynced.SendLuaRulesMsg("pc") end end end @@ -500,33 +500,33 @@ else -- Unsynced end local function ScenarioGameEnd(_, winners) - if Spring.IsReplay() then + if SpringUnsynced.IsReplay() then return end local myTeamID = Spring.GetMyAllyTeamID() - local cur_max = Spring.GetTeamStatsHistory(myTeamID) - local stats = Spring.GetTeamStatsHistory(myTeamID, cur_max, cur_max) + local cur_max = SpringShared.GetTeamStatsHistory(myTeamID) + local stats = SpringShared.GetTeamStatsHistory(myTeamID, cur_max, cur_max) stats = stats[1] stats.cheated = cheated stats.winners = winners stats.won = (myTeamID == winners) - stats.endtime = Spring.GetGameFrame() / 30 - stats.scenariooptions = Spring.GetModOptions().scenariooptions -- pass it back so we know difficulty + stats.endtime = SpringShared.GetGameFrame() / 30 + stats.scenariooptions = SpringShared.GetModOptions().scenariooptions -- pass it back so we know difficulty - if Spring.GetMenuName and string.find(string.lower(Spring.GetMenuName()), "chobby") ~= nil then + if SpringUnsynced.GetMenuName and string.find(string.lower(SpringUnsynced.GetMenuName()), "chobby") ~= nil then local message = Json.encode(stats) - Spring.SendLuaMenuMsg("ScenarioGameEnd " .. message) + SpringUnsynced.SendLuaMenuMsg("ScenarioGameEnd " .. message) end end function gadget:Initialize() - if Spring.GetModOptions().scenariooptions then + if SpringShared.GetModOptions().scenariooptions then gadgetHandler:AddSyncAction("scenariogameend", ScenarioGameEnd) end end function gadget:Shutdown() - if Spring.GetModOptions().scenariooptions then + if SpringShared.GetModOptions().scenariooptions then gadgetHandler:RemoveSyncAction("scenariogameend") end end diff --git a/luarules/gadgets/game_energy_conversion.lua b/luarules/gadgets/game_energy_conversion.lua index 98140896ada..e0602dca0f6 100644 --- a/luarules/gadgets/game_energy_conversion.lua +++ b/luarules/gadgets/game_energy_conversion.lua @@ -36,8 +36,8 @@ local function SetMMRulesParams() local unitName = UnitDefs[uDID].name or "" local capacity = conv.c local ratio = conv.e - Spring.SetGameRulesParam(unitName .. "_mm_capacity", capacity) - Spring.SetGameRulesParam(unitName .. "_mm_ratio", ratio) + SpringSynced.SetGameRulesParam(unitName .. "_mm_capacity", capacity) + SpringSynced.SetGameRulesParam(unitName .. "_mm_ratio", ratio) end end @@ -62,16 +62,16 @@ local paralysisRelRate = 75 -- unit HP / paralysisRelRate = paralysis dmg drop r -- Speedups ---------------------------------------------------------------- -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetTeamRulesParam = Spring.GetTeamRulesParam -local spSetTeamRulesParam = Spring.SetTeamRulesParam -local spGetTeamResources = Spring.GetTeamResources -local spGetUnitHealth = Spring.GetUnitHealth -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitDefID = Spring.GetUnitDefID -local spSetUnitResourcing = Spring.SetUnitResourcing -local spCallCOBScript = Spring.CallCOBScript -local spGetTeamList = Spring.GetTeamList +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetTeamRulesParam = SpringShared.GetTeamRulesParam +local spSetTeamRulesParam = SpringSynced.SetTeamRulesParam +local spGetTeamResources = SpringShared.GetTeamResources +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitDefID = SpringShared.GetUnitDefID +local spSetUnitResourcing = SpringSynced.SetUnitResourcing +local spCallCOBScript = SpringSynced.CallCOBScript +local spGetTeamList = SpringShared.GetTeamList local mathCeil = math.ceil local tableSort = table.sort diff --git a/luarules/gadgets/game_ffa_start_setup.lua b/luarules/gadgets/game_ffa_start_setup.lua index 8031722e2df..524506e5066 100644 --- a/luarules/gadgets/game_ffa_start_setup.lua +++ b/luarules/gadgets/game_ffa_start_setup.lua @@ -27,7 +27,7 @@ end -- set default logging to INFO since it's kinda important to know when this -- gadget does things with start points and start boxes -Spring.SetLogSectionFilterLevel(gadget:GetInfo().name, LOG.INFO) +SpringUnsynced.SetLogSectionFilterLevel(gadget:GetInfo().name, LOG.INFO) -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -40,7 +40,7 @@ local function tryLoadConfigFromBAR(currentMapName) for _, configFile in pairs(availableConfigFiles) do local basename = configFile:gsub(configsDirectory, ""):gsub(".lua", ""):gsub("_", " "):lower() if string.find(sanitizedCurrentMapName, basename) then - Spring.Log(gadget:GetInfo().name, LOG.INFO, string.format("found FFA start points config %s provided by BAR for current map %s", configFile, currentMapName)) + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, string.format("found FFA start points config %s provided by BAR for current map %s", configFile, currentMapName)) return VFS.Include(configFile), true end end @@ -50,7 +50,7 @@ end local function tryLoadConfigFromMap(currentMapName) local configFile = "luarules/configs/ffa_startpoints.lua" if VFS.FileExists(configFile) then - Spring.Log(gadget:GetInfo().name, LOG.INFO, string.format("found FFA start points config %s provided by current map %s", configFile, currentMapName)) + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, string.format("found FFA start points config %s provided by current map %s", configFile, currentMapName)) return VFS.Include(configFile), true end return nil, false @@ -64,7 +64,7 @@ local function tryLoadConfig(currentMapName, requiredStartPointCount) config, found = tryLoadConfigFromMap(currentMapName) end if not found then - Spring.Log(gadget:GetInfo().name, LOG.INFO, string.format("did not find a FFA start points config for current map %s", currentMapName)) + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, string.format("did not find a FFA start points config for current map %s", currentMapName)) return nil end @@ -76,13 +76,13 @@ local function tryLoadConfig(currentMapName, requiredStartPointCount) -- here, but we also add additional backwards compatibility logic in case any such legacy start points config exists -- in the wild. if ffaStartPoints and ffaStartPoints[requiredStartPointCount] then - Spring.Log(gadget:GetInfo().name, LOG.WARNING, string.format("backwards compatibility layer: using legacy FFA start points config for %s start points", requiredStartPointCount)) + SpringShared.Log(gadget:GetInfo().name, LOG.WARNING, string.format("backwards compatibility layer: using legacy FFA start points config for %s start points", requiredStartPointCount)) layout = ffaStartPoints[requiredStartPointCount] end -- if a FFA start points config file has been found and a layout for the required number of start points is available if config and config.startPoints and config.byAllyTeamCount and config.byAllyTeamCount[requiredStartPointCount] then - Spring.Log(gadget:GetInfo().name, LOG.INFO, string.format("using FFA start points config for %s start points", requiredStartPointCount)) + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, string.format("using FFA start points config for %s start points", requiredStartPointCount)) -- pick a random layout from the ones available local layouts = config.byAllyTeamCount[requiredStartPointCount] @@ -97,11 +97,11 @@ local function tryLoadConfig(currentMapName, requiredStartPointCount) end if not layout then - Spring.Log(gadget:GetInfo().name, LOG.INFO, string.format("did not find a layout for %s start points for current map %s", requiredStartPointCount, currentMapName)) + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, string.format("did not find a layout for %s start points for current map %s", requiredStartPointCount, currentMapName)) return nil elseif #layout ~= requiredStartPointCount then - Spring.Log(gadget:GetInfo().name, LOG.ERROR, string.format("incorrect number of start points found in layout (actual: %s, expected: %s)", #layout, requiredStartPointCount)) - Spring.Log(gadget:GetInfo().name, LOG.ERROR, "FFA start points config is malformed and will NOT be used") + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, string.format("incorrect number of start points found in layout (actual: %s, expected: %s)", #layout, requiredStartPointCount)) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, "FFA start points config is malformed and will NOT be used") return nil else return layout @@ -126,14 +126,14 @@ local function setFFAStartPoints(allyTeamList) GG.ffaStartPoints[allyTeamID] = layout[i] end - Spring.Log(gadget:GetInfo().name, LOG.INFO, "set up start points from FFA start points config for current map") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "set up start points from FFA start points config for current map") end end local function shuffleStartBoxes(allyTeamList) local startBoxes = {} for _, allyTeamID in pairs(allyTeamList) do - local xmin, zmin, xmax, zmax = Spring.GetAllyTeamStartBox(allyTeamID) + local xmin, zmin, xmax, zmax = SpringShared.GetAllyTeamStartBox(allyTeamID) startBoxes[allyTeamID] = { xmin, zmin, xmax, zmax } end @@ -142,11 +142,11 @@ local function shuffleStartBoxes(allyTeamList) for _, allyTeamID in pairs(allyTeamList) do if startBoxes[allyTeamID] then local xmin, zmin, xmax, zmax = unpack(startBoxes[allyTeamID]) - Spring.SetAllyTeamStartBox(allyTeamID, xmin, zmin, xmax, zmax) + SpringSynced.SetAllyTeamStartBox(allyTeamID, xmin, zmin, xmax, zmax) end end - Spring.Log(gadget:GetInfo().name, LOG.INFO, "shuffled start boxes for ally teams (humans and AIs, but not Raptors and Scavengers)") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "shuffled start boxes for ally teams (humans and AIs, but not Raptors and Scavengers)") end function gadget:Initialize() @@ -154,7 +154,7 @@ function gadget:Initialize() local allyTeamList = Spring.Utilities.GetAllyTeamList() setFFAStartPoints(allyTeamList) - if Spring.GetModOptions().teamffa_start_boxes_shuffle then + if SpringShared.GetModOptions().teamffa_start_boxes_shuffle then shuffleStartBoxes(allyTeamList) end diff --git a/luarules/gadgets/game_fogofwar_remover.lua b/luarules/gadgets/game_fogofwar_remover.lua index a4948386e9b..680126f1b4e 100644 --- a/luarules/gadgets/game_fogofwar_remover.lua +++ b/luarules/gadgets/game_fogofwar_remover.lua @@ -3,7 +3,7 @@ if not gadgetHandler:IsSyncedCode() then end local gadgetEnabled = false -if Spring.GetModOptions().disable_fogofwar then +if SpringShared.GetModOptions().disable_fogofwar then gadgetEnabled = true end @@ -21,14 +21,14 @@ function gadget:GetInfo() } end -local spGetAllyTeamList = Spring.GetAllyTeamList +local spGetAllyTeamList = SpringShared.GetAllyTeamList function gadget:GameFrame(n) if n % 1800 == 10 then local allyteams = spGetAllyTeamList() for i = 1, #allyteams do local allyTeamID = allyteams[i] - Spring.SetGlobalLos(allyTeamID, true) + SpringSynced.SetGlobalLos(allyTeamID, true) end end end diff --git a/luarules/gadgets/game_fps_broadcast.lua b/luarules/gadgets/game_fps_broadcast.lua index 34387bf86e2..57132c9217b 100644 --- a/luarules/gadgets/game_fps_broadcast.lua +++ b/luarules/gadgets/game_fps_broadcast.lua @@ -39,9 +39,9 @@ else -- unsynced -------------------------------------------------------------------------------- - local GetLastUpdateSeconds = Spring.GetLastUpdateSeconds - local SendLuaRulesMsg = Spring.SendLuaRulesMsg - local GetFPS = Spring.GetFPS + local GetLastUpdateSeconds = SpringUnsynced.GetLastUpdateSeconds + local SendLuaRulesMsg = SpringUnsynced.SendLuaRulesMsg + local GetFPS = SpringUnsynced.GetFPS local updateTimer = 0 local avgFps = GetFPS() diff --git a/luarules/gadgets/game_id.lua b/luarules/gadgets/game_id.lua index 275f539aaf4..4d2c5eb721e 100644 --- a/luarules/gadgets/game_id.lua +++ b/luarules/gadgets/game_id.lua @@ -17,6 +17,6 @@ function gadget:GetInfo() end function gadget:GameID(msg) - Spring.SetGameRulesParam("GameID", msg) + SpringSynced.SetGameRulesParam("GameID", msg) gadgetHandler:RemoveGadget() end diff --git a/luarules/gadgets/game_initial_spawn.lua b/luarules/gadgets/game_initial_spawn.lua index 93193b9d248..79e51c525c5 100644 --- a/luarules/gadgets/game_initial_spawn.lua +++ b/luarules/gadgets/game_initial_spawn.lua @@ -24,13 +24,13 @@ end -- Synced ---------------------------------------------------------------- if gadgetHandler:IsSyncedCode() then - local spGetPlayerInfo = Spring.GetPlayerInfo - local spGetTeamInfo = Spring.GetTeamInfo - local spGetTeamRulesParam = Spring.GetTeamRulesParam - local spSetTeamRulesParam = Spring.SetTeamRulesParam - local spGetAllyTeamStartBox = Spring.GetAllyTeamStartBox - local spCreateUnit = Spring.CreateUnit - local spGetGroundHeight = Spring.GetGroundHeight + local spGetPlayerInfo = SpringShared.GetPlayerInfo + local spGetTeamInfo = SpringShared.GetTeamInfo + local spGetTeamRulesParam = SpringShared.GetTeamRulesParam + local spSetTeamRulesParam = SpringSynced.SetTeamRulesParam + local spGetAllyTeamStartBox = SpringShared.GetAllyTeamStartBox + local spCreateUnit = SpringSynced.CreateUnit + local spGetGroundHeight = SpringShared.GetGroundHeight local mathRandom = math.random local mathFloor = math.floor local mathBitOr = math.bit_or @@ -44,7 +44,7 @@ if gadgetHandler:IsSyncedCode() then local startUnitParamName = "startUnit" local tooCloseToSpawn = 350 - local allowEnemyAIPlacement = Spring.GetModOptions().allow_enemy_ai_spawn_placement or false + local allowEnemyAIPlacement = SpringShared.GetModOptions().allow_enemy_ai_spawn_placement or false local spawnInitialFrame = Game.spawnInitialFrame local spawnWarpInFrame = Game.spawnWarpInFrame @@ -79,7 +79,7 @@ if gadgetHandler:IsSyncedCode() then end do - local modoptions = Spring.GetModOptions() + local modoptions = SpringShared.GetModOptions() local factionlimiter = tonumber(modoptions.factionlimiter) or 0 if factionlimiter > 0 then local legcomDefID = modoptions.experimentallegionfaction and UnitDefNames.legcom and UnitDefNames.legcom.id @@ -90,7 +90,7 @@ if gadgetHandler:IsSyncedCode() then local LEG_MASK = 2 ^ 2 local FULL_BITMASK = mathBitOr(ARM_MASK, COR_MASK, LEG_MASK) - local allyTeams = Spring.GetAllyTeamList() + local allyTeams = SpringShared.GetAllyTeamList() for i = 1, #allyTeams do local allyTeam = allyTeams[i] local allyStartUnits = {} @@ -127,10 +127,10 @@ if gadgetHandler:IsSyncedCode() then validStartUnits[allyTeam] = allyStartUnits - local allyTeamList = Spring.GetTeamList(allyTeam) + local allyTeamList = SpringShared.GetTeamList(allyTeam) ---@diagnostic disable-next-line: param-type-mismatch for _, teamID in ipairs(allyTeamList) do - Spring.SetTeamRulesParam(teamID, "validStartUnits", packedOptions) + SpringSynced.SetTeamRulesParam(teamID, "validStartUnits", packedOptions) end end @@ -189,7 +189,7 @@ if gadgetHandler:IsSyncedCode() then end packedOptions = packedOptions .. "|" .. RANDOM_DUMMY end - Spring.SetGameRulesParam("validStartUnits", packedOptions) + SpringSynced.SetGameRulesParam("validStartUnits", packedOptions) end end @@ -239,7 +239,7 @@ if gadgetHandler:IsSyncedCode() then ---------------------------------------------------------------- -- Draft Spawn Order -- only enabled when startPosType is 2 ---------------------------------------------------------------- - local draftMode = Spring.GetModOptions().draft_mode + local draftMode = SpringShared.GetModOptions().draft_mode if (Game.startPosType == SPAWN_CHOOSE_IN_GAME) and (draftMode ~= nil and draftMode ~= "disabled") then include("luarules/gadgets/game_draft_spawn_order.lua") else @@ -250,18 +250,18 @@ if gadgetHandler:IsSyncedCode() then -- Initialize ---------------------------------------------------------------- function gadget:Initialize() - Spring.SetLogSectionFilterLevel(gadget:GetInfo().name, LOG.INFO) + SpringUnsynced.SetLogSectionFilterLevel(gadget:GetInfo().name, LOG.INFO) - Spring.SetGameRulesParam("tooCloseToSpawn", tooCloseToSpawn) + SpringSynced.SetGameRulesParam("tooCloseToSpawn", tooCloseToSpawn) - local gaiaTeamID = Spring.GetGaiaTeamID() - local teamList = Spring.GetTeamList() + local gaiaTeamID = SpringShared.GetGaiaTeamID() + local teamList = SpringShared.GetTeamList() for i = 1, #teamList do local teamID = teamList[i] if teamID ~= gaiaTeamID then -- set & broadcast (current) start unit local _, _, _, isAI, teamSide, teamAllyID = spGetTeamInfo(teamID, false) - local comName = Spring.GetSideData(teamSide) + local comName = SpringShared.GetSideData(teamSide) local comDefID = UnitDefNames[comName] and UnitDefNames[comName].id if not isUnitValid(comDefID, teamAllyID) then @@ -289,9 +289,9 @@ if gadgetHandler:IsSyncedCode() then draftModeInitialize() end end - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for _, playerID in pairs(playerList) do - Spring.SetGameRulesParam("player_" .. playerID .. "_readyState", initState) + SpringSynced.SetGameRulesParam("player_" .. playerID .. "_readyState", initState) end -- initializes gameside player readystates @@ -325,34 +325,34 @@ if gadgetHandler:IsSyncedCode() then -- thus, the plan is to keep track of readystats gameside, and only send through GameSetup -- when everyone is ready if msg == "ready_to_start_game" then - Spring.SetGameRulesParam("player_" .. playerID .. "_readyState", READYSTATE_READY) + SpringSynced.SetGameRulesParam("player_" .. playerID .. "_readyState", READYSTATE_READY) end -- keep track of who has joined -- so when last person joins, start the auto-ready countdown if msg == "joined_game" then - Spring.SetGameRulesParam("player_" .. playerID .. "_joined", 1) - local playerList = Spring.GetPlayerList() + SpringSynced.SetGameRulesParam("player_" .. playerID .. "_joined", 1) + local playerList = SpringShared.GetPlayerList() local all_players_joined = true for _, PID in pairs(playerList) do local _, _, spectator_flag = spGetPlayerInfo(PID, false) if spectator_flag == false then - if Spring.GetGameRulesParam("player_" .. PID .. "_joined") == nil then + if SpringShared.GetGameRulesParam("player_" .. PID .. "_joined") == nil then all_players_joined = false end end end if all_players_joined == true then - Spring.SetGameRulesParam("all_players_joined", 1) + SpringSynced.SetGameRulesParam("all_players_joined", 1) end end -- keep track of lock state if msg == "locking_in_place" then - Spring.SetGameRulesParam("player_" .. playerID .. "_lockState", 1) + SpringSynced.SetGameRulesParam("player_" .. playerID .. "_lockState", 1) end if msg == "unlocking_in_place" then - Spring.SetGameRulesParam("player_" .. playerID .. "_lockState", 0) + SpringSynced.SetGameRulesParam("player_" .. playerID .. "_lockState", 0) end if not playerIsSpec and (draftMode ~= nil and draftMode ~= "disabled") then @@ -367,7 +367,7 @@ if gadgetHandler:IsSyncedCode() then x = tonumber(x) z = tonumber(z) - local aiAllyTeamID = select(6, Spring.GetTeamInfo(teamID, false)) + local aiAllyTeamID = select(6, SpringShared.GetTeamInfo(teamID, false)) if playerIsSpec or (aiAllyTeamID ~= allyTeamID and not allowEnemyAIPlacement) then return false @@ -380,18 +380,18 @@ if gadgetHandler:IsSyncedCode() then if currentPos and currentPos[1] > 0 and currentPos[2] > 0 and validateSpawnPosition(currentPos[1], currentPos[2], teamID, playerID) then x, z = currentPos[1], currentPos[2] local y = spGetGroundHeight(x, z) - Spring.SetTeamStartPosition(teamID, x, y, z) + SpringSynced.SetTeamStartPosition(teamID, x, y, z) updateAIManualPlacement(teamID, x, z) else updateAIManualPlacement(teamID) end elseif x == 0 and z == 0 then - Spring.SetTeamStartPosition(teamID, -1, -1, -1) -- Reset position + SpringSynced.SetTeamStartPosition(teamID, -1, -1, -1) -- Reset position startPointTable[teamID] = nil updateAIManualPlacement(teamID) else local y = spGetGroundHeight(x, z) - Spring.SetTeamStartPosition(teamID, x, y, z) + SpringSynced.SetTeamStartPosition(teamID, x, y, z) startPointTable[teamID] = { x, z } updateAIManualPlacement(teamID, x, z) end @@ -419,10 +419,10 @@ if gadgetHandler:IsSyncedCode() then end if type == 2 then - return not (Spring.TestMoveOrder(unitDefID, x, y, z) and Spring.TestMoveOrder(unitDefID, x, y, z, 1, 0, 0) and Spring.TestMoveOrder(unitDefID, x, y, z, 0, 0, 1) and Spring.TestMoveOrder(unitDefID, x, y, z, -1, 0, 0) and Spring.TestMoveOrder(unitDefID, x, y, z, 0, 0, -1)) + return not (SpringShared.TestMoveOrder(unitDefID, x, y, z) and SpringShared.TestMoveOrder(unitDefID, x, y, z, 1, 0, 0) and SpringShared.TestMoveOrder(unitDefID, x, y, z, 0, 0, 1) and SpringShared.TestMoveOrder(unitDefID, x, y, z, -1, 0, 0) and SpringShared.TestMoveOrder(unitDefID, x, y, z, 0, 0, -1)) end - return Spring.TestBuildOrder(unitDefID, x, y, z, "s") == 0 + return SpringShared.TestBuildOrder(unitDefID, x, y, z, "s") == 0 end function gadget:AllowStartPosition(playerID, teamID, readyState, x, y, z) @@ -443,7 +443,7 @@ if gadgetHandler:IsSyncedCode() then return false end - local _, _, _, teamID, allyTeamID = Spring.GetPlayerInfo(playerID, false) + local _, _, _, teamID, allyTeamID = SpringShared.GetPlayerInfo(playerID, false) if not teamID or not allyTeamID then return false end --fail @@ -476,14 +476,14 @@ if gadgetHandler:IsSyncedCode() then end -- don't allow player to place if locked - local is_player_locked = Spring.GetGameRulesParam("player_" .. playerID .. "_lockState") + local is_player_locked = SpringShared.GetGameRulesParam("player_" .. playerID .. "_lockState") if is_player_locked == 1 then return false end -- communicate readyState to all -- Spring.SetGameRulesParam("player_" .. playerID .. "_readyState", readyState) - local is_player_ready = Spring.GetGameRulesParam("player_" .. playerID .. "_readyState") + local is_player_ready = SpringShared.GetGameRulesParam("player_" .. playerID .. "_readyState") local isValid = validateSpawnPosition(x, z, teamID, playerID) @@ -491,7 +491,7 @@ if gadgetHandler:IsSyncedCode() then local currentPos = startPointTable[teamID] if currentPos and currentPos[1] > 0 and currentPos[2] > 0 and validateSpawnPosition(currentPos[1], currentPos[2], teamID, playerID) then local y = spGetGroundHeight(currentPos[1], currentPos[2]) - Spring.SetTeamStartPosition(teamID, currentPos[1], y, currentPos[2]) + SpringSynced.SetTeamStartPosition(teamID, currentPos[1], y, currentPos[2]) end return false end @@ -507,7 +507,7 @@ if gadgetHandler:IsSyncedCode() then startPointTable[teamID] = { x, z } if is_player_ready ~= READYSTATE_READY then -- game is not starting (therefore, player cannot yet have pressed ready) - Spring.SetGameRulesParam("player_" .. playerID .. "_readyState", READYSTATE_PLACED_UNREADY) + SpringSynced.SetGameRulesParam("player_" .. playerID .. "_readyState", READYSTATE_PLACED_UNREADY) end end @@ -546,7 +546,7 @@ if gadgetHandler:IsSyncedCode() then local startUnitBlocking = {} local function spawnStartUnit(teamID, x, z) local startUnit = spGetTeamRulesParam(teamID, startUnitParamName) - local luaAI = Spring.GetTeamLuaAI(teamID) + local luaAI = SpringShared.GetTeamLuaAI(teamID) local _, _, _, isAI, sideName, allyTeadID = spGetTeamInfo(teamID, false) if (startUnit or RANDOM_DUMMY) == RANDOM_DUMMY then @@ -557,10 +557,10 @@ if gadgetHandler:IsSyncedCode() then local y = spGetGroundHeight(x, z) local scenarioSpawnsUnits = false - if Spring.GetModOptions().scenariooptions then - local scenariooptions = Json.decode(string.base64Decode(Spring.GetModOptions().scenariooptions)) + if SpringShared.GetModOptions().scenariooptions then + local scenariooptions = Json.decode(string.base64Decode(SpringShared.GetModOptions().scenariooptions)) if scenariooptions and scenariooptions.unitloadout and next(scenariooptions.unitloadout) then - Spring.Echo("Scenario: Spawning loadout instead of regular commanders") + SpringShared.Echo("Scenario: Spawning loadout instead of regular commanders") scenarioSpawnsUnits = true end end @@ -571,15 +571,15 @@ if gadgetHandler:IsSyncedCode() then if unitID then startUnitList[#startUnitList + 1] = { unitID = unitID, teamID = teamID, x = x, y = y, z = z } if not isAI then - Spring.MoveCtrl.Enable(unitID) + SpringSynced.MoveCtrl.Enable(unitID) end - Spring.SetUnitNoDraw(unitID, true) - local uhealth, umaxhealth, uparalyze = Spring.GetUnitHealth(unitID) + SpringUnsynced.SetUnitNoDraw(unitID, true) + local uhealth, umaxhealth, uparalyze = SpringShared.GetUnitHealth(unitID) local paralyzemult = 3 * 0.025 -- 3 seconds of paralyze local paralyzedamage = (umaxhealth - uparalyze) + (umaxhealth * paralyzemult) - Spring.SetUnitHealth(unitID, { paralyze = paralyzedamage }) - startUnitBlocking[unitID] = { Spring.GetUnitBlocking(unitID) } - Spring.SetUnitBlocking(unitID, false, false, false, false, false, false, false) + SpringSynced.SetUnitHealth(unitID, { paralyze = paralyzedamage }) + startUnitBlocking[unitID] = { SpringShared.GetUnitBlocking(unitID) } + SpringSynced.SetUnitBlocking(unitID, false, false, false, false, false, false, false) end end end @@ -616,7 +616,7 @@ if gadgetHandler:IsSyncedCode() then end local function spawnRegularly(teamID, allyTeamID) - local x, _, z = Spring.GetTeamStartPosition(teamID) + local x, _, z = SpringShared.GetTeamStartPosition(teamID) local xmin, zmin, xmax, zmax = spGetAllyTeamStartBox(allyTeamID) if Game.startPosType == SPAWN_CHOOSE_IN_GAME then @@ -654,7 +654,7 @@ if gadgetHandler:IsSyncedCode() then local guessedX, guessedZ = GuessStartSpot(teamID, allyTeamID, xmin, zmin, xmax, zmax, startPointTable) if guessedX and guessedZ then local y = spGetGroundHeight(guessedX, guessedZ) - Spring.SetTeamStartPosition(teamID, guessedX, y, guessedZ) + SpringSynced.SetTeamStartPosition(teamID, guessedX, y, guessedZ) startPointTable[teamID] = { guessedX, guessedZ } end end @@ -664,18 +664,18 @@ if gadgetHandler:IsSyncedCode() then -- if this a FFA match with automatic spawning (i.e. no start boxes) and a list of start points was provided by -- `game_ffa_start_setup` for the ally teams in this match if isFFA and Game.startPosType == SPAWN_CHOOSE_BEFORE_GAME and GG.ffaStartPoints then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "spawn using FFA start points config") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "spawn using FFA start points config") for teamID, allyTeamID in pairs(teams) do spawnUsingFFAStartPoints(teamID, allyTeamID) end else -- otherwise default to spawning regularly if Game.startPosType == SPAWN_CHOOSE_IN_GAME then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "manual spawning based on positions chosen by players in start boxes") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "manual spawning based on positions chosen by players in start boxes") elseif Game.startPosType == SPAWN_CHOOSE_BEFORE_GAME then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "automatic spawning using default map start positions, in random order") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "automatic spawning using default map start positions, in random order") elseif Game.startPosType == SPAWN_FIXED then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "automatic spawning using default map start positions, in fixed order") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "automatic spawning using default map start positions, in fixed order") end for teamID, allyTeamID in pairs(teams) do spawnRegularly(teamID, allyTeamID) @@ -691,7 +691,7 @@ if gadgetHandler:IsSyncedCode() then local x = startUnitList[i].x local y = startUnitList[i].y local z = startUnitList[i].z - Spring.SpawnCEG("commander-spawn", x, y, z, 0, 0, 0) + SpringSynced.SpawnCEG("commander-spawn", x, y, z, 0, 0, 0) GG.ComSpawnDefoliate(x, y, z) end @@ -699,12 +699,12 @@ if gadgetHandler:IsSyncedCode() then if n == spawnWarpInFrame then for i = 1, #startUnitList do local unitID = startUnitList[i].unitID - Spring.MoveCtrl.Disable(unitID) - Spring.SetUnitNoDraw(unitID, false) - Spring.SetUnitHealth(unitID, { paralyze = 0 }) + SpringSynced.MoveCtrl.Disable(unitID) + SpringUnsynced.SetUnitNoDraw(unitID, false) + SpringSynced.SetUnitHealth(unitID, { paralyze = 0 }) local unitBlocking = startUnitBlocking[unitID] if unitBlocking then - Spring.SetUnitBlocking(unitID, unpack(unitBlocking)) + SpringSynced.SetUnitBlocking(unitID, unpack(unitBlocking)) end end end @@ -720,7 +720,7 @@ else -- UNSYNCED local function positionTooClose(_, playerID) if Script.LuaUI("GadgetMessageProxy") then local message = Script.LuaUI.GadgetMessageProxy("ui.initialSpawn.tooClose") - Spring.SendMessageToPlayer(playerID, message) + SpringUnsynced.SendMessageToPlayer(playerID, message) end end @@ -733,7 +733,7 @@ else -- UNSYNCED function gadget:GameFrame(n) if n == spawnInitialFrame then - Spring.PlaySoundFile("commanderspawn", 0.6, "ui") + SpringUnsynced.PlaySoundFile("commanderspawn", 0.6, "ui") end if n > spawnWarpInFrame then gadgetHandler:RemoveGadget(self) diff --git a/luarules/gadgets/game_logger.lua b/luarules/gadgets/game_logger.lua index 43402168e16..33645192d6b 100644 --- a/luarules/gadgets/game_logger.lua +++ b/luarules/gadgets/game_logger.lua @@ -24,8 +24,8 @@ if gadgetHandler:IsSyncedCode() then else - local spSendLuaRulesMsg = Spring.SendLuaRulesMsg - local spAreTeamsAllied = Spring.AreTeamsAllied + local spSendLuaRulesMsg = SpringUnsynced.SendLuaRulesMsg + local spAreTeamsAllied = SpringShared.AreTeamsAllied local validation = SYNCED.validationLog local isCommander = {} @@ -54,12 +54,12 @@ else local myTeamID = Spring.GetMyTeamID() local myPlayerID = Spring.GetMyPlayerID() - local mySpec, fullview = Spring.GetSpectatingState() + local mySpec, fullview = SpringUnsynced.GetSpectatingState() function gadget:PlayerChanged(playerID) if playerID == myPlayerID then myTeamID = Spring.GetMyTeamID() - mySpec, fullview = Spring.GetSpectatingState() + mySpec, fullview = SpringUnsynced.GetSpectatingState() end end @@ -70,7 +70,7 @@ else -- Check if its a commander doing shenanigan to others eco units if (isEcoUnit[unitDefID] or isCommander[unitDefID]) and spAreTeamsAllied(unitTeam, attackerTeam) and isCommander[attackerDefID] then -- This is an 'only attack friendlies with commander' type thing - local msg = string.format("l0g%s:friendlyfire:%d:%s:%d:%d:%d", validation, Spring.GetGameFrame(), "ud", unitTeam, attackerTeam, unitDefID) + local msg = string.format("l0g%s:friendlyfire:%d:%s:%d:%d:%d", validation, SpringShared.GetGameFrame(), "ud", unitTeam, attackerTeam, unitDefID) --Spring.Echo(msg) spSendLuaRulesMsg(msg) end @@ -79,11 +79,11 @@ else function gadget:UnitLoaded(unitID, unitDefID, unitTeam, transportID, transportTeam) if not mySpec and transportTeam == myTeamID and unitTeam ~= transportTeam and isCommander[unitDefID] then - local _, _, _, isAiTeam = Spring.GetTeamInfo(unitTeam, false) + local _, _, _, isAiTeam = SpringShared.GetTeamInfo(unitTeam, false) if isAiTeam then return end - local msg = string.format("l0g%s:allycommloaded:%d:%s:%d:%d:%d", validation, Spring.GetGameFrame(), "ud", unitTeam, transportTeam, unitDefID) + local msg = string.format("l0g%s:allycommloaded:%d:%s:%d:%d:%d", validation, SpringShared.GetGameFrame(), "ud", unitTeam, transportTeam, unitDefID) spSendLuaRulesMsg(msg) end end diff --git a/luarules/gadgets/game_message.lua b/luarules/gadgets/game_message.lua index ff5bb02f834..0e856ba51e3 100644 --- a/luarules/gadgets/game_message.lua +++ b/luarules/gadgets/game_message.lua @@ -31,10 +31,10 @@ if gadgetHandler:IsSyncedCode() then else -- UNSYNCED local function sendMsg(_, playerID, msg) - local name, _, spec, _, playerAllyTeamID = Spring.GetPlayerInfo(playerID, false) - local mySpec = Spring.GetSpectatingState() + local name, _, spec, _, playerAllyTeamID = SpringShared.GetPlayerInfo(playerID, false) + local mySpec = SpringUnsynced.GetSpectatingState() if not spec and (playerAllyTeamID == Spring.GetMyAllyTeamID() or mySpec) then - Spring.SendMessageToPlayer(Spring.GetMyPlayerID(), "<" .. name .. "> Allies: > " .. msg) + SpringUnsynced.SendMessageToPlayer(Spring.GetMyPlayerID(), "<" .. name .. "> Allies: > " .. msg) end end diff --git a/luarules/gadgets/game_no_rush_mode.lua b/luarules/gadgets/game_no_rush_mode.lua index d03468f443c..6171afb977c 100644 --- a/luarules/gadgets/game_no_rush_mode.lua +++ b/luarules/gadgets/game_no_rush_mode.lua @@ -8,13 +8,13 @@ function gadget:GetInfo() date = "2022", license = "GNU GPL, v2 or later", layer = -100, - enabled = Spring.GetModOptions().norushtimer > 0, + enabled = SpringShared.GetModOptions().norushtimer > 0, } end -- Get Startbox Area of every player local positionCheckLibrary = VFS.Include("luarules/utilities/damgam_lib/position_checks.lua") -local norushtimer = Spring.GetModOptions().norushtimer * 1800 -- modoption is stating minutes, and we need frames. 60 seconds * 30 frames = 1800 +local norushtimer = SpringShared.GetModOptions().norushtimer * 1800 -- modoption is stating minutes, and we need frames. 60 seconds * 30 frames = 1800 local CommandsToCatchMap = { -- CMDTYPES: ICON_MAP, ICON_AREA, ICON_UNIT_OR_MAP, ICON_UNIT_OR_AREA, ICON_UNIT_FEATURE_OR_AREA, ICON_BUILDING [CMD.MOVE] = true, @@ -59,8 +59,8 @@ local LuaAIsToExclude = { local TeamIDsToExclude = {} -- dynamically filled below -for _, teamID in ipairs(Spring.GetTeamList()) do - local teamLuaAI = Spring.GetTeamLuaAI(teamID) +for _, teamID in ipairs(SpringShared.GetTeamList()) do + local teamLuaAI = SpringShared.GetTeamLuaAI(teamID) if teamLuaAI and LuaAIsToExclude[teamLuaAI] then TeamIDsToExclude[teamID] = true end @@ -84,10 +84,10 @@ if gadgetHandler:IsSyncedCode() then function gadget:AllowCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag, synced) local allowed = true - local frame = Spring.GetGameFrame() + local frame = SpringShared.GetGameFrame() if frame < norushtimer and not TeamIDsToExclude[unitTeam] then - local _, _, _, _, _, allyTeamID = Spring.GetTeamInfo(unitTeam, false) + local _, _, _, _, _, allyTeamID = SpringShared.GetTeamInfo(unitTeam, false) if cmdID < 0 then if cmdParams[1] and cmdParams[2] and cmdParams[3] then @@ -107,21 +107,21 @@ if gadgetHandler:IsSyncedCode() then end elseif CommandsToCatchUnit[cmdID] and #cmdParams == 1 then local targetUnitID = cmdParams[1] - if Spring.GetUnitDefID(targetUnitID) then - local x, y, z = Spring.GetUnitPosition(targetUnitID) + if SpringShared.GetUnitDefID(targetUnitID) then + local x, y, z = SpringShared.GetUnitPosition(targetUnitID) if not positionCheckLibrary.StartboxCheck(x, y, z, allyTeamID) then allowed = false end - elseif Spring.GetFeatureDefID(targetUnitID - Game.maxUnits) and CommandsToCatchFeature[cmdID] then -- maybe it's a feature that we want to reclaim? - local x, y, z = Spring.GetFeaturePosition(targetUnitID - Game.maxUnits) + elseif SpringShared.GetFeatureDefID(targetUnitID - Game.maxUnits) and CommandsToCatchFeature[cmdID] then -- maybe it's a feature that we want to reclaim? + local x, y, z = SpringShared.GetFeaturePosition(targetUnitID - Game.maxUnits) if not positionCheckLibrary.StartboxCheck(x, y, z, allyTeamID) then allowed = false end end elseif CommandsToCatchFeature[cmdID] and #cmdParams == 1 then local targetFeatureID = cmdParams[1] - if Spring.GetFeatureDefID(targetFeatureID - Game.maxUnits) then - local x, y, z = Spring.GetFeaturePosition(targetFeatureID - Game.maxUnits) + if SpringShared.GetFeatureDefID(targetFeatureID - Game.maxUnits) then + local x, y, z = SpringShared.GetFeaturePosition(targetFeatureID - Game.maxUnits) if not positionCheckLibrary.StartboxCheck(x, y, z, allyTeamID) then allowed = false end diff --git a/luarules/gadgets/game_no_share_to_enemy.lua b/luarules/gadgets/game_no_share_to_enemy.lua index 3685bfcb04d..79766c5aeec 100644 --- a/luarules/gadgets/game_no_share_to_enemy.lua +++ b/luarules/gadgets/game_no_share_to_enemy.lua @@ -19,14 +19,14 @@ if not gadgetHandler:IsSyncedCode() then return end -local AreTeamsAllied = Spring.AreTeamsAllied -local IsCheatingEnabled = Spring.IsCheatingEnabled +local AreTeamsAllied = SpringShared.AreTeamsAllied +local IsCheatingEnabled = SpringShared.IsCheatingEnabled -local isNonPlayerTeam = { [Spring.GetGaiaTeamID()] = true } -local teams = Spring.GetTeamList() +local isNonPlayerTeam = { [SpringShared.GetGaiaTeamID()] = true } +local teams = SpringShared.GetTeamList() for i = 1, #teams do - local _, _, _, isAiTeam = Spring.GetTeamInfo(teams[i], false) - local isLuaAI = (Spring.GetTeamLuaAI(teams[i]) ~= nil) + local _, _, _, isAiTeam = SpringShared.GetTeamInfo(teams[i], false) + local isLuaAI = (SpringShared.GetTeamLuaAI(teams[i]) ~= nil) if isAiTeam or isLuaAI then isNonPlayerTeam[teams[i]] = true end diff --git a/luarules/gadgets/game_prevent_excessive_share.lua b/luarules/gadgets/game_prevent_excessive_share.lua index 376803069eb..3c18a8a4c37 100644 --- a/luarules/gadgets/game_prevent_excessive_share.lua +++ b/luarules/gadgets/game_prevent_excessive_share.lua @@ -19,8 +19,8 @@ if not gadgetHandler:IsSyncedCode() then return false end -local spIsCheatingEnabled = Spring.IsCheatingEnabled -local spGetTeamUnitCount = Spring.GetTeamUnitCount +local spIsCheatingEnabled = SpringShared.IsCheatingEnabled +local spGetTeamUnitCount = SpringShared.GetTeamUnitCount ---------------------------------------------------------------- -- Callins @@ -39,13 +39,13 @@ function gadget:AllowResourceTransfer(senderTeamId, receiverTeamId, resourceType end -- Calculate the maximum amount the receiver can receive - local rCur, rStor, rPull, rInc, rExp, rShare = Spring.GetTeamResources(receiverTeamId, resourceName) + local rCur, rStor, rPull, rInc, rExp, rShare = SpringShared.GetTeamResources(receiverTeamId, resourceName) local maxShare = rStor * rShare - rCur -- Is the sender trying to send more than the maximum? Block it, possibly sending a reduced amount instead if amount > maxShare then if maxShare > 0 then - Spring.ShareTeamResource(senderTeamId, receiverTeamId, resourceName, maxShare) + SpringSynced.ShareTeamResource(senderTeamId, receiverTeamId, resourceName, maxShare) end return false end @@ -56,7 +56,7 @@ end function gadget:AllowUnitTransfer(unitID, unitDefID, oldTeam, newTeam, capture) local unitCount = spGetTeamUnitCount(newTeam) - if capture or spIsCheatingEnabled() or unitCount < Spring.GetTeamMaxUnits(newTeam) then + if capture or spIsCheatingEnabled() or unitCount < SpringShared.GetTeamMaxUnits(newTeam) then return true end return false diff --git a/luarules/gadgets/game_quick_start.lua b/luarules/gadgets/game_quick_start.lua index 057a0ea9e31..84e068330a3 100644 --- a/luarules/gadgets/game_quick_start.lua +++ b/luarules/gadgets/game_quick_start.lua @@ -11,7 +11,7 @@ function gadget:GetInfo() end local isSynced = gadgetHandler:IsSyncedCode() -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() if not isSynced then return false @@ -97,19 +97,19 @@ local INITIAL_BUILD_PROGRESS = 0.01 local TRAVERSABILITY_GRID_RESOLUTION = 32 local GRID_CHECK_RESOLUTION_MULTIPLIER = 1 -local spCreateUnit = Spring.CreateUnit -local spGetGroundHeight = Spring.GetGroundHeight -local spGetUnitCommands = Spring.GetUnitCommands -local spGetUnitPosition = Spring.GetUnitPosition -local spPos2BuildPos = Spring.Pos2BuildPos -local spTestBuildOrder = Spring.TestBuildOrder -local spSetUnitHealth = Spring.SetUnitHealth -local spValidUnitID = Spring.ValidUnitID -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitHealth = Spring.GetUnitHealth -local spTestMoveOrder = Spring.TestMoveOrder +local spCreateUnit = SpringSynced.CreateUnit +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetUnitCommands = SpringShared.GetUnitCommands +local spGetUnitPosition = SpringShared.GetUnitPosition +local spPos2BuildPos = SpringShared.Pos2BuildPos +local spTestBuildOrder = SpringShared.TestBuildOrder +local spSetUnitHealth = SpringSynced.SetUnitHealth +local spValidUnitID = SpringShared.ValidUnitID +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitHealth = SpringShared.GetUnitHealth +local spTestMoveOrder = SpringShared.TestMoveOrder local random = math.random local ceil = math.ceil local max = math.max @@ -308,8 +308,8 @@ local function generateOverlapLines(commanderID) local neighbors = {} for _, otherTeamID in ipairs(allTeamsList) do - if otherTeamID ~= comData.teamID and Spring.AreTeamsAllied(comData.teamID, otherTeamID) then - local sx, sy, sz = Spring.GetTeamStartPosition(otherTeamID) + if otherTeamID ~= comData.teamID and SpringShared.AreTeamsAllied(comData.teamID, otherTeamID) then + local sx, sy, sz = SpringShared.GetTeamStartPosition(otherTeamID) if sx and sx >= 0 then -- Check for valid start pos (allow 0, ignore -100) table.insert(neighbors, { x = sx, z = sz }) end @@ -331,7 +331,7 @@ local function getCommanderBuildQueue(commanderID) generateOverlapLines(commanderID) end - Spring.Echo(string.format("=== Validating Build Queue for Commander %d (Team %d) ===", commanderID, comData.teamID)) + SpringShared.Echo(string.format("=== Validating Build Queue for Commander %d (Team %d) ===", commanderID, comData.teamID)) for i, cmd in ipairs(commands) do if isBuildCommand(cmd.id) then @@ -370,7 +370,7 @@ local function getCommanderBuildQueue(commanderID) totalBudgetCost = totalBudgetCost + budgetCost if totalBudgetCost > comData.budget then - Spring.Echo(string.format(" [%d] %s at (%.1f, %.1f, %.1f) facing: %d - REJECTED (Budget exceeded: %.1f > %.1f)", i, unitDefName, spawnParams.x, spawnParams.y, spawnParams.z, spawnParams.facing, totalBudgetCost, comData.budget)) + SpringShared.Echo(string.format(" [%d] %s at (%.1f, %.1f, %.1f) facing: %d - REJECTED (Budget exceeded: %.1f > %.1f)", i, unitDefName, spawnParams.x, spawnParams.y, spawnParams.z, spawnParams.facing, totalBudgetCost, comData.budget)) comData.commandsToRemove = commandsToRemove return spawnQueue end @@ -390,12 +390,12 @@ local function getCommanderBuildQueue(commanderID) table.insert(failReasons, "PastFriendlyLines") end local failReasonsStr = table.concat(failReasons, ", ") - Spring.Echo(string.format(" [%d] %s at (%.1f, %.1f, %.1f) facing: %d - REJECTED (%s)", i, unitDefName, spawnParams.x, spawnParams.y, spawnParams.z, spawnParams.facing, failReasonsStr)) + SpringShared.Echo(string.format(" [%d] %s at (%.1f, %.1f, %.1f) facing: %d - REJECTED (%s)", i, unitDefName, spawnParams.x, spawnParams.y, spawnParams.z, spawnParams.facing, failReasonsStr)) end end end comData.commandsToRemove = commandsToRemove - Spring.Echo(string.format("=== Accepted %d/%d build queue items ===", #spawnQueue, #commands)) + SpringShared.Echo(string.format("=== Accepted %d/%d build queue items ===", #spawnQueue, #commands)) return spawnQueue end @@ -634,8 +634,8 @@ local function initializeCommander(commanderID, teamID) end end - local currentMetal = Spring.GetTeamResources(teamID, "metal") or 0 - local currentEnergy = Spring.GetTeamResources(teamID, "energy") or 0 + local currentMetal = SpringShared.GetTeamResources(teamID, "metal") or 0 + local currentEnergy = SpringShared.GetTeamResources(teamID, "energy") or 0 local commanderX, commanderY, commanderZ = spGetUnitPosition(commanderID) if not commanderX or not commanderY or not commanderZ then @@ -646,7 +646,7 @@ local function initializeCommander(commanderID, teamID) local angle = atan2(directionX, directionZ) local defaultFacing = floor((angle / (pi / 2)) + 0.5) % 4 - local commanderDefID = Spring.GetUnitDefID(commanderID) + local commanderDefID = SpringShared.GetUnitDefID(commanderID) local commanderName = UnitDefs[commanderDefID].name local isInWater = commanderY < 0 local buildDefs = {} @@ -678,8 +678,8 @@ local function initializeCommander(commanderID, teamID) unitDefID = commanderDefID, } - Spring.SetTeamResource(teamID, "metal", max(0, currentMetal - QUICK_START_COST_METAL)) - Spring.SetTeamResource(teamID, "energy", max(0, currentEnergy - QUICK_START_COST_ENERGY)) + SpringSynced.SetTeamResource(teamID, "metal", max(0, currentMetal - QUICK_START_COST_METAL)) + SpringSynced.SetTeamResource(teamID, "energy", max(0, currentEnergy - QUICK_START_COST_ENERGY)) local comData = commanders[commanderID] comData.spawnX, comData.spawnY, comData.spawnZ = spGetUnitPosition(commanderID) @@ -730,7 +730,7 @@ local function generateBuildCommands(commanderID) elseif comData.hasBuildsIntercepted and budgetRemaining <= READY_REFUNDABLE_BUDGET or cost > budgetRemaining then shouldQueue = false local refundAmount = budgetRemaining - Spring.AddTeamResource(comData.teamID, "metal", refundAmount) + SpringSynced.AddTeamResource(comData.teamID, "metal", refundAmount) comData.budget = comData.budget - budgetRemaining break end @@ -755,7 +755,7 @@ local function removeCommanderCommands(commanderID) local comData = commanders[commanderID] if comData and comData.commandsToRemove and #comData.commandsToRemove > 0 then for _, cmdTag in ipairs(comData.commandsToRemove) do - Spring.GiveOrderToUnit(commanderID, CMD.REMOVE, { cmdTag }, {}) + SpringSynced.GiveOrderToUnit(commanderID, CMD.REMOVE, { cmdTag }, {}) end comData.commandsToRemove = {} end @@ -769,7 +769,7 @@ local function tryToSpawnBuild(commanderID, unitDefID, buildX, buildY, buildZ, f local unitID = spCreateUnit(unitDef.name, buildX, buildY, buildZ, facing, comData.teamID) if not unitID then - Spring.Echo(string.format(" SPAWN FAILED: %s at (%.1f, %.1f, %.1f) facing: %d - CreateUnit returned nil (terrain/collision conflict)", unitDefName, buildX, buildY, buildZ, facing)) + SpringShared.Echo(string.format(" SPAWN FAILED: %s at (%.1f, %.1f, %.1f) facing: %d - CreateUnit returned nil (terrain/collision conflict)", unitDefName, buildX, buildY, buildZ, facing)) return false, nil end @@ -787,7 +787,7 @@ local function tryToSpawnBuild(commanderID, unitDefID, buildX, buildY, buildZ, f end if projectedBuildProgress < 1 then - Spring.GiveOrderToUnit(commanderID, CMD.INSERT, { 0, CMD.REPAIR, CMD.OPT_SHIFT, unitID }, CMD.OPT_ALT) + SpringSynced.GiveOrderToUnit(commanderID, CMD.INSERT, { 0, CMD.REPAIR, CMD.OPT_SHIFT, unitID }, CMD.OPT_ALT) end return projectedBuildProgress >= 1 @@ -796,7 +796,7 @@ end function gadget:GameFrame(frame) if not initialized and frame > PREGAME_DELAY_FRAMES then if #allTeamsList == 0 then - allTeamsList = Spring.GetTeamList() + allTeamsList = SpringShared.GetTeamList() end local modulo = frame % #allTeamsList @@ -824,7 +824,7 @@ function gadget:GameFrame(frame) end local loop = modOptions.quick_start ~= "factory_discount_only" if loop and gameFrameTryCount == 1 then - Spring.Echo("=== Beginning Quick Start Spawn Phase ===") + SpringShared.Echo("=== Beginning Quick Start Spawn Phase ===") end while loop do loop = false @@ -859,7 +859,7 @@ function gadget:GameFrame(frame) if #failReasons > 0 then local failReasonsStr = table.concat(failReasons, ", ") local coordsStr = buildItem.x and string.format("(%.1f, %.1f, %.1f)", buildItem.x, buildItem.y or 0, buildItem.z) or "(no coords)" - Spring.Echo(string.format(" SPAWN SKIPPED: %s at %s facing: %d - %s", unitDefName, coordsStr, facing, failReasonsStr)) + SpringShared.Echo(string.format(" SPAWN SKIPPED: %s at %s facing: %d - %s", unitDefName, coordsStr, facing, failReasonsStr)) end end end @@ -891,8 +891,8 @@ function gadget:GameFrame(frame) local buildProgress = select(5, spGetUnitHealth(unitID)) if buildProgress >= 1 then -- due to some kind of glitch related to incrimentally increasing build progress to 1, we gotta cycle mexes off and on to get them to actually extract metal. - Spring.GiveOrderToUnit(unitID, CMD.ONOFF, { 0 }, 0) - Spring.GiveOrderToUnit(unitID, CMD.ONOFF, { 1 }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.ONOFF, { 0 }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.ONOFF, { 1 }, 0) buildsInProgress[unitID] = nil end elseif buildData.targetProgress > buildData.addedProgress then @@ -914,7 +914,7 @@ function gadget:GameFrame(frame) if initialized and allDiscountsUsed and not running and allBuildsCompleted then for commanderID, comData in pairs(commanders) do if comData.budget and comData.budget > 0 then - Spring.AddTeamResource(comData.teamID, "metal", comData.budget) + SpringSynced.AddTeamResource(comData.teamID, "metal", comData.budget) end end gadgetHandler:RemoveGadget() @@ -932,12 +932,12 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) end local unitDef = unitDefs[unitDefID] - local discount = not Spring.GetTeamRulesParam(unitTeam, "quickStartFactoryDiscountUsed") and getFactoryDiscount(unitDef, builderID) or 0 + local discount = not SpringShared.GetTeamRulesParam(unitTeam, "quickStartFactoryDiscountUsed") and getFactoryDiscount(unitDef, builderID) or 0 if discount > 0 and builderID then if builderID then commanderFactoryDiscounts[builderID] = true end - Spring.SetTeamRulesParam(unitTeam, "quickStartFactoryDiscountUsed", 1) + SpringSynced.SetTeamRulesParam(unitTeam, "quickStartFactoryDiscountUsed", 1) local fullBudgetCost = defMetergies[unitDefID] queueBuildForProgression(unitID, unitDef, discount, fullBudgetCost) @@ -945,18 +945,18 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) end function gadget:Initialize() - for _, teamID in ipairs(Spring.GetTeamList()) do - Spring.SetTeamRulesParam(teamID, "quickStartFactoryDiscountUsed", nil) + for _, teamID in ipairs(SpringShared.GetTeamList()) do + SpringSynced.SetTeamRulesParam(teamID, "quickStartFactoryDiscountUsed", nil) end isGoodWind = windFunctions.isGoodWind() isMetalMap = GG and GG["resource_spot_finder"] and GG["resource_spot_finder"].isMetalMap metalSpotsList = GG and GG["resource_spot_finder"] and GG["resource_spot_finder"].metalSpotsList - local frame = Spring.GetGameFrame() - Spring.SetGameRulesParam("quickStartBudgetBase", BUDGET) - Spring.SetGameRulesParam("quickStartFactoryDiscountAmount", FACTORY_DISCOUNT) - Spring.SetGameRulesParam("quickStartMetalDeduction", QUICK_START_COST_METAL) - Spring.SetGameRulesParam("quickStartTraversabilityGridRange", TRAVERSABILITY_GRID_GENERATION_RANGE) + local frame = SpringShared.GetGameFrame() + SpringSynced.SetGameRulesParam("quickStartBudgetBase", BUDGET) + SpringSynced.SetGameRulesParam("quickStartFactoryDiscountAmount", FACTORY_DISCOUNT) + SpringSynced.SetGameRulesParam("quickStartMetalDeduction", QUICK_START_COST_METAL) + SpringSynced.SetGameRulesParam("quickStartTraversabilityGridRange", TRAVERSABILITY_GRID_GENERATION_RANGE) local cheapestEconomicCost = calculateCheapestEconomicStructure() local anyCommanderHasBuildsIntercepted = false for commanderID, comData in pairs(commanders) do @@ -966,13 +966,13 @@ function gadget:Initialize() end end local budgetThresholdToAllowStart = not anyCommanderHasBuildsIntercepted and READY_REFUNDABLE_BUDGET or cheapestEconomicCost - Spring.SetGameRulesParam("quickStartBudgetThresholdToAllowStart", budgetThresholdToAllowStart) + SpringSynced.SetGameRulesParam("quickStartBudgetThresholdToAllowStart", budgetThresholdToAllowStart) if modOptions.quick_start ~= "factory_discount_only" then - Spring.SetGameRulesParam("overridePregameBuildDistance", INSTANT_BUILD_RANGE) + SpringSynced.SetGameRulesParam("overridePregameBuildDistance", INSTANT_BUILD_RANGE) end if frame > 1 then - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for _, unitID in ipairs(allUnits) do local unitDefinitionID = spGetUnitDefID(unitID) local unitTeam = spGetUnitTeam(unitID) diff --git a/luarules/gadgets/game_replace_afk_players.lua b/luarules/gadgets/game_replace_afk_players.lua index a94af81bb11..16c54cf5693 100644 --- a/luarules/gadgets/game_replace_afk_players.lua +++ b/luarules/gadgets/game_replace_afk_players.lua @@ -42,9 +42,9 @@ if gadgetHandler:IsSyncedCode() then local replaced = false local gameStarted = false - local gaiaTeamID = Spring.GetGaiaTeamID() - local SpGetPlayerList = Spring.GetPlayerList - local SpIsCheatingEnabled = Spring.IsCheatingEnabled + local gaiaTeamID = SpringShared.GetGaiaTeamID() + local SpGetPlayerList = SpringShared.GetPlayerList + local SpIsCheatingEnabled = SpringShared.IsCheatingEnabled function gadget:RecvLuaMsg(msg, playerID) local checkChange = (msg == "\144" or msg == "\145") @@ -54,7 +54,7 @@ if gadgetHandler:IsSyncedCode() then end if msg == "\144" then -- do the same eligibility check as in unsynced - local customtable = select(11, Spring.GetPlayerInfo(playerID)) + local customtable = select(11, SpringShared.GetPlayerInfo(playerID)) if type(customtable) == "table" then local tsMu = customtable.skill local tsSigma = customtable.skilluncertainty @@ -79,12 +79,12 @@ if gadgetHandler:IsSyncedCode() then function gadget:Initialize() -- record a list of which playersIDs are players on which teamID - local teamList = Spring.GetTeamList() + local teamList = SpringShared.GetTeamList() for _, teamID in pairs(teamList) do if teamID ~= gaiaTeamID then - local playerList = Spring.GetPlayerList(teamID) + local playerList = SpringShared.GetPlayerList(teamID) for _, playerID in pairs(playerList) do - if not select(3, Spring.GetPlayerInfo(playerID, false)) then + if not select(3, SpringShared.GetPlayerInfo(playerID, false)) then players[playerID] = teamID end end @@ -104,12 +104,12 @@ if gadgetHandler:IsSyncedCode() then -- make a list of absent players (only ones with valid ts) for playerID, _ in pairs(players) do - local _, active, spec = Spring.GetPlayerInfo(playerID, false) - local readyState = Spring.GetGameRulesParam("player_" .. playerID .. "_readyState") + local _, active, spec = SpringShared.GetPlayerInfo(playerID, false) + local readyState = SpringShared.GetGameRulesParam("player_" .. playerID .. "_readyState") local noStartPoint = (readyState == 3) or (readyState == 0) local present = active and not spec and not noStartPoint if not present then - local customtable = select(11, Spring.GetPlayerInfo(playerID)) or {} + local customtable = select(11, SpringShared.GetPlayerInfo(playerID)) or {} local tsMu = customtable.skill local ts = tsMu and tonumber(tsMu:match("%d+%.?%d*")) if ts then @@ -118,7 +118,7 @@ if gadgetHandler:IsSyncedCode() then end -- if present, tell LuaUI that won't be substituted if not absent[playerID] then - Spring.SetGameRulesParam("Player" .. playerID .. "willSub", 0) + SpringSynced.SetGameRulesParam("Player" .. playerID .. "willSub", 0) end end @@ -128,7 +128,7 @@ if gadgetHandler:IsSyncedCode() then local idealSubs = {} local validSubs = {} for subID, subts in pairs(substitutesLocal) do - local _, active, spec = Spring.GetPlayerInfo(subID, false) + local _, active, spec = SpringShared.GetPlayerInfo(subID, false) if active and spec then local tsDiff = mathAbs(ts - subts) if tsDiff <= validDiff then @@ -153,12 +153,12 @@ if gadgetHandler:IsSyncedCode() then if real then -- do the replacement local teamID = players[playerID] - Spring.AssignPlayerToTeam(sID, teamID) + SpringSynced.AssignPlayerToTeam(sID, teamID) players[sID] = teamID replaced = true - local incoming, _ = Spring.GetPlayerInfo(sID, false) - local outgoing, _ = Spring.GetPlayerInfo(playerID, false) + local incoming, _ = SpringShared.GetPlayerInfo(sID, false) + local outgoing, _ = SpringShared.GetPlayerInfo(playerID, false) SendToUnsynced("SubstitutionOccurred", incoming, outgoing) end substitutesLocal[sID] = nil @@ -166,7 +166,7 @@ if gadgetHandler:IsSyncedCode() then end -- tell luaui that if would substitute if the game started now - Spring.SetGameRulesParam("Player" .. playerID .. "willSub", wouldSub and 1 or 0) + SpringSynced.SetGameRulesParam("Player" .. playerID .. "willSub", wouldSub and 1 or 0) end end @@ -183,7 +183,7 @@ if gadgetHandler:IsSyncedCode() then local revealed = {} for pID, p in pairs(coopStartPoints) do --first do the coop starts - local name, _, _, tID = Spring.GetPlayerInfo(pID, false) + local name, _, _, tID = SpringShared.GetPlayerInfo(pID, false) SendToUnsynced("MarkStartPoint", p[1], p[2], p[3], name, tID) revealed[pID] = true end @@ -191,12 +191,12 @@ if gadgetHandler:IsSyncedCode() then local teamStartPoints = GG.teamStartPoints or {} for tID, p in pairs(teamStartPoints) do p = teamStartPoints[tID] - local playerList = Spring.GetPlayerList(tID) + local playerList = SpringShared.GetPlayerList(tID) local name = "" for _, pID in pairs(playerList) do --now do all pIDs for this team which were not coop starts if not revealed[pID] then - local pName, active, spec = Spring.GetPlayerInfo(pID, false) + local pName, active, spec = SpringShared.GetPlayerInfo(pID, false) if pName and absent[pID] == nil and active and not spec then --AIs might not have a name, don't write the name of the dropped player name = name .. pName .. ", " @@ -225,7 +225,7 @@ if gadgetHandler:IsSyncedCode() then for _, pID in ipairs(pList) do if not players[pID] then - local _, active, spec, _, aID = Spring.GetPlayerInfo(pID, false) + local _, active, spec, _, aID = SpringShared.GetPlayerInfo(pID, false) if active and not spec then --Spring.Echo("handle join", pID, active, spec) HandleJoinedPlayer(pID, aID) @@ -245,33 +245,33 @@ else ----------------------------- local myPlayerID = Spring.GetMyPlayerID() - local spec, _ = Spring.GetSpectatingState() - local isReplay = Spring.IsReplay() + local spec, _ = SpringUnsynced.GetSpectatingState() + local isReplay = SpringUnsynced.IsReplay() local ColorString = Spring.Utilities.Color.ToString local revealed = false local function colourNames(teamID) - local nameColourR, nameColourG, nameColourB, nameColourA = Spring.GetTeamColor(teamID) + local nameColourR, nameColourG, nameColourB, nameColourA = SpringUnsynced.GetTeamColor(teamID) return ColorString(nameColourR, nameColourG, nameColourB) end local function MarkStartPoint(_, x, y, z, name, teamID) - local _, _, spec = Spring.GetPlayerInfo(myPlayerID, false) + local _, _, spec = SpringShared.GetPlayerInfo(myPlayerID, false) if not spec then - Spring.MarkerAddPoint(x, y, z, colourNames(teamID) .. name, true) + SpringUnsynced.MarkerAddPoint(x, y, z, colourNames(teamID) .. name, true) revealed = true end end local function substitutionOccurred(_, incoming, outgoing) if Script.LuaUI("GadgetMessageProxy") then - Spring.Echo(Script.LuaUI.GadgetMessageProxy("ui.substitutePlayers.substitutedPlayers", { incoming = incoming, outgoing = outgoing })) + SpringShared.Echo(Script.LuaUI.GadgetMessageProxy("ui.substitutePlayers.substitutedPlayers", { incoming = incoming, outgoing = outgoing })) end end function gadget:Initialize() - if isReplay or Spring.Utilities.Gametype.IsFFA() or Spring.GetGameFrame() > 6 then + if isReplay or Spring.Utilities.Gametype.IsFFA() or SpringShared.GetGameFrame() > 6 then gadgetHandler:RemoveGadget() -- don't run in FFA mode return end @@ -286,7 +286,7 @@ else return end if revealed and Script.LuaUI("GadgetMessageProxy") then - Spring.Echo(Script.LuaUI.GadgetMessageProxy("ui.substitutePlayers.substituted")) + SpringShared.Echo(Script.LuaUI.GadgetMessageProxy("ui.substitutePlayers.substituted")) end gadgetHandler:RemoveGadget() end diff --git a/luarules/gadgets/game_restrict_resurrection.lua b/luarules/gadgets/game_restrict_resurrection.lua index f59931d5dd2..d5ea36e3fe7 100644 --- a/luarules/gadgets/game_restrict_resurrection.lua +++ b/luarules/gadgets/game_restrict_resurrection.lua @@ -16,15 +16,15 @@ if not gadgetHandler:IsSyncedCode() then return false end -if not Spring.GetModOptions().easytax then +if not SpringShared.GetModOptions().easytax then return false end function gadget:AllowFeatureBuildStep(builderID, builderTeam, featureID, featureDefID, part) if part < 0 then -- We are reclaiming some wreck - metal, defMetal, _, _, _, _ = Spring.GetFeatureResources(featureID) + metal, defMetal, _, _, _, _ = SpringShared.GetFeatureResources(featureID) if metal == defMetal then -- It's the first time we are touching this wreck/feature to reclaim it, i.e. we don't need to call SetFeatureResurrect every frame once we already set the wreck as non-resurrectable. Is this check actually faster than just always calling it? - Spring.SetFeatureResurrect(featureID, false) -- Set the wreck as non-resurrectable + SpringSynced.SetFeatureResurrect(featureID, false) -- Set the wreck as non-resurrectable end end return true diff --git a/luarules/gadgets/game_restrict_unit_sharing.lua b/luarules/gadgets/game_restrict_unit_sharing.lua index 448e2d78521..4437c5a0d83 100644 --- a/luarules/gadgets/game_restrict_unit_sharing.lua +++ b/luarules/gadgets/game_restrict_unit_sharing.lua @@ -16,7 +16,7 @@ if not gadgetHandler:IsSyncedCode() then return false end -if not Spring.GetModOptions().easytax then +if not SpringShared.GetModOptions().easytax then return false end @@ -33,22 +33,22 @@ for unitDefID, unitDef in pairs(UnitDefs) do end function gadget:AllowUnitTransfer(unitID, unitDefID, fromTeamID, toTeamID, capture) - if capture and (not Spring.AreTeamsAllied(fromTeamID, toTeamID)) then + if capture and (not SpringShared.AreTeamsAllied(fromTeamID, toTeamID)) then return true end - beingBuilt, buildProgress = Spring.GetUnitIsBeingBuilt(unitID) - if beingBuilt and buildProgress > 0 and next(Spring.GetPlayerList(fromTeamID)) ~= nil then + beingBuilt, buildProgress = SpringShared.GetUnitIsBeingBuilt(unitID) + if beingBuilt and buildProgress > 0 and next(SpringShared.GetPlayerList(fromTeamID)) ~= nil then return false -- Sharing partly built nanoframes is not allowed because letting it decay bypasses taxation. Also you can't assist ally build so unit could get stuck in factory. end if commanders[unitDefID] then - if next(Spring.GetPlayerList(fromTeamID, true)) == nil then -- There are no active players in the fromTeam, therefore this is /take. + if next(SpringShared.GetPlayerList(fromTeamID, true)) == nil then -- There are no active players in the fromTeam, therefore this is /take. return true end return false end if ecoUnits[unitDefID] then - local _, maxHealth, _ = Spring.GetUnitHealth(unitID) - Spring.AddUnitDamage(unitID, maxHealth * 5, 30) -- Stun for 30 seconds. + local _, maxHealth, _ = SpringShared.GetUnitHealth(unitID) + SpringSynced.AddUnitDamage(unitID, maxHealth * 5, 30) -- Stun for 30 seconds. end return true end diff --git a/luarules/gadgets/game_selfd_resign.lua b/luarules/gadgets/game_selfd_resign.lua index e366e0ee527..ac618e68d79 100644 --- a/luarules/gadgets/game_selfd_resign.lua +++ b/luarules/gadgets/game_selfd_resign.lua @@ -23,9 +23,9 @@ if gadgetHandler:IsSyncedCode() then local CMD_SELFD = CMD.SELFD local selfdCheckTeamUnits = {} - local spGetUnitSelfDTime = Spring.GetUnitSelfDTime - local spGetTeamUnits = Spring.GetTeamUnits - local gaiaTeamID = Spring.GetGaiaTeamID() + local spGetUnitSelfDTime = SpringShared.GetUnitSelfDTime + local spGetTeamUnits = SpringShared.GetTeamUnits + local gaiaTeamID = SpringShared.GetGaiaTeamID() local function forceResignTeam(teamID) @@ -34,16 +34,16 @@ if gadgetHandler:IsSyncedCode() then for i = 1, #units do local unitID = units[i] if spGetUnitSelfDTime(unitID) > 0 then - Spring.GiveOrderToUnit(unitID, CMD_SELFD, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD_SELFD, {}, 0) end end - Spring.KillTeam(teamID) + SpringSynced.KillTeam(teamID) -- notify players in this team - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() for _, playerID in pairs(players) do - if teamID == select(4, Spring.GetPlayerInfo(playerID, false)) then + if teamID == select(4, SpringShared.GetPlayerInfo(playerID, false)) then SendToUnsynced("forceResignMessage", playerID) end end @@ -86,7 +86,7 @@ if gadgetHandler:IsSyncedCode() then if skippedUnitCount >= skipResignAmount then break elseif selfdUnitCount >= triggerResignAmount then - local LuaAI = Spring.GetTeamLuaAI(teamID) + local LuaAI = SpringShared.GetTeamLuaAI(teamID) if not LuaAI or not (string.find(LuaAI, "Scavengers") or string.find(LuaAI, "Raptors")) then forceResignTeam(teamID) end @@ -113,19 +113,19 @@ else -- UNSYNCED local function forceResignMessage(_, playerID) if playerID == myPlayerID then - if not Spring.GetSpectatingState() then + if not SpringUnsynced.GetSpectatingState() then -- check first if player has team players local numActiveTeamPlayers = 0 - local allyID = select(6, Spring.GetTeamInfo(myTeamID, false)) - local teamList = Spring.GetTeamList(allyID) + local allyID = select(6, SpringShared.GetTeamInfo(myTeamID, false)) + local teamList = SpringShared.GetTeamList(allyID) for _, tID in ipairs(teamList) do - local luaAI = Spring.GetTeamLuaAI(tID) - if tID ~= myTeamID and not select(4, Spring.GetTeamInfo(tID, false)) and (not luaAI or luaAI == "") and Spring.GetTeamRulesParam(tID, "numActivePlayers") > 0 then + local luaAI = SpringShared.GetTeamLuaAI(tID) + if tID ~= myTeamID and not select(4, SpringShared.GetTeamInfo(tID, false)) and (not luaAI or luaAI == "") and SpringShared.GetTeamRulesParam(tID, "numActivePlayers") > 0 then numActiveTeamPlayers = numActiveTeamPlayers + 1 end end if numActiveTeamPlayers > 0 and Script.LuaUI("GadgetMessageProxy") then - Spring.Echo("\255\255\166\166" .. Script.LuaUI.GadgetMessageProxy("ui.forceResignMessage")) + SpringShared.Echo("\255\255\166\166" .. Script.LuaUI.GadgetMessageProxy("ui.forceResignMessage")) end end end diff --git a/luarules/gadgets/game_tax_resource_sharing.lua b/luarules/gadgets/game_tax_resource_sharing.lua index 0ffea4cc0d2..db829a4ceed 100644 --- a/luarules/gadgets/game_tax_resource_sharing.lua +++ b/luarules/gadgets/game_tax_resource_sharing.lua @@ -18,33 +18,33 @@ end if not gadgetHandler:IsSyncedCode() then return false end -if Spring.GetModOptions().tax_resource_sharing_amount == 0 and not Spring.GetModOptions().easytax then +if SpringShared.GetModOptions().tax_resource_sharing_amount == 0 and not SpringShared.GetModOptions().easytax then return false end -local spIsCheatingEnabled = Spring.IsCheatingEnabled -local spGetTeamUnitCount = Spring.GetTeamUnitCount -local spGetTeamList = Spring.GetTeamList -local spGetTeamResources = Spring.GetTeamResources -local spGetTeamInfo = Spring.GetTeamInfo -local spAreTeamsAllied = Spring.AreTeamsAllied -local spUseTeamResource = Spring.UseTeamResource -local spShareTeamResource = Spring.ShareTeamResource -local spAddTeamResource = Spring.AddTeamResource -local spSetTeamResource = Spring.SetTeamResource +local spIsCheatingEnabled = SpringShared.IsCheatingEnabled +local spGetTeamUnitCount = SpringShared.GetTeamUnitCount +local spGetTeamList = SpringShared.GetTeamList +local spGetTeamResources = SpringShared.GetTeamResources +local spGetTeamInfo = SpringShared.GetTeamInfo +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spUseTeamResource = SpringSynced.UseTeamResource +local spShareTeamResource = SpringSynced.ShareTeamResource +local spAddTeamResource = SpringSynced.AddTeamResource +local spSetTeamResource = SpringSynced.SetTeamResource local math_max = math.max local math_min = math.min -local gameMaxUnits = math.min(Spring.GetModOptions().maxunits, math.floor(32000 / #Spring.GetTeamList())) +local gameMaxUnits = math.min(SpringShared.GetModOptions().maxunits, math.floor(32000 / #SpringShared.GetTeamList())) -local sharingTax = Spring.GetModOptions().tax_resource_sharing_amount -if Spring.GetModOptions().easytax then +local sharingTax = SpringShared.GetModOptions().tax_resource_sharing_amount +if SpringShared.GetModOptions().easytax then sharingTax = 0.3 -- 30% tax for easytax modoption end local function isAlliedUnit(teamID, unitID) - local unitTeam = Spring.GetUnitTeam(unitID) - return teamID and unitTeam and teamID ~= unitTeam and Spring.AreTeamsAllied(teamID, unitTeam) + local unitTeam = SpringShared.GetUnitTeam(unitID) + return teamID and unitTeam and teamID ~= unitTeam and SpringShared.AreTeamsAllied(teamID, unitTeam) end ---------------------------------------------------------------- diff --git a/luarules/gadgets/game_team_com_ends.lua b/luarules/gadgets/game_team_com_ends.lua index 5481feb8914..161dc6350bd 100644 --- a/luarules/gadgets/game_team_com_ends.lua +++ b/luarules/gadgets/game_team_com_ends.lua @@ -16,18 +16,18 @@ if not gadgetHandler:IsSyncedCode() then return end -local GetTeamList = Spring.GetTeamList -local GetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetTeamInfo = Spring.GetTeamInfo -local spGetTeamList = Spring.GetTeamList -local spKillTeam = Spring.KillTeam -local spGetUnitPosition = Spring.GetUnitPosition -local spGetTeamLuaAI = Spring.GetTeamLuaAI -local spGetAllyTeamList = Spring.GetAllyTeamList -local spGetAllUnits = Spring.GetAllUnits -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitTeam = Spring.GetUnitTeam -local gaiaTeamID = Spring.GetGaiaTeamID() +local GetTeamList = SpringShared.GetTeamList +local GetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetTeamList = SpringShared.GetTeamList +local spKillTeam = SpringSynced.KillTeam +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetTeamLuaAI = SpringShared.GetTeamLuaAI +local spGetAllyTeamList = SpringShared.GetAllyTeamList +local spGetAllUnits = SpringShared.GetAllUnits +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitTeam = SpringShared.GetUnitTeam +local gaiaTeamID = SpringShared.GetGaiaTeamID() -- Exclude Gaia / Scavengers / Raptors local ignoredTeams = { @@ -60,7 +60,7 @@ local commanderDeathQueue = {} local isCommander = {} for unitDefID, unitDef in pairs(UnitDefs) do - if unitDef.customParams.iscommander or unitDef.customParams.isscavcommander or (Spring.GetModOptions().deathmode == "builders" and ((unitDef.buildOptions and #unitDef.buildOptions > 0) or unitDef.canResurrect == true)) then + if unitDef.customParams.iscommander or unitDef.customParams.isscavcommander or (SpringShared.GetModOptions().deathmode == "builders" and ((unitDef.buildOptions and #unitDef.buildOptions > 0) or unitDef.canResurrect == true)) then isCommander[unitDefID] = true end end @@ -79,7 +79,7 @@ local function commanderDeath(teamID, originX, originZ) -- optional: attackerUni end end - if Spring.GetModOptions().deathmode == "own_com" and aliveTeamComCount[teamID] <= 0 then + if SpringShared.GetModOptions().deathmode == "own_com" and aliveTeamComCount[teamID] <= 0 then if not select(3, spGetTeamInfo(teamID, false)) then spKillTeam(teamID) end @@ -137,7 +137,7 @@ end function gadget:Initialize() -- disable gadget when deathmode is "killall" or "none", or scoremode isnt regular - local deathmode = Spring.GetModOptions().deathmode + local deathmode = SpringShared.GetModOptions().deathmode if deathmode ~= "com" and deathmode ~= "own_com" and deathmode ~= "territorial_domination" and deathmode ~= "builders" then gadgetHandler:RemoveGadget(self) end @@ -159,7 +159,7 @@ function gadget:Initialize() end -- for debug purpose: destroy comless allyteams (usefull when team has no coms because of error and you do luarules reload) - if Spring.GetGameFrame() > 1 then + if SpringShared.GetGameFrame() > 1 then for allyTeamID, count in ipairs(aliveComCount) do if count <= 0 then local allyTeams = GetTeamList(allyTeamID) diff --git a/luarules/gadgets/game_team_death_effect.lua b/luarules/gadgets/game_team_death_effect.lua index 9d519e5d5b4..a6bbca64a4d 100644 --- a/luarules/gadgets/game_team_death_effect.lua +++ b/luarules/gadgets/game_team_death_effect.lua @@ -32,9 +32,9 @@ for udefID, def in ipairs(UnitDefs) do end end -local spDestroyUnit = Spring.DestroyUnit -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitDefID = Spring.GetUnitDefID +local spDestroyUnit = SpringSynced.DestroyUnit +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitDefID = SpringShared.GetUnitDefID local DISTANCE_LIMIT = math.max(Game.mapSizeX, Game.mapSizeZ) * math.max(Game.mapSizeX, Game.mapSizeZ) local destroyUnitQueue = {} local wipedoutTeams = {} @@ -45,11 +45,11 @@ local function getSqrDistance(x1, z1, x2, z2) end local function wipeoutTeam(teamID, originX, originZ, attackerUnitID, periodMult) -- only teamID is required - wipedoutTeams[teamID] = Spring.GetGameFrame() + wipedoutTeams[teamID] = SpringShared.GetGameFrame() periodMult = periodMult or 1 - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() local maxDeathFrame = 0 - local teamUnits = Spring.GetTeamUnits(teamID) + local teamUnits = SpringShared.GetTeamUnits(teamID) for i = 1, #teamUnits do local unitID = teamUnits[i] if not unitDecoration[spGetUnitDefID(unitID)] then @@ -69,22 +69,22 @@ local function wipeoutTeam(teamID, originX, originZ, attackerUnitID, periodMult) end -- neutralize units - Spring.SetUnitNeutral(unitID, true) - Spring.SetUnitSensorRadius(unitID, "los", 0) - Spring.SetUnitSensorRadius(unitID, "airLos", 0) - Spring.SetUnitSensorRadius(unitID, "radar", 0) - Spring.SetUnitSensorRadius(unitID, "sonar", 0) + SpringSynced.SetUnitNeutral(unitID, true) + SpringSynced.SetUnitSensorRadius(unitID, "los", 0) + SpringSynced.SetUnitSensorRadius(unitID, "airLos", 0) + SpringSynced.SetUnitSensorRadius(unitID, "radar", 0) + SpringSynced.SetUnitSensorRadius(unitID, "sonar", 0) local i = 0 for weaponID, _ in pairs(UnitDefs[spGetUnitDefID(unitID)].weapons) do - Spring.UnitWeaponHoldFire(unitID, weaponID) + SpringSynced.UnitWeaponHoldFire(unitID, weaponID) i = i + 1 end if i > 0 then - Spring.SetUnitMaxRange(unitID, 0) -- looks like this one doesnt really work - Spring.GiveOrderToUnit(unitID, CMD.FIRE_STATE, { 0 }, 0) - Spring.SetUnitTarget(unitID, nil) + SpringSynced.SetUnitMaxRange(unitID, 0) -- looks like this one doesnt really work + SpringSynced.GiveOrderToUnit(unitID, CMD.FIRE_STATE, { 0 }, 0) + SpringSynced.SetUnitTarget(unitID, nil) if GameCMD and GameCMD.UNIT_CANCEL_TARGET then -- remove any settarget cmd - Spring.GiveOrderToUnit(unitID, GameCMD.UNIT_CANCEL_TARGET, {}, {}) + SpringSynced.GiveOrderToUnit(unitID, GameCMD.UNIT_CANCEL_TARGET, {}, {}) end end --Spring.SetUnitNoMinimap(unitID, true) @@ -103,14 +103,14 @@ local function wipeoutAllyTeam(allyTeamID, attackerUnitID, originX, originZ, per -- define smaller destruction period when few units local totalUnits = 0 - for _, teamID in ipairs(Spring.GetTeamList(allyTeamID)) do - local units = Spring.GetTeamUnits(teamID) + for _, teamID in ipairs(SpringShared.GetTeamList(allyTeamID)) do + local units = SpringShared.GetTeamUnits(teamID) totalUnits = totalUnits + #units end periodMult = (periodMult or 1) * math.clamp(totalUnits / 300, 0.33, 1) -- make low unitcount blow up faster -- destroy all teams - for _, teamID in ipairs(Spring.GetTeamList(allyTeamID)) do + for _, teamID in ipairs(SpringShared.GetTeamList(allyTeamID)) do wipeoutTeam(teamID, originX, originZ, attackerUnitID, periodMult) end end @@ -140,7 +140,7 @@ end -- i've seen a resurrected unit being left-over so lets remove units being created after a team wipeout was initiated function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) - if wipedoutTeams[unitTeam] and wipedoutTeams[unitTeam] + 300 > Spring.GetGameFrame() then - Spring.DestroyUnit(unitID, not GG.wipeoutWithWreckage, false) + if wipedoutTeams[unitTeam] and wipedoutTeams[unitTeam] + 300 > SpringShared.GetGameFrame() then + SpringSynced.DestroyUnit(unitID, not GG.wipeoutWithWreckage, false) end end diff --git a/luarules/gadgets/game_team_power_watcher.lua b/luarules/gadgets/game_team_power_watcher.lua index 12c6961ffa4..e51a108c292 100644 --- a/luarules/gadgets/game_team_power_watcher.lua +++ b/luarules/gadgets/game_team_power_watcher.lua @@ -21,7 +21,7 @@ local alliesAreWinningRatio = 1.25 local mathHuge = math.huge local mathMax = math.max -local teamList = Spring.GetTeamList() +local teamList = SpringShared.GetTeamList() local scavengerTeam = Spring.Utilities.GetScavTeamID() local raptorTeam = Spring.Utilities.GetRaptorTeamID() local aiTeams = {} @@ -46,8 +46,8 @@ local powerThresholds = { local pveTeamID = scavengerTeam or raptorTeam for _, teamID in ipairs(teamList) do - local allyID = select(6, Spring.GetTeamInfo(teamID)) - if teamID ~= scavengerTeam and teamID ~= raptorTeam and select(4, Spring.GetTeamInfo(teamID, false)) then + local allyID = select(6, SpringShared.GetTeamInfo(teamID)) + if teamID ~= scavengerTeam and teamID ~= raptorTeam and select(4, SpringShared.GetTeamInfo(teamID, false)) then aiTeams[teamID] = true playerTeams[teamID] = true playerAllies[allyID] = playerAllies[allyID] or {} @@ -225,12 +225,12 @@ end -- Returns the highest team power of the allies belonging to input team or allyID. Returns as a table {teamID, power}. local function highestAlliedTeamPower(teamID, allyID) - allyID = allyID or select(6, Spring.GetTeamInfo(teamID)) + allyID = allyID or select(6, SpringShared.GetTeamInfo(teamID)) local highestPower = 0 local highestTeamID = nil for id, power in pairs(teamPowers) do - if allyID == select(6, Spring.GetTeamInfo(id)) and power > 0 then + if allyID == select(6, SpringShared.GetTeamInfo(id)) and power > 0 then if power > highestPower then highestPower = power highestTeamID = id @@ -243,12 +243,12 @@ end -- Returns the average of all allies of the input teamID or allyID. Returns a number. local function averageAlliedTeamPower(teamID, allyID) - allyID = allyID or select(6, Spring.GetTeamInfo(teamID)) + allyID = allyID or select(6, SpringShared.GetTeamInfo(teamID)) local totalPower = 0 local teamCount = 0 for id, power in pairs(teamPowers) do - if allyID == select(6, Spring.GetTeamInfo(id)) and power > 0 then + if allyID == select(6, SpringShared.GetTeamInfo(id)) and power > 0 then totalPower = totalPower + power teamCount = teamCount + 1 end @@ -260,12 +260,12 @@ end -- Returns the lowest of the teamID's allies or allyID's power as a table {teamID, power}. local function lowestAlliedTeamPower(teamID, allyID) - allyID = allyID or select(6, Spring.GetTeamInfo(teamID)) + allyID = allyID or select(6, SpringShared.GetTeamInfo(teamID)) local lowestPower = mathHuge local lowestTeamID = nil for id, power in pairs(teamPowers) do - if allyID == select(6, Spring.GetTeamInfo(id)) and power > 0 then + if allyID == select(6, SpringShared.GetTeamInfo(id)) and power > 0 then if power < lowestPower then lowestPower = power lowestTeamID = id @@ -359,12 +359,12 @@ end -- Compare average powers of all allied teams of the input teamID or allyID and return an estimated tech level number. local function averageAlliedTechGuesstimate(teamID, allyID) - allyID = allyID or select(6, Spring.GetTeamInfo(teamID)) + allyID = allyID or select(6, SpringShared.GetTeamInfo(teamID)) local totalPower = 0 local teamCount = 0 for id, power in pairs(teamPowers) do - if allyID == select(6, Spring.GetTeamInfo(id)) and power > 0 then + if allyID == select(6, SpringShared.GetTeamInfo(id)) and power > 0 then totalPower = totalPower + power teamCount = teamCount + 1 end @@ -426,12 +426,12 @@ end -- Returns the highest power achieved by any non scavenger/raptor team on the same team as the input teamID or allyID as a table {teamID, power}. local function highestAlliedPeakPower(teamID, allyID) - allyID = allyID or select(6, Spring.GetTeamInfo(teamID)) + allyID = allyID or select(6, SpringShared.GetTeamInfo(teamID)) local highestPower = 0 local highestTeamID = nil for id, power in pairs(peakTeamPowers) do - if allyID == select(6, Spring.GetTeamInfo(id)) then + if allyID == select(6, SpringShared.GetTeamInfo(id)) then if power > highestPower then highestPower = power highestTeamID = id @@ -460,12 +460,12 @@ end -- Returns the average of all the peak powers achieved by allied teams of the input teamID or allyID as a number. local function averageAlliedPeakPower(teamID, allyID) - allyID = allyID or select(6, Spring.GetTeamInfo(teamID)) + allyID = allyID or select(6, SpringShared.GetTeamInfo(teamID)) local totalPower = 0 local teamCount = 0 for id, power in pairs(peakTeamPowers) do - if allyID == select(6, Spring.GetTeamInfo(id)) then + if allyID == select(6, SpringShared.GetTeamInfo(id)) then totalPower = totalPower + power teamCount = teamCount + 1 end @@ -520,7 +520,7 @@ end -- Returns the ratio number of the input teamID's allies or allyID compared to the average of all player allies. local function alliesComparedToAverage(teamID, allyID) - allyID = allyID or select(6, Spring.GetTeamInfo(teamID)) + allyID = allyID or select(6, SpringShared.GetTeamInfo(teamID)) local allyPowers = {} local allyCount = 0 local totalPower = 0 @@ -548,7 +548,7 @@ end -- Returns boolean true if the input teamID's allies or allyID is considered significantly more powerful by the API. Third argument allows user-defined ratio. local function isAllyTeamWinning(teamID, allyID, marginRatio) - allyID = allyID or select(6, Spring.GetTeamInfo(teamID)) + allyID = allyID or select(6, SpringShared.GetTeamInfo(teamID)) marginRatio = marginRatio or alliesAreWinningRatio local allyPowers = {} local allyCount = 0 diff --git a/luarules/gadgets/game_team_resources.lua b/luarules/gadgets/game_team_resources.lua index dd3006579e5..63a7b912cf5 100644 --- a/luarules/gadgets/game_team_resources.lua +++ b/luarules/gadgets/game_team_resources.lua @@ -22,10 +22,10 @@ local mathMax = math.max local function GetTeamPlayerCounts() local teamPlayerCounts = {} - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for i = 1, #playerList do local playerID = playerList[i] - local _, _, isSpec, teamID = Spring.GetPlayerInfo(playerID, false) + local _, _, isSpec, teamID = SpringShared.GetPlayerInfo(playerID, false) if not isSpec then teamPlayerCounts[teamID] = (teamPlayerCounts[teamID] or 0) + 1 end @@ -34,11 +34,11 @@ local function GetTeamPlayerCounts() end local function setup(addResources) - local startMetalStorage = Spring.GetModOptions().startmetalstorage - local startEnergyStorage = Spring.GetModOptions().startenergystorage - local startMetal = Spring.GetModOptions().startmetal - local startEnergy = Spring.GetModOptions().startenergy - local bonusMultiplierEnabled = Spring.GetModOptions().bonusstartresourcemultiplier + local startMetalStorage = SpringShared.GetModOptions().startmetalstorage + local startEnergyStorage = SpringShared.GetModOptions().startenergystorage + local startMetal = SpringShared.GetModOptions().startmetal + local startEnergy = SpringShared.GetModOptions().startenergy + local bonusMultiplierEnabled = SpringShared.GetModOptions().bonusstartresourcemultiplier local commanderMinMetal, commanderMinEnergy = 0, 0 @@ -48,7 +48,7 @@ local function setup(addResources) teamPlayerCounts = GetTeamPlayerCounts() end - local teamList = Spring.GetTeamList() + local teamList = SpringShared.GetTeamList() for i = 1, #teamList do local teamID = teamList[i] @@ -61,7 +61,7 @@ local function setup(addResources) --If starting bonus multiplication is enabled, multiply it. local teamMultiplier = 1 if bonusMultiplierEnabled then - teamMultiplier = select(7, Spring.GetTeamInfo(teamID)) + teamMultiplier = select(7, SpringShared.GetTeamInfo(teamID)) end -- Get starting resources and storage including any bonuses from mods @@ -71,23 +71,23 @@ local function setup(addResources) local startingEnergyStorage = startEnergyStorage * teamMultiplier * multiplier -- Get the player's start unit to make sure starting storage is no less than its storage - local com = UnitDefs[Spring.GetTeamRulesParam(teamID, "startUnit")] + local com = UnitDefs[SpringShared.GetTeamRulesParam(teamID, "startUnit")] if com then commanderMinMetal = com.metalStorage or 0 commanderMinEnergy = com.energyStorage or 0 end - Spring.SetTeamResource(teamID, "ms", mathMax(minStorageMetal, startingMetalStorage, startingMetal, commanderMinMetal)) - Spring.SetTeamResource(teamID, "es", mathMax(minStorageEnergy, startingEnergyStorage, startingEnergy, commanderMinEnergy)) + SpringSynced.SetTeamResource(teamID, "ms", mathMax(minStorageMetal, startingMetalStorage, startingMetal, commanderMinMetal)) + SpringSynced.SetTeamResource(teamID, "es", mathMax(minStorageEnergy, startingEnergyStorage, startingEnergy, commanderMinEnergy)) if addResources then - Spring.SetTeamResource(teamID, "m", startingMetal) - Spring.SetTeamResource(teamID, "e", startingEnergy) + SpringSynced.SetTeamResource(teamID, "m", startingMetal) + SpringSynced.SetTeamResource(teamID, "e", startingEnergy) end end end function gadget:Initialize() - if Spring.GetGameFrame() > 0 then + if SpringShared.GetGameFrame() > 0 then return end setup(true) @@ -99,6 +99,6 @@ function gadget:GameStart() end function gadget:TeamDied(teamID) - Spring.SetTeamShareLevel(teamID, "metal", 0) - Spring.SetTeamShareLevel(teamID, "energy", 0) + SpringSynced.SetTeamShareLevel(teamID, "metal", 0) + SpringSynced.SetTeamShareLevel(teamID, "energy", 0) end diff --git a/luarules/gadgets/game_tech_blocking.lua b/luarules/gadgets/game_tech_blocking.lua index e11a195886c..22ebc83a1da 100644 --- a/luarules/gadgets/game_tech_blocking.lua +++ b/luarules/gadgets/game_tech_blocking.lua @@ -16,7 +16,7 @@ if not gadgetHandler:IsSyncedCode() then return end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() local techMode = modOptions.tech_blocking local t2TechThreshold = modOptions.t2_tech_threshold or 100 local t3TechThreshold = modOptions.t3_tech_threshold or 1000 @@ -27,9 +27,9 @@ if not techMode then return end -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetTeamRulesParam = Spring.GetTeamRulesParam -local spSetTeamRulesParam = Spring.SetTeamRulesParam +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetTeamRulesParam = SpringShared.GetTeamRulesParam +local spSetTeamRulesParam = SpringSynced.SetTeamRulesParam local UPDATE_INTERVAL = Game.gameSpeed @@ -37,7 +37,7 @@ local blockTechDefs = {} local techPointsGeneratorDefs = {} local techCoreValueDefs = {} local ignoredTeams = { - [Spring.GetGaiaTeamID()] = true, + [SpringShared.GetGaiaTeamID()] = true, } local scavTeamID = Spring.Utilities.GetScavTeamID() if scavTeamID then @@ -64,13 +64,13 @@ for unitDefID, unitDef in pairs(UnitDefs) do blockTechDefs[unitDefID] = techLevel end if customParams.tech_points_gain and tonumber(customParams.tech_points_gain) > 0 then - Spring.Echo("Tech points gain found for ", unitDef.name, ": ", tostring(customParams.tech_points_gain)) + SpringShared.Echo("Tech points gain found for ", unitDef.name, ": ", tostring(customParams.tech_points_gain)) removeGadget = false local techXP = tonumber(customParams.tech_points_gain) techPointsGeneratorDefs[unitDefID] = techXP end if customParams.tech_core_value and tonumber(customParams.tech_core_value) > 0 then - Spring.Echo("Tech core value found for ", unitDef.name, ": ", tostring(customParams.tech_core_value)) + SpringShared.Echo("Tech core value found for ", unitDef.name, ": ", tostring(customParams.tech_core_value)) removeGadget = false local coreValue = tonumber(customParams.tech_core_value) techCoreValueDefs[unitDefID] = coreValue @@ -81,16 +81,16 @@ if removeGadget then gadgetHandler:RemoveGadget(gadget) end -local allyTeamList = Spring.GetAllyTeamList() +local allyTeamList = SpringShared.GetAllyTeamList() for _, allyTeamID in ipairs(allyTeamList) do - local teamList = Spring.GetTeamList(allyTeamID) + local teamList = SpringShared.GetTeamList(allyTeamID) allyWatch[allyTeamID] = teamList end local function increaseTechLevel(teamList, notificationEvent, techLevel) for _, teamID in ipairs(teamList) do if not ignoredTeams[teamID] then - local players = Spring.GetPlayerList(teamID) + local players = SpringShared.GetPlayerList(teamID) if players then for _, playerID in ipairs(players) do SendToUnsynced("NotificationEvent", notificationEvent, tostring(playerID)) @@ -111,7 +111,7 @@ end function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD.BUILD) - local teamList = Spring.GetTeamList() + local teamList = SpringShared.GetTeamList() for _, teamID in ipairs(teamList) do if not ignoredTeams[teamID] then spSetTeamRulesParam(teamID, "tech_points", 0) @@ -119,17 +119,17 @@ function gadget:Initialize() end end - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for _, unitID in ipairs(allUnits) do - local unitDefID = Spring.GetUnitDefID(unitID) - local unitTeam = Spring.GetUnitTeam(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) + local unitTeam = SpringShared.GetUnitTeam(unitID) if unitDefID and unitTeam then gadget:UnitFinished(unitID, unitDefID, unitTeam) end end end function gadget:GameStart() - local teamList = Spring.GetTeamList() + local teamList = SpringShared.GetTeamList() for _, teamID in ipairs(teamList) do if not ignoredTeams[teamID] then local techLevel = spGetTeamRulesParam(teamID, "tech_level") or 1 diff --git a/luarules/gadgets/game_territorial_domination.lua b/luarules/gadgets/game_territorial_domination.lua index 8403ed65b95..78b5743eac4 100644 --- a/luarules/gadgets/game_territorial_domination.lua +++ b/luarules/gadgets/game_territorial_domination.lua @@ -11,7 +11,7 @@ function gadget:GetInfo() } end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() local isSynced = gadgetHandler:IsSyncedCode() if modOptions.deathmode ~= "territorial_domination" or not isSynced then return false @@ -70,22 +70,22 @@ local max = math.max local min = math.min local random = math.random -local spGetGameFrame = Spring.GetGameFrame -local spGetGameSeconds = Spring.GetGameSeconds -local spGetUnitsInRectangle = Spring.GetUnitsInRectangle -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetUnitIsCloaked = Spring.GetUnitIsCloaked -local spGetPositionLosState = Spring.GetPositionLosState -local spGetTeamInfo = Spring.GetTeamInfo -local spGetTeamList = Spring.GetTeamList -local spGetGaiaTeamID = Spring.GetGaiaTeamID -local spDestroyUnit = Spring.DestroyUnit -local spSpawnCEG = Spring.SpawnCEG -local spPlaySoundFile = Spring.PlaySoundFile -local spGetUnitIsDead = Spring.GetUnitIsDead +local spGetGameFrame = SpringShared.GetGameFrame +local spGetGameSeconds = SpringShared.GetGameSeconds +local spGetUnitsInRectangle = SpringShared.GetUnitsInRectangle +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetUnitIsCloaked = SpringShared.GetUnitIsCloaked +local spGetPositionLosState = SpringShared.GetPositionLosState +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetTeamList = SpringShared.GetTeamList +local spGetGaiaTeamID = SpringShared.GetGaiaTeamID +local spDestroyUnit = SpringSynced.DestroyUnit +local spSpawnCEG = SpringSynced.SpawnCEG +local spPlaySoundFile = SpringUnsynced.PlaySoundFile +local spGetUnitIsDead = SpringShared.GetUnitIsDead local SendToUnsynced = SendToUnsynced local mapSizeX = Game.mapSizeX @@ -312,7 +312,7 @@ local function setAllyTeamRanks() topLivingRankedScoreIndex = i end end - Spring.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_rank", currentRank) + SpringSynced.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_rank", currentRank) end else topLivingRankedScoreIndex = currentRank @@ -323,7 +323,7 @@ local function processLivingTeams() allyTeamsCount = 0 allyTeamsWatch = {} - allTeams = Spring.GetTeamList() + allTeams = SpringShared.GetTeamList() for _, teamID in ipairs(allTeams) do local _, _, isDead, _, _, allyID = spGetTeamInfo(teamID) if not isDead and not doomedAllies[allyID] then @@ -396,23 +396,23 @@ local function defeatAlly(allyID) killQueue[killFrame] = killQueue[killFrame] or {} killQueue[killFrame][unitID] = true - Spring.SetUnitRulesParam(unitID, "muteDestructionNotification", 1) + SpringSynced.SetUnitRulesParam(unitID, "muteDestructionNotification", 1) local x, y, z = spGetUnitPosition(unitID) spSpawnCEG("commander-spawn", x, y, z, 0, 0, 0) spPlaySoundFile("commanderspawn-mono", 1.0, x, y, z, 0, 0, 0, "sfx") GG.ComSpawnDefoliate(x, y, z) - local allPlayers = Spring.GetPlayerList() + local allPlayers = SpringShared.GetPlayerList() for _, playerID in ipairs(allPlayers) do - local _, _, _, _, playerAllyID = Spring.GetPlayerInfo(playerID, false) + local _, _, _, _, playerAllyID = SpringShared.GetPlayerInfo(playerID, false) local notificationEvent = (playerAllyID == allyID) and "TerritorialDomination/YourTeamEliminated" or "TerritorialDomination/EnemyTeamEliminated" SendToUnsynced("NotificationEvent", notificationEvent, tostring(playerID)) end end end - Spring.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_projectedPoints", 0) + SpringSynced.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_projectedPoints", 0) end local function addProgress(gridID, progressChange, winningAllyID, delayDecay) @@ -577,11 +577,11 @@ local function updateProjectedPoints() projectedAllyTeamPoints[allyID] = projectedScore if not gameOver and (currentRound <= MAX_ROUNDS) then - Spring.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_projectedPoints", projectedScore) + SpringSynced.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_projectedPoints", projectedScore) else - Spring.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_projectedPoints", 0) + SpringSynced.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_projectedPoints", 0) end - Spring.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_territoryCount", territoryCount) + SpringSynced.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_territoryCount", territoryCount) end end @@ -640,19 +640,19 @@ function gadget:GameFrame(frame) if currentRound <= MAX_ROUNDS then eliminationThreshold = math.floor(newHighestScore * ELIMINATION_THRESHOLD_MULTIPLIER) - Spring.SetGameRulesParam("territorialDominationEliminationThreshold", eliminationThreshold) + SpringSynced.SetGameRulesParam("territorialDominationEliminationThreshold", eliminationThreshold) roundTimestamp = seconds + ROUND_SECONDS end end updateProjectedPoints() setAllyTeamRanks() - Spring.SetGameRulesParam("territorialDominationRoundEndTimestamp", currentRound > MAX_ROUNDS and 0 or roundTimestamp) - Spring.SetGameRulesParam("territorialDominationCurrentRound", currentRound) - Spring.SetGameRulesParam("territorialDominationMaxRounds", MAX_ROUNDS) + SpringSynced.SetGameRulesParam("territorialDominationRoundEndTimestamp", currentRound > MAX_ROUNDS and 0 or roundTimestamp) + SpringSynced.SetGameRulesParam("territorialDominationCurrentRound", currentRound) + SpringSynced.SetGameRulesParam("territorialDominationMaxRounds", MAX_ROUNDS) for allyID, scoreData in pairs(allyData) do - Spring.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_score", scoreData.score) + SpringSynced.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_score", scoreData.score) end end @@ -681,28 +681,28 @@ function gadget:Initialize() end end - local units = Spring.GetAllUnits() + local units = SpringShared.GetAllUnits() for i = 1, #units do local unitID = units[i] - gadget:UnitCreated(unitID, spGetUnitDefID(unitID), Spring.GetUnitTeam(unitID)) + gadget:UnitCreated(unitID, spGetUnitDefID(unitID), SpringShared.GetUnitTeam(unitID)) end - allTeams = Spring.GetTeamList() + allTeams = SpringShared.GetTeamList() updateProjectedPoints() - Spring.SetGameRulesParam("territorialDominationCurrentRound", currentRound) - Spring.SetGameRulesParam("territorialDominationMaxRounds", MAX_ROUNDS) + SpringSynced.SetGameRulesParam("territorialDominationCurrentRound", currentRound) + SpringSynced.SetGameRulesParam("territorialDominationMaxRounds", MAX_ROUNDS) for allyID in pairs(allyTeamsWatch) do - Spring.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_score", 0) - Spring.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_rank", 1) + SpringSynced.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_score", 0) + SpringSynced.SetGameRulesParam("territorialDomination_ally_" .. allyID .. "_rank", 1) end end function gadget:UnitCreated(unitID, unitDefID, unitTeam) if commandersDefs[unitDefID] then - livingCommanders[unitID] = select(6, Spring.GetTeamInfo(unitTeam)) + livingCommanders[unitID] = select(6, SpringShared.GetTeamInfo(unitTeam)) end end diff --git a/luarules/gadgets/game_volcano_pyroclastic.lua b/luarules/gadgets/game_volcano_pyroclastic.lua index 2676ec13f10..f78270f67ad 100644 --- a/luarules/gadgets/game_volcano_pyroclastic.lua +++ b/luarules/gadgets/game_volcano_pyroclastic.lua @@ -21,16 +21,16 @@ if gadgetHandler:IsSyncedCode() then -------------------------------------------------------------------------------- -- Shortcuts -------------------------------------------------------------------------------- - local spCreateUnit = Spring.CreateUnit - local spDestroyUnit = Spring.DestroyUnit - local spGiveOrderToUnit = Spring.GiveOrderToUnit - local spSpawnCEG = Spring.SpawnCEG - local spGetGroundHeight = Spring.GetGroundHeight - local spSetUnitCloak = Spring.SetUnitCloak - local spMoveCtrlEnable = Spring.MoveCtrl.Enable - local spMoveCtrlSetPosition = Spring.MoveCtrl.SetPosition - - local GameFrame = Spring.GetGameFrame + local spCreateUnit = SpringSynced.CreateUnit + local spDestroyUnit = SpringSynced.DestroyUnit + local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit + local spSpawnCEG = SpringSynced.SpawnCEG + local spGetGroundHeight = SpringShared.GetGroundHeight + local spSetUnitCloak = SpringSynced.SetUnitCloak + local spMoveCtrlEnable = SpringSynced.MoveCtrl.Enable + local spMoveCtrlSetPosition = SpringSynced.MoveCtrl.SetPosition + + local GameFrame = SpringShared.GetGameFrame local SendToUnsynced = SendToUnsynced local CMD_ATTACK = CMD.ATTACK @@ -72,7 +72,7 @@ if gadgetHandler:IsSyncedCode() then end local function IsVolcanoEnabled() - local modOpts = (Spring.GetModOptions and Spring.GetModOptions()) or {} + local modOpts = (SpringShared.GetModOptions and SpringShared.GetModOptions()) or {} local v = modOpts.forge_volcano return v == nil or v == true or v == 1 or v == "1" or v == "true" end @@ -128,18 +128,18 @@ if gadgetHandler:IsSyncedCode() then local accountID = Spring.Utilities.GetAccountID(playerID) local authorized = _G.permissions.volcano[accountID] - if not (authorized or Spring.IsCheatingEnabled()) then - Spring.Echo("[Volcano] Unauthorized command.") + if not (authorized or SpringShared.IsCheatingEnabled()) then + SpringShared.Echo("[Volcano] Unauthorized command.") return end volcanoActive = not volcanoActive if volcanoActive then nextErupt = GameFrame() + R(COOLDOWN_MIN, COOLDOWN_MAX) - Spring.Echo("[Volcano] Volcano system resumed.") + SpringShared.Echo("[Volcano] Volcano system resumed.") else ResetVolcanoState() - Spring.Echo("[Volcano] Volcano system paused.") + SpringShared.Echo("[Volcano] Volcano system paused.") end end) end @@ -213,7 +213,7 @@ if gadgetHandler:IsSyncedCode() then ejectScheduled = false end - local uid = spCreateUnit("volcano_projectile_unit", VX, LAUNCHER_Y, VZ, 0, Spring.GetGaiaTeamID()) + local uid = spCreateUnit("volcano_projectile_unit", VX, LAUNCHER_Y, VZ, 0, SpringShared.GetGaiaTeamID()) if not uid then return end @@ -393,9 +393,9 @@ if gadgetHandler:IsSyncedCode() then -------------------------------------------------------------------------------- else - local spPlaySoundFile = Spring.PlaySoundFile - local spGetGameFrame = Spring.GetGameFrame - local spGetViewGeometry = Spring.GetViewGeometry + local spPlaySoundFile = SpringUnsynced.PlaySoundFile + local spGetGameFrame = SpringShared.GetGameFrame + local spGetViewGeometry = SpringUnsynced.GetViewGeometry local glPushMatrix = gl.PushMatrix local glPopMatrix = gl.PopMatrix @@ -421,7 +421,7 @@ else warningText = msg or "SEISMIC ACTIVITY DETECTED" warningEnd = spGetGameFrame() + WARNING_FRAMES - Spring.Echo("[Volcano] Warning: " .. warningText) + SpringShared.Echo("[Volcano] Warning: " .. warningText) spPlaySoundFile("sounds/voice-soundeffects/LavaAlert.wav", 1.0, "ui") end) end diff --git a/luarules/gadgets/gfx_debrisexplosions.lua b/luarules/gadgets/gfx_debrisexplosions.lua index 1ea18cffa52..28c932847ca 100644 --- a/luarules/gadgets/gfx_debrisexplosions.lua +++ b/luarules/gadgets/gfx_debrisexplosions.lua @@ -30,9 +30,9 @@ if gadgetHandler:IsSyncedCode() then Script.SetWatchExplosion(-1, true) -- well that doesnt register anything! end - local spGetProjectileType = Spring.GetProjectileType - local spSpawnCEG = Spring.SpawnCEG - local spGetProjectilePosition = Spring.GetProjectilePosition + local spGetProjectileType = SpringShared.GetProjectileType + local spSpawnCEG = SpringSynced.SpawnCEG + local spGetProjectilePosition = SpringShared.GetProjectilePosition function gadget:ProjectileDestroyed(proID) -- Catch debris explosions, get position, pick random ceg, spawn it at position. local weapon, piece = spGetProjectileType(proID) diff --git a/luarules/gadgets/gfx_explosion_lights.lua b/luarules/gadgets/gfx_explosion_lights.lua index c5a4f270fce..0ff7ac6f93d 100644 --- a/luarules/gadgets/gfx_explosion_lights.lua +++ b/luarules/gadgets/gfx_explosion_lights.lua @@ -16,7 +16,7 @@ end if gadgetHandler:IsSyncedCode() then local SendToUnsynced = SendToUnsynced - local spGetProjectilePosition = Spring.GetProjectilePosition + local spGetProjectilePosition = SpringShared.GetProjectilePosition local explosionTypes = { Flame = true, @@ -76,15 +76,15 @@ else -- Unsynced local myPlayerID = Spring.GetMyPlayerID() local myAllyID = Spring.GetMyAllyTeamID() - local fullView = select(2, Spring.GetSpectatingState()) - local spGetUnitAllyTeam = Spring.GetUnitAllyTeam - local spIsPosInLos = Spring.IsPosInLos + local fullView = select(2, SpringUnsynced.GetSpectatingState()) + local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam + local spIsPosInLos = SpringShared.IsPosInLos function gadget:PlayerChanged(playerID) if playerID == myPlayerID then myPlayerID = Spring.GetMyPlayerID() myAllyID = Spring.GetMyAllyTeamID() - fullView = select(2, Spring.GetSpectatingState()) + fullView = select(2, SpringUnsynced.GetSpectatingState()) end end diff --git a/luarules/gadgets/gfx_raptor_scum_gl4.lua b/luarules/gadgets/gfx_raptor_scum_gl4.lua index a99f8232013..2cb3e920da7 100644 --- a/luarules/gadgets/gfx_raptor_scum_gl4.lua +++ b/luarules/gadgets/gfx_raptor_scum_gl4.lua @@ -34,8 +34,8 @@ if gadgetHandler:IsSyncedCode() then local max = math.max local min = math.min local clamp = math.clamp - local spGetGroundHeight = Spring.GetGroundHeight - local spGetGameFrame = Spring.GetGameFrame + local spGetGroundHeight = SpringShared.GetGroundHeight + local spGetGameFrame = SpringShared.GetGameFrame local mapSizeX = Game.mapSizeX local mapSizeZ = Game.mapSizeZ local initialized = false @@ -227,7 +227,7 @@ if gadgetHandler:IsSyncedCode() then local function AddOrUpdateScum(posx, posy, posz, radius, growthrate, scumID) if debugmode then - Spring.Echo("AddOrUpdateScum", posx, posy, posz, radius, growthrate, scumID) + SpringShared.Echo("AddOrUpdateScum", posx, posy, posz, radius, growthrate, scumID) end -- if scumID is supplied, we are updateing an existing scum instance! @@ -236,7 +236,7 @@ if gadgetHandler:IsSyncedCode() then local scum -- thus we need to make a new scum, and register it in our scumBins if scums[scumID] == nil then - posy = posy or Spring.GetGroundHeight(posx, posz) + posy = posy or SpringShared.GetGroundHeight(posx, posz) scum = { posx = posx, posz = posz, radius = radius, spawnframe = gf, growthrate = growthrate, scumID = scumID } scums[scumID] = scum UpdateBins(scumID) @@ -262,14 +262,14 @@ if gadgetHandler:IsSyncedCode() then scum.growthrate = growthrate if debugmode then - Spring.Echo("Updated scum", scumID, "it was", currentradius, "/", scum.radius, "sized, growing at", growthrate) + SpringShared.Echo("Updated scum", scumID, "it was", currentradius, "/", scum.radius, "sized, growing at", growthrate) end end --Spring.Echo(scumID, growthrate, radius, gf) if scum.growthrate < 0 then if debugmode then - Spring.Echo("Removal of scum ID", scumID, "Scheduled for ", deathtime - gf, "from now") + SpringShared.Echo("Removal of scum ID", scumID, "Scheduled for ", deathtime - gf, "from now") end if scumRemoveQueue[deathtime] == nil then scumRemoveQueue[deathtime] = {} @@ -282,8 +282,8 @@ if gadgetHandler:IsSyncedCode() then function gadget:UnitCreated(unitID, unitDefID, unitTeam) if scumSpawnerIDs[unitDefID] and (debugmode or (unitTeam and unitTeam == pveTeamID)) then - local px, py, pz = Spring.GetUnitPosition(unitID) - local gf = Spring.GetGameFrame() + local px, py, pz = SpringShared.GetUnitPosition(unitID) + local gf = SpringShared.GetGameFrame() local scumID = AddOrUpdateScum(px, py, pz, scumSpawnerIDs[unitDefID].radius, scumSpawnerIDs[unitDefID].growthrate, unitID) local scum = scums[scumID] @@ -301,8 +301,8 @@ if gadgetHandler:IsSyncedCode() then function gadget:GameFrame(n) if not initialized then - for i, unitID in ipairs(Spring.GetAllUnits()) do - gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID)) + for i, unitID in ipairs(SpringShared.GetAllUnits()) do + gadget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID)) end initialized = true end @@ -570,7 +570,7 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED ]] local function goodbye(reason) - Spring.Echo("Scum GL4 gadget exiting with reason: " .. reason) + SpringShared.Echo("Scum GL4 gadget exiting with reason: " .. reason) gadgetHandler:RemoveGadget() end @@ -637,7 +637,7 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED local sqrt = math.sqrt local floor = math.floor local clamp = math.clamp - local spGetGroundHeight = Spring.GetGroundHeight + local spGetGroundHeight = SpringShared.GetGroundHeight local mapSizeX = Game.mapSizeX local mapSizeZ = Game.mapSizeZ local boundary = 32 -- how many elmos closer to the center of the scum than the actual edge of the scum the unit must be to be considered on the scum @@ -743,16 +743,16 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED -- growthrate is in elmos per frame, negative for shrinking scums local function AddOrUpdateScum(posx, posy, posz, radius, growthrate, scumID) if debugmode then - Spring.Echo("AddOrUpdateScum", posx, posy, posz, radius, growthrate, scumID) + SpringShared.Echo("AddOrUpdateScum", posx, posy, posz, radius, growthrate, scumID) end -- if scumID is supplied, we are updateing an existing scum instance! - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() local deathtime local scum -- thus we need to make a new scum, and register it in our scumBins if scumID == nil or scums[scumID] == nil then - posy = posy or Spring.GetGroundHeight(posx, posz) + posy = posy or SpringShared.GetGroundHeight(posx, posz) scum = { posx = posx, posz = posz, radius = radius, spawnframe = gf, growthrate = growthrate, scumID = scumID, atmaxsize = false } scums[scumID] = scum UpdateBins(scumID) @@ -778,7 +778,7 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED scum.growthrate = growthrate if debugmode then - Spring.Echo("Updated scum", scumID, "it was", currentradius, "/", scum.radius, "sized, growing at", growthrate) + SpringShared.Echo("Updated scum", scumID, "it was", currentradius, "/", scum.radius, "sized, growing at", growthrate) end end @@ -803,7 +803,7 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED end if scum.growthrate < 0 then if debugmode then - Spring.Echo("Removal of scum ID", scumID, "Scheduled for ", deathtime - gf, "from now") + SpringShared.Echo("Removal of scum ID", scumID, "Scheduled for ", deathtime - gf, "from now") end if scumRemoveQueue[deathtime] == nil then scumRemoveQueue[deathtime] = {} @@ -850,7 +850,7 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED end end if debugmode then - Spring.Echo(string.format("Of %d scums, %d overlaps found in %d comparisons", numscums, overlapcount, comparisons)) + SpringShared.Echo(string.format("Of %d scums, %d overlaps found in %d comparisons", numscums, overlapcount, comparisons)) end -- update the VBO @@ -870,10 +870,10 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED return end if debugmode then - local mx, my, mb = Spring.GetMouseState() - local _, coords = Spring.TraceScreenRay(mx, my, true) + local mx, my, mb = SpringUnsynced.GetMouseState() + local _, coords = SpringUnsynced.TraceScreenRay(mx, my, true) if coords and (IsPosInScum(coords[1], coords[2], coords[3])) then - Spring.Echo("Inscum", numscums, IsPosInScum(coords[1], coords[2], coords[3])) + SpringShared.Echo("Inscum", numscums, IsPosInScum(coords[1], coords[2], coords[3])) end end @@ -929,7 +929,7 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED local lastSunChanged = -1 function gadget:SunChanged() -- Note that map_nightmode.lua gadget has to change sun twice in a single draw frame to update all - local df = Spring.GetDrawFrame() + local df = SpringUnsynced.GetDrawFrame() if df == lastSunChanged then return end @@ -945,7 +945,7 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED local function RemoveScum(instanceID) if debugmode then - Spring.Echo("Removing scum", instanceID) + SpringShared.Echo("Removing scum", instanceID) end if scums[instanceID] then numscums = numscums - 1 @@ -959,7 +959,7 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED local function AddRandomScum() local posx = Game.mapSizeX * math.random() * 0.8 local posz = Game.mapSizeZ * math.random() * 0.8 - local posy = Spring.GetGroundHeight(posx, posz) + local posy = SpringShared.GetGroundHeight(posx, posz) local radius = math.random() * 256 + 128 local growthrate = math.random() * 0.5 -- in elmos per frame local scumID = math.random() @@ -985,7 +985,7 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED Script.LuaUI.GadgetRemoveGrass(scum.posx, scum.posz, currentRadius * 0.87) else if debugmode then - Spring.Echo("Scum ID", scumID, "reached max size", currentRadius, ">=", scum.radius) + SpringShared.Echo("Scum ID", scumID, "reached max size", currentRadius, ">=", scum.radius) end scum.atmaxsize = true end @@ -1024,7 +1024,7 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED local function ScumTextures() textureresolution = ((textureresolution == "low") and "high") or "low" - Spring.Echo("Scum textureresolution set to ", textureresolution) + SpringShared.Echo("Scum textureresolution set to ", textureresolution) end local function ScumStats() @@ -1035,25 +1035,25 @@ elseif not Spring.Utilities.Gametype.IsScavengers() then -- UNSYNCED for _ in pairs(scumBin) do scumCount = scumCount + 1 end - Spring.Echo(string.format("%d scums are in bin %d x %d", scumCount, x, z)) + SpringShared.Echo(string.format("%d scums are in bin %d x %d", scumCount, x, z)) end end - Spring.Echo(string.format("Total amount of scums on map is %d", numscums)) + SpringShared.Echo(string.format("Total amount of scums on map is %d", numscums)) local overlapcount, comparisons = UpdateScumOverlaps() - Spring.Echo("overlapcount", overlapcount, "comparisons=", comparisons) + SpringShared.Echo("overlapcount", overlapcount, "comparisons=", comparisons) end local function ScumReloadShader() - Spring.Echo("ScumReloadShader not implemented") + SpringShared.Echo("ScumReloadShader not implemented") end local function ScumDrawToggle() drawScum = not drawScum - Spring.Echo("Scum drawing toggled to", drawScum) + SpringShared.Echo("Scum drawing toggled to", drawScum) end local function ScumOptimizeOverlap() optimizeoverlaps = not optimizeoverlaps - Spring.Echo("Scum optimizeoverlaps toggled to", optimizeoverlaps) + SpringShared.Echo("Scum optimizeoverlaps toggled to", optimizeoverlaps) UpdateScumOverlaps() end diff --git a/luarules/gadgets/gfx_reclaim_fx.lua b/luarules/gadgets/gfx_reclaim_fx.lua index a38625c7344..e6a4451e38e 100644 --- a/luarules/gadgets/gfx_reclaim_fx.lua +++ b/luarules/gadgets/gfx_reclaim_fx.lua @@ -52,10 +52,10 @@ if gadgetHandler:IsSyncedCode() then function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam, weaponDefID) if attackerID == nil and not ignoreUnits[unitDefID] then -- if reclaimed - local ux, uy, uz = Spring.GetUnitPosition(unitID) + local ux, uy, uz = SpringShared.GetUnitPosition(unitID) if ux ~= nil then local x, y, z = ux, uy, uz - Spring.SpawnCEG("metalshards1", x, y, z) + SpringSynced.SpawnCEG("metalshards1", x, y, z) -- add more effects depending on unit cost local posMultiplier = 0.5 @@ -63,7 +63,7 @@ if gadgetHandler:IsSyncedCode() then x = ux + (random(unitMinX[unitDefID], unitMaxX[unitDefID]) * posMultiplier) z = uz + (random(unitMinZ[unitDefID], unitMaxX[unitDefID]) * posMultiplier) y = uy + (random(0, 1) * unitMaxY[unitDefID] * posMultiplier) - Spring.SpawnCEG("metalshards" .. (((i + 1) % 3) + 1), x, y, z) + SpringSynced.SpawnCEG("metalshards" .. (((i + 1) % 3) + 1), x, y, z) end end end @@ -71,38 +71,38 @@ if gadgetHandler:IsSyncedCode() then local damagedFeatures = {} function gadget:FeatureDamaged(featureID, featureDefID, featureTeam, damage, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam) - if damage > 4 and (damagedFeatures[featureID] == nil or Spring.GetGameFrame() - damagedFeatures[featureID] > 15) and select(1, Spring.GetFeatureHealth(featureID)) > 0 then -- not sure if "select(1,Spring.GetFeatureHealth(featureID)) > 0" is needed because if featuredestroyed, featuredamaged wont be called probably - local fx, fy, fz = Spring.GetFeaturePosition(featureID) + if damage > 4 and (damagedFeatures[featureID] == nil or SpringShared.GetGameFrame() - damagedFeatures[featureID] > 15) and select(1, SpringShared.GetFeatureHealth(featureID)) > 0 then -- not sure if "select(1,Spring.GetFeatureHealth(featureID)) > 0" is needed because if featuredestroyed, featuredamaged wont be called probably + local fx, fy, fz = SpringShared.GetFeaturePosition(featureID) if fx ~= nil then local fdef = featureList[featureDefID] if fdef and fdef.minx and fdef.maxx then local x, y, z = fx, fy, fz - local _, mm, _, me, _ = Spring.GetFeatureResources(featureID) + local _, mm, _, me, _ = SpringShared.GetFeatureResources(featureID) if me ~= nil and me > 0 then local numFx = math.min(25, math.floor(me / 250)) local posMultiplier = 0.5 - Spring.SpawnCEG("energyshards1", x, y, z) + SpringSynced.SpawnCEG("energyshards1", x, y, z) for i = 1, numFx, 1 do x = fx + (random(fdef.minx, fdef.maxx) * posMultiplier) z = fz + (random(fdef.minz, fdef.maxz) * posMultiplier) y = fy + (random(0, 1) * fdef.maxy * posMultiplier) - Spring.SpawnCEG("energyshards" .. (((i + 1) % 3) + 1), x, y, z) + SpringSynced.SpawnCEG("energyshards" .. (((i + 1) % 3) + 1), x, y, z) end end if mm ~= nil and mm > 0 then local numFx = math.min(25, math.floor(mm / 90)) local posMultiplier = 0.5 - Spring.SpawnCEG("metalshards1", x, y, z) + SpringSynced.SpawnCEG("metalshards1", x, y, z) for i = 1, numFx, 1 do x = fx + (random(fdef.minx, fdef.maxx) * posMultiplier) z = fz + (random(fdef.minz, fdef.maxz) * posMultiplier) y = fy + (random(0, 1) * fdef.maxy * posMultiplier) - Spring.SpawnCEG("metalshards" .. (((i + 1) % 3) + 1), x, y, z) + SpringSynced.SpawnCEG("metalshards" .. (((i + 1) % 3) + 1), x, y, z) end end end end - damagedFeatures[featureID] = Spring.GetGameFrame() + damagedFeatures[featureID] = SpringShared.GetGameFrame() end end @@ -110,36 +110,36 @@ if gadgetHandler:IsSyncedCode() then if damagedFeatures[featureID] ~= nil then damagedFeatures[featureID] = nil end - local fx, fy, fz = Spring.GetFeaturePosition(featureID) - if fy ~= nil and fy + 15 > Spring.GetGroundHeight(fx, fz) then - local fdef = featureList[Spring.GetFeatureDefID(featureID)] + local fx, fy, fz = SpringShared.GetFeaturePosition(featureID) + if fy ~= nil and fy + 15 > SpringShared.GetGroundHeight(fx, fz) then + local fdef = featureList[SpringShared.GetFeatureDefID(featureID)] if fdef and fdef.minx then local x, y, z = fx, fy, fz - local rm, mm, re, me, rl = Spring.GetFeatureResources(featureID) + local rm, mm, re, me, rl = SpringShared.GetFeatureResources(featureID) if me ~= nil and me > 0 then local numFx = math.max(math.floor(me / 250), 15) local posMultiplier = 0.5 - Spring.SpawnCEG("energyshards1", x, y, z) + SpringSynced.SpawnCEG("energyshards1", x, y, z) for i = 1, numFx, 1 do x = fx + (random(fdef.minx, fdef.maxx) * posMultiplier) z = fz + (random(fdef.minz, fdef.maxz) * posMultiplier) y = fy + (random(fdef.miny, fdef.maxy) * posMultiplier) - Spring.SpawnCEG("energyshards" .. (((i + 1) % 3) + 1), x, y, z) + SpringSynced.SpawnCEG("energyshards" .. (((i + 1) % 3) + 1), x, y, z) end end if mm ~= nil and mm > 0 then local numFx = math.max(math.floor(mm / 90), 15) local posMultiplier = 0.5 - Spring.SpawnCEG("metalshards1", x, y, z) + SpringSynced.SpawnCEG("metalshards1", x, y, z) for i = 1, numFx, 1 do x = fx + (random(fdef.minx, fdef.maxx) * posMultiplier) z = fz + (random(fdef.minz, fdef.maxz) * posMultiplier) y = fy + (random(fdef.miny, fdef.maxy) * posMultiplier) - Spring.SpawnCEG("metalshards" .. (((i + 1) % 3) + 1), x, y, z) + SpringSynced.SpawnCEG("metalshards" .. (((i + 1) % 3) + 1), x, y, z) end end if rm ~= nil and mm == 0 and re == 0 then - Spring.SpawnCEG("sparklegreen", fx, fy, fz) + SpringSynced.SpawnCEG("sparklegreen", fx, fy, fz) SendToUnsynced("reclaimfx", fx, fy, fz) end end @@ -149,9 +149,9 @@ if gadgetHandler:IsSyncedCode() then else -- UNSYNCED local function reclaimfx(_, fx, fy, fz) - local mySpec, fullview = Spring.GetSpectatingState() - if fullview or Spring.IsPosInLos(fx, fy, fz, Spring.GetMyAllyTeamID()) then - Spring.PlaySoundFile("reclaimate", 1, fx, fy, fz, "sfx") + local mySpec, fullview = SpringUnsynced.GetSpectatingState() + if fullview or SpringShared.IsPosInLos(fx, fy, fz, Spring.GetMyAllyTeamID()) then + SpringUnsynced.PlaySoundFile("reclaimate", 1, fx, fy, fz, "sfx") end end diff --git a/luarules/gadgets/gfx_tree_feller.lua b/luarules/gadgets/gfx_tree_feller.lua index 5dd9161f229..905e0a7f19c 100644 --- a/luarules/gadgets/gfx_tree_feller.lua +++ b/luarules/gadgets/gfx_tree_feller.lua @@ -20,10 +20,10 @@ if gadgetHandler:IsSyncedCode() then local math_min = math.min local math_floor = math.floor - local spSpawnCEG = Spring.SpawnCEG - local spSpawnExplosion = Spring.SpawnExplosion - local spSetFeatureResources = Spring.SetFeatureResources - local spGetGroundHeight = Spring.GetGroundHeight + local spSpawnCEG = SpringSynced.SpawnCEG + local spSpawnExplosion = SpringSynced.SpawnExplosion + local spSetFeatureResources = SpringSynced.SetFeatureResources + local spGetGroundHeight = SpringShared.GetGroundHeight local treefireExplosion = { tiny = { @@ -92,16 +92,16 @@ if gadgetHandler:IsSyncedCode() then end end - local GetFeaturePosition = Spring.GetFeaturePosition - local GetFeatureHealth = Spring.GetFeatureHealth - local GetFeatureDirection = Spring.GetFeatureDirection - local GetFeatureResources = Spring.GetFeatureResources - local SetFeatureDirection = Spring.SetFeatureDirection - local SetFeatureBlocking = Spring.SetFeatureBlocking - local SetFeaturePosition = Spring.SetFeaturePosition - local CreateFeature = Spring.CreateFeature - local DestroyFeature = Spring.DestroyFeature - local GetGameFrame = Spring.GetGameFrame + local GetFeaturePosition = SpringShared.GetFeaturePosition + local GetFeatureHealth = SpringShared.GetFeatureHealth + local GetFeatureDirection = SpringShared.GetFeatureDirection + local GetFeatureResources = SpringShared.GetFeatureResources + local SetFeatureDirection = SpringSynced.SetFeatureDirection + local SetFeatureBlocking = SpringSynced.SetFeatureBlocking + local SetFeaturePosition = SpringSynced.SetFeaturePosition + local CreateFeature = SpringSynced.CreateFeature + local DestroyFeature = SpringSynced.DestroyFeature + local GetGameFrame = SpringShared.GetGameFrame local treesdying = {} local falltime = 55.0 -- in frames @@ -133,11 +133,11 @@ if gadgetHandler:IsSyncedCode() then local function ComSpawnDefoliate(spawnx, spawny, spawnz) - local blasted_trees = Spring.GetFeaturesInCylinder(spawnx, spawnz, 125) + local blasted_trees = SpringShared.GetFeaturesInCylinder(spawnx, spawnz, 125) for i, tree in pairs(blasted_trees) do - local featureDefID = Spring.GetFeatureDefID(tree) + local featureDefID = SpringShared.GetFeatureDefID(tree) if geothermals[featureDefID] then return 0 @@ -157,15 +157,15 @@ if gadgetHandler:IsSyncedCode() then elseif treeScaleY[featureDefID] > 65 then size = "large" end - dissapearSpeed = 0.15 + Spring.GetFeatureHeight(tree) / math_random(3700, 4700) + dissapearSpeed = 0.15 + SpringShared.GetFeatureHeight(tree) / math_random(3700, 4700) end local destroyFrame = GetGameFrame() + falltime + 150 + (dissapearSpeed * 4000) local dmg = treeMass[featureDefID] * 2 - Spring.SetFeatureResources(0, 0, 0, 0) - Spring.SetFeatureNoSelect(tree, true) - Spring.PlaySoundFile("treefall", 2, fx, fy, fz, "sfx") + SpringSynced.SetFeatureResources(0, 0, 0, 0) + SpringSynced.SetFeatureNoSelect(tree, true) + SpringUnsynced.PlaySoundFile("treefall", 2, fx, fy, fz, "sfx") treesdying[tree] = { frame = GetGameFrame(), posx = fx, @@ -197,14 +197,14 @@ if gadgetHandler:IsSyncedCode() then local lavaCheckInterval = 30 local function checkLavaTreesDestroy() - local lavaLevel = Spring.GetGameRulesParam("lavaLevel") + local lavaLevel = SpringShared.GetGameRulesParam("lavaLevel") if not lavaLevel or lavaLevel <= -99999 then return end - local allFeatures = Spring.GetAllFeatures() + local allFeatures = SpringShared.GetAllFeatures() for i = 1, #allFeatures do local featureID = allFeatures[i] - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if treeMass[featureDefID] and not geothermals[featureDefID] then local remainingMetal, maxMetal, remainingEnergy, maxEnergy = GetFeatureResources(featureID) if maxMetal == 0 and maxEnergy > 0 then @@ -219,15 +219,15 @@ if gadgetHandler:IsSyncedCode() then end local function checkLavaTreesFire(gf) - local lavaLevel = Spring.GetGameRulesParam("lavaLevel") + local lavaLevel = SpringShared.GetGameRulesParam("lavaLevel") if not lavaLevel or lavaLevel <= -99999 or lavaLevel <= lastLavaLevel then return end - local allFeatures = Spring.GetAllFeatures() + local allFeatures = SpringShared.GetAllFeatures() for i = 1, #allFeatures do local featureID = allFeatures[i] if not treesdying[featureID] then - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if treeMass[featureDefID] and not geothermals[featureDefID] then local remainingMetal, maxMetal, remainingEnergy, maxEnergy = GetFeatureResources(featureID) if maxMetal == 0 and maxEnergy > 0 then @@ -244,12 +244,12 @@ if gadgetHandler:IsSyncedCode() then elseif treeScaleY[featureDefID] > 65 then size = "large" end - dissapearSpeed = 0.15 + Spring.GetFeatureHeight(featureID) / math_random(3700, 4700) + dissapearSpeed = 0.15 + SpringShared.GetFeatureHeight(featureID) / math_random(3700, 4700) end local destroyFrame = gf + falltime + 150 + (dissapearSpeed * 4000) SetFeatureBlocking(featureID, false, false, false, false, false, false, false) spSetFeatureResources(0, 0, 0, 0) - Spring.SetFeatureNoSelect(featureID, true) + SpringSynced.SetFeatureNoSelect(featureID, true) treesdying[featureID] = { frame = gf, posx = fx, @@ -317,7 +317,7 @@ if gadgetHandler:IsSyncedCode() then elseif treeScaleY[featureDefID] > 65 then size = "large" end - dissapearSpeed = 0.15 + Spring.GetFeatureHeight(featureID) / math_random(3700, 4700) + dissapearSpeed = 0.15 + SpringShared.GetFeatureHeight(featureID) / math_random(3700, 4700) end --local destroyFrame = GetGameFrame() + (falltime * (treeMass[featureDefID] / dmg)) + 150 + (dissapearSpeed*4000) local destroyFrame = GetGameFrame() + falltime + 150 + (dissapearSpeed * 4000) @@ -354,8 +354,8 @@ if gadgetHandler:IsSyncedCode() then -- PROJECTILE EXPLOSION elseif projectileID > 0 and weaponDefID and not noFireWeapons[weaponDefID] then - ppx, ppy, ppz = Spring.GetProjectilePosition(projectileID) - local vpx, vpy, vpz = Spring.GetProjectileVelocity(projectileID) + ppx, ppy, ppz = SpringShared.GetProjectilePosition(projectileID) + local vpx, vpy, vpz = SpringShared.GetProjectileVelocity(projectileID) ppx = ppx - 2 * vpx ppy = ppy - 2 * vpy ppz = ppz - 2 * vpz @@ -366,8 +366,8 @@ if gadgetHandler:IsSyncedCode() then -- CRUSH elseif attackerID and weaponDefID < 0 then - ppx, ppy, ppz = Spring.GetUnitPosition(attackerID) - local vpx, vpy, vpz = Spring.GetUnitVelocity(attackerID) + ppx, ppy, ppz = SpringShared.GetUnitPosition(attackerID) + local vpx, vpy, vpz = SpringShared.GetUnitVelocity(attackerID) ppx = ppx - 2 * vpx ppy = ppy - 2 * vpy ppz = ppz - 2 * vpz @@ -376,15 +376,15 @@ if gadgetHandler:IsSyncedCode() then -- UNITEXPLOSION elseif attackerID and weaponDefID and not noFireWeapons[weaponDefID] then - ppx, ppy, ppz = Spring.GetUnitPosition(attackerID) + ppx, ppy, ppz = SpringShared.GetUnitPosition(attackerID) dmg = math_min(treeMass[featureDefID] * 2, dmg) if fy >= 0 then fire = true end end spSetFeatureResources(0, 0, 0, 0) - Spring.SetFeatureNoSelect(featureID, true) - Spring.PlaySoundFile("treefall", 2, fx, fy, fz, "sfx") + SpringSynced.SetFeatureNoSelect(featureID, true) + SpringUnsynced.PlaySoundFile("treefall", 2, fx, fy, fz, "sfx") treesdying[featureID] = { frame = GetGameFrame(), posx = fx, diff --git a/luarules/gadgets/gfx_unit_glass.lua b/luarules/gadgets/gfx_unit_glass.lua index 259683b8a9a..7dafec95af8 100644 --- a/luarules/gadgets/gfx_unit_glass.lua +++ b/luarules/gadgets/gfx_unit_glass.lua @@ -16,11 +16,11 @@ end -- Global Acceleration ----------------------------------------------------------------- -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPieceList = Spring.GetUnitPieceList -local spGetUnitTeam = Spring.GetUnitTeam -local spSetUnitPieceVisible = Spring.SetUnitPieceVisible -local spGetUnitIsCloaked = Spring.GetUnitIsCloaked +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPieceList = SpringShared.GetUnitPieceList +local spGetUnitTeam = SpringShared.GetUnitTeam +local spSetUnitPieceVisible = SpringSynced.SetUnitPieceVisible +local spGetUnitIsCloaked = SpringShared.GetUnitIsCloaked if gadgetHandler:IsSyncedCode() then -- Synced @@ -61,7 +61,7 @@ if gadgetHandler:IsSyncedCode() then -- Synced end function gadget:Initialize() - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for _, unitID in ipairs(allUnits) do local unitDefID = spGetUnitDefID(unitID) local unitTeamID = spGetUnitTeam(unitID) @@ -70,7 +70,7 @@ if gadgetHandler:IsSyncedCode() then -- Synced end function gadget:Shutdown() - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for _, unitID in ipairs(allUnits) do local unitDefID = spGetUnitDefID(unitID) if glassUnitDefs[unitDefID] then @@ -93,8 +93,8 @@ else -- Unsynced -- Acceleration ----------------------------------------------------------------- - local spGetVisibleUnits = Spring.GetVisibleUnits - local spGetTeamColor = Spring.GetTeamColor + local spGetVisibleUnits = SpringUnsynced.GetVisibleUnits + local spGetTeamColor = SpringUnsynced.GetTeamColor local glGetSun = gl.GetSun @@ -281,7 +281,7 @@ void main(void){ local sunChanged = true local glassShader - local isSpec, fullview = Spring.GetSpectatingState() + local isSpec, fullview = SpringUnsynced.GetSpectatingState() local myAllyTeamID = Spring.GetMyAllyTeamID() local myTeamID = Spring.GetMyTeamID() @@ -304,7 +304,7 @@ void main(void){ function gadget:PlayerChanged(playerID) local prevFullview = fullview local prevMyAllyTeamID = myAllyTeamID - isSpec, fullview = Spring.GetSpectatingState() + isSpec, fullview = SpringUnsynced.GetSpectatingState() myAllyTeamID = Spring.GetMyAllyTeamID() myTeamID = Spring.GetMyTeamID() if fullview ~= prevFullview or myAllyTeamID ~= prevMyAllyTeamID then @@ -329,14 +329,14 @@ void main(void){ glassShader:SetUniformFloatAlways("sunPos", glGetSun("pos")) glassShader:SetUniformFloatArrayAlways("pbrParams", { - Spring.GetConfigFloat("tonemapA", 4.8), - Spring.GetConfigFloat("tonemapB", 0.8), - Spring.GetConfigFloat("tonemapC", 3.35), - Spring.GetConfigFloat("tonemapD", 1.0), - Spring.GetConfigFloat("tonemapE", 1.15), - Spring.GetConfigFloat("envAmbient", 0.3), - Spring.GetConfigFloat("unitSunMult", 1.35), - Spring.GetConfigFloat("unitExposureMult", 1.0), + SpringUnsynced.GetConfigFloat("tonemapA", 4.8), + SpringUnsynced.GetConfigFloat("tonemapB", 0.8), + SpringUnsynced.GetConfigFloat("tonemapC", 3.35), + SpringUnsynced.GetConfigFloat("tonemapD", 1.0), + SpringUnsynced.GetConfigFloat("tonemapE", 1.15), + SpringUnsynced.GetConfigFloat("envAmbient", 0.3), + SpringUnsynced.GetConfigFloat("unitSunMult", 1.35), + SpringUnsynced.GetConfigFloat("unitExposureMult", 1.0), }) sunChanged = false @@ -436,7 +436,7 @@ void main(void){ end local units if fullview then - units = Spring.GetAllUnits() + units = SpringShared.GetAllUnits() else units = CallAsTeam(myTeamID, spGetVisibleUnits, -1, nil, false) end @@ -458,13 +458,13 @@ void main(void){ end function gadget:UnitEnteredLos(unitID, unitTeam, allyTeam, unitDefID) - if (glassUnitDefs[unitDefID] or not solidUnitDefs[unitDefID]) and CallAsTeam(myTeamID, Spring.IsUnitVisible, unitID, nil, false) then + if (glassUnitDefs[unitDefID] or not solidUnitDefs[unitDefID]) and CallAsTeam(myTeamID, SpringUnsynced.IsUnitVisible, unitID, nil, false) then UpdateGlassUnit(unitID) end end function gadget:UnitLeftLos(unitID, unitTeam, allyTeam, unitDefID) - if (glassUnitDefs[unitDefID] or not solidUnitDefs[unitDefID]) and not CallAsTeam(myTeamID, Spring.IsUnitVisible, unitID, nil, false) then + if (glassUnitDefs[unitDefID] or not solidUnitDefs[unitDefID]) and not CallAsTeam(myTeamID, SpringUnsynced.IsUnitVisible, unitID, nil, false) then GlassUnitDestroyed(unitID) end end @@ -476,7 +476,7 @@ void main(void){ end function gadget:UnitDecloaked(unitID, unitDefID, unitTeam) - if (glassUnitDefs[unitDefID] or not solidUnitDefs[unitDefID]) and CallAsTeam(myTeamID, Spring.IsUnitVisible, unitID, nil, false) then + if (glassUnitDefs[unitDefID] or not solidUnitDefs[unitDefID]) and CallAsTeam(myTeamID, SpringUnsynced.IsUnitVisible, unitID, nil, false) then UpdateGlassUnit(unitID) end end diff --git a/luarules/gadgets/gfx_unit_script_decals.lua b/luarules/gadgets/gfx_unit_script_decals.lua index 3276c627dfe..302b39d3f0c 100644 --- a/luarules/gadgets/gfx_unit_script_decals.lua +++ b/luarules/gadgets/gfx_unit_script_decals.lua @@ -32,13 +32,13 @@ else -- UNSYNCED local myAllyTeamID = Spring.GetMyAllyTeamID() local myPlayerID = Spring.GetMyPlayerID() - local mySpec, fullview = Spring.GetSpectatingState() - local spIsUnitInLos = Spring.IsUnitInLos + local mySpec, fullview = SpringUnsynced.GetSpectatingState() + local spIsUnitInLos = SpringShared.IsUnitInLos function gadget:PlayerChanged(playerID) if playerID == myPlayerID then myAllyTeamID = Spring.GetMyAllyTeamID() - mySpec, fullview = Spring.GetSpectatingState() + mySpec, fullview = SpringUnsynced.GetSpectatingState() end end diff --git a/luarules/gadgets/gfx_unit_script_lights.lua b/luarules/gadgets/gfx_unit_script_lights.lua index 23e792261cf..c4d0f8e90ac 100644 --- a/luarules/gadgets/gfx_unit_script_lights.lua +++ b/luarules/gadgets/gfx_unit_script_lights.lua @@ -38,13 +38,13 @@ if gadgetHandler:IsSyncedCode() then else -- UNSYNCED local myAllyTeamID = Spring.GetMyAllyTeamID() local myPlayerID = Spring.GetMyPlayerID() - local mySpec, fullview = Spring.GetSpectatingState() - local spIsUnitInLos = Spring.IsUnitInLos + local mySpec, fullview = SpringUnsynced.GetSpectatingState() + local spIsUnitInLos = SpringShared.IsUnitInLos function gadget:PlayerChanged(playerID) if playerID == myPlayerID then myAllyTeamID = Spring.GetMyAllyTeamID() - mySpec, fullview = Spring.GetSpectatingState() + mySpec, fullview = SpringUnsynced.GetSpectatingState() end end diff --git a/luarules/gadgets/gfx_unit_shield_effects.lua b/luarules/gadgets/gfx_unit_shield_effects.lua index 233497cb9e5..0ae6223d0c7 100644 --- a/luarules/gadgets/gfx_unit_shield_effects.lua +++ b/luarules/gadgets/gfx_unit_shield_effects.lua @@ -65,7 +65,7 @@ end ----------------------------------------------------------------- if gadgetHandler:IsSyncedCode() then - local spSetUnitRulesParam = Spring.SetUnitRulesParam + local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam local SendToUnsynced = SendToUnsynced local INLOS_ACCESS = { inlos = true } local gameFrame = 0 @@ -104,9 +104,9 @@ if gadgetHandler:IsSyncedCode() then local dmgMod = 1 local weaponDefID if proID and proID ~= -1 then - weaponDefID = Spring.GetProjectileDefID(proID) + weaponDefID = SpringShared.GetProjectileDefID(proID) elseif beamEmitterUnitID then -- hitscan weapons - local uDefID = Spring.GetUnitDefID(beamEmitterUnitID) + local uDefID = SpringShared.GetUnitDefID(beamEmitterUnitID) if unitBeamWeapons[uDefID] and unitBeamWeapons[uDefID][beamEmitterWeaponNum] then weaponDefID = unitBeamWeapons[uDefID][beamEmitterWeaponNum] if weaponType[weaponDefID] ~= "LightningCannon" then @@ -121,7 +121,7 @@ if gadgetHandler:IsSyncedCode() then dmg = weaponDamages[weaponDefID][SHIELDARMORIDALT] end - local x, y, z = Spring.GetUnitPosition(shieldCarrierUnitID) + local x, y, z = SpringShared.GetUnitPosition(shieldCarrierUnitID) local dx, dy, dz local onlyMove = false if bounceProjectile then @@ -145,14 +145,14 @@ end -------------------------------------------------------------------------------- local spGetMyAllyTeamID = Spring.GetMyAllyTeamID -local spGetSpectatingState = Spring.GetSpectatingState -local spGetUnitPosition = Spring.GetUnitPosition -local spIsSphereInView = Spring.IsSphereInView -local spGetUnitRotation = Spring.GetUnitRotation -local spGetUnitShieldState = Spring.GetUnitShieldState -local spGetUnitIsStunned = Spring.GetUnitIsStunned -local spGetGameFrame = Spring.GetGameFrame -local spGetFrameTimeOffset = Spring.GetFrameTimeOffset +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetUnitPosition = SpringShared.GetUnitPosition +local spIsSphereInView = SpringUnsynced.IsSphereInView +local spGetUnitRotation = SpringShared.GetUnitRotation +local spGetUnitShieldState = SpringShared.GetUnitShieldState +local spGetUnitIsStunned = SpringShared.GetUnitIsStunned +local spGetGameFrame = SpringShared.GetGameFrame +local spGetFrameTimeOffset = SpringUnsynced.GetFrameTimeOffset local IterableMap = VFS.Include("LuaRules/Gadgets/Include/IterableMap.lua") @@ -199,7 +199,7 @@ local function GetVisibleSearch(x, z, search) return false end for i = 1, #search do - if Spring.IsPosInAirLos(x + search[i][1], 0, z + search[i][2], myAllyTeamID) then + if SpringShared.IsPosInAirLos(x + search[i][1], 0, z + search[i][2], myAllyTeamID) then return true end end @@ -209,17 +209,17 @@ end local function UpdateVisibility(unitID, unitData, unitVisible, forceUpdate) unitVisible = unitVisible or (myAllyTeamID == unitData.allyTeamID) if not unitVisible then - local ux, _, uz = Spring.GetUnitPosition(unitID) + local ux, _, uz = SpringShared.GetUnitPosition(unitID) unitVisible = GetVisibleSearch(ux, uz, unitData.search) end - local unitIsActive = Spring.GetUnitIsActive(unitID) + local unitIsActive = SpringShared.GetUnitIsActive(unitID) if unitIsActive ~= unitData.isActive then forceUpdate = true unitData.isActive = unitIsActive end - local shieldEnabled = Spring.GetUnitRulesParam(unitID, SHIELDONRULESPARAMINDEX) + local shieldEnabled = SpringShared.GetUnitRulesParam(unitID, SHIELDONRULESPARAMINDEX) if shieldEnabled == 1 then unitVisible = true elseif shieldEnabled == 0 then @@ -244,7 +244,7 @@ local function AddUnit(unitID, unitDefID) -- Validate shield capacity if not def.shieldCapacity or def.shieldCapacity <= 0 then - Spring.Echo("Warning: Shield unit " .. unitDefID .. " has invalid capacity: " .. tostring(def.shieldCapacity)) + SpringShared.Echo("Warning: Shield unit " .. unitDefID .. " has invalid capacity: " .. tostring(def.shieldCapacity)) return end @@ -260,7 +260,7 @@ local function AddUnit(unitID, unitDefID) capacity = def.shieldCapacity, radius = def.shieldRadius, shieldInfo = shieldInfo, - allyTeamID = Spring.GetUnitAllyTeam(unitID), + allyTeamID = SpringShared.GetUnitAllyTeam(unitID), } if highEnoughQuality then @@ -641,11 +641,11 @@ local function InitializeShader() -- Check if shader files exist if not VFS.FileExists("shaders/ShieldSphereColor.vert") then - Spring.Echo("Shield shader error: shaders/ShieldSphereColor.vert not found!") + SpringShared.Echo("Shield shader error: shaders/ShieldSphereColor.vert not found!") return false end if not VFS.FileExists("shaders/ShieldSphereColor.frag") then - Spring.Echo("Shield shader error: shaders/ShieldSphereColor.frag not found!") + SpringShared.Echo("Shield shader error: shaders/ShieldSphereColor.frag not found!") return false end @@ -653,7 +653,7 @@ local function InitializeShader() local shieldShaderFrag = VFS.LoadFile("shaders/ShieldSphereColor.frag") if not shieldShaderVert or not shieldShaderFrag then - Spring.Echo("Shield shader error: Failed to load shader files!") + SpringShared.Echo("Shield shader error: Failed to load shader files!") return false end @@ -684,14 +684,14 @@ local function InitializeShader() local shaderCompiled = shieldShader:Initialize() if not shaderCompiled then - Spring.Echo("Shield shader failed to compile!") + SpringShared.Echo("Shield shader failed to compile!") shieldShader = nil return false end -- Verify shader object is valid if not shieldShader or not shieldShader.uniformLocations then - Spring.Echo("Shield shader object is invalid after initialization!") + SpringShared.Echo("Shield shader object is invalid after initialization!") shieldShader = nil return false end @@ -964,7 +964,7 @@ end function gadget:UnitTaken(unitID, unitDefID, newTeam, oldTeam) local unitData = IterableMap.Get(shieldUnits, unitID) if unitData then - unitData.allyTeamID = Spring.GetUnitAllyTeam(unitID) + unitData.allyTeamID = SpringShared.GetUnitAllyTeam(unitID) end end @@ -998,7 +998,7 @@ function gadget:Initialize(n) -- Initialize shader and geometry local shaderSuccess = InitializeShader() if not shaderSuccess then - Spring.Echo("Shield gadget: Failed to initialize shader, disabling") + SpringShared.Echo("Shield gadget: Failed to initialize shader, disabling") gadgetHandler:RemoveGadget(self) return end @@ -1009,11 +1009,11 @@ function gadget:Initialize(n) end -- Add existing units - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for i = 1, #allUnits do local unitID = allUnits[i] - local unitDefID = Spring.GetUnitDefID(unitID) - local unitTeam = Spring.GetUnitTeam(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) + local unitTeam = SpringShared.GetUnitTeam(unitID) if unitDefID and unitTeam then gadget:UnitFinished(unitID, unitDefID, unitTeam) end @@ -1030,7 +1030,7 @@ function gadget:Shutdown() FinalizeShader() -- Remove all units - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for i = 1, #allUnits do local unitID = allUnits[i] RemoveUnit(unitID) diff --git a/luarules/gadgets/gfx_wade_fx.lua b/luarules/gadgets/gfx_wade_fx.lua index f8c6b7cbb75..35545e708ed 100644 --- a/luarules/gadgets/gfx_wade_fx.lua +++ b/luarules/gadgets/gfx_wade_fx.lua @@ -25,12 +25,12 @@ local fold_frames = 4 -- every X-th frame local n_folds = 3 -- check every X-th unit local current_fold = 1 -local spGetUnitIsCloaked = Spring.GetUnitIsCloaked -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitVelocity = Spring.GetUnitVelocity -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitDefDimensions = Spring.GetUnitDefDimensions -local spSpawnCEG = Spring.SpawnCEG +local spGetUnitIsCloaked = SpringShared.GetUnitIsCloaked +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitVelocity = SpringShared.GetUnitVelocity +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitDefDimensions = SpringShared.GetUnitDefDimensions +local spSpawnCEG = SpringSynced.SpawnCEG local wadeDepth = {} local wadeSfxID = {} @@ -112,7 +112,7 @@ end function gadget:GameFrame(n) if n % fold_frames == 0 then if n <= fold_frames then - local minheight = Spring.GetGroundExtremes() + local minheight = SpringShared.GetGroundExtremes() if minheight > 20 then gadgetHandler:RemoveGadget(self) return @@ -143,7 +143,7 @@ function gadget:GameFrame(n) end function gadget:Initialize() - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for i = 1, #allUnits do local unitID = allUnits[i] gadget:UnitCreated(unitID, spGetUnitDefID(unitID)) diff --git a/luarules/gadgets/gpumem_broadcast.lua b/luarules/gadgets/gpumem_broadcast.lua index 449c8d466c7..cdd29b4f3cb 100644 --- a/luarules/gadgets/gpumem_broadcast.lua +++ b/luarules/gadgets/gpumem_broadcast.lua @@ -38,8 +38,8 @@ else -- unsynced -------------------------------------------------------------------------------- - local GetLastUpdateSeconds = Spring.GetLastUpdateSeconds - local SendLuaRulesMsg = Spring.SendLuaRulesMsg + local GetLastUpdateSeconds = SpringUnsynced.GetLastUpdateSeconds + local SendLuaRulesMsg = SpringUnsynced.SendLuaRulesMsg local validation = SYNCED.validationGpuMem local updateTimer = 0 @@ -60,7 +60,7 @@ else function gadget:Update() updateTimer = updateTimer + GetLastUpdateSeconds() if updateTimer > sendPacketEvery then - local used, max = Spring.GetVidMemUsage() + local used, max = SpringUnsynced.GetVidMemUsage() if type(used) == "number" and used > 0 then SendLuaRulesMsg("@" .. validation .. math.ceil((used / max) * 100)) updateTimer = 0 diff --git a/luarules/gadgets/graphics_territorial_domination.lua b/luarules/gadgets/graphics_territorial_domination.lua index de73f84b482..7682a4831ee 100644 --- a/luarules/gadgets/graphics_territorial_domination.lua +++ b/luarules/gadgets/graphics_territorial_domination.lua @@ -11,7 +11,7 @@ function gadget:GetInfo() } end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() local isSynced = gadgetHandler:IsSyncedCode() if modOptions.deathmode ~= "territorial_domination" or isSynced then return false @@ -58,18 +58,18 @@ local currentFrame = 0 local lastMoveFrame = 0 local myAllyID = Spring.GetMyAllyTeamID() -local gaiaAllyTeamID = select(6, Spring.GetTeamInfo(Spring.GetGaiaTeamID())) -local allTeams = Spring.GetTeamList() -local amSpectating = Spring.GetSpectatingState() +local gaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(SpringShared.GetGaiaTeamID())) +local allTeams = SpringShared.GetTeamList() +local amSpectating = SpringUnsynced.GetSpectatingState() local previousAllyID = nil local allyColors = {} local blankColor = { 0.5, 0.5, 0.5, 0.0 } -local spIsGUIHidden = Spring.IsGUIHidden +local spIsGUIHidden = SpringUnsynced.IsGUIHidden local glDepthTest = gl.DepthTest local glTexture = gl.Texture -local spPlaySoundFile = Spring.PlaySoundFile +local spPlaySoundFile = SpringUnsynced.PlaySoundFile local planeLayout = { { id = 1, name = "posscale", size = 4 }, -- a vec4 for pos + scale @@ -275,10 +275,10 @@ void main() { local function initializeAllyColors() for _, teamID in ipairs(allTeams) do - local allyID = select(6, Spring.GetTeamInfo(teamID)) + local allyID = select(6, SpringShared.GetTeamInfo(teamID)) if allyID and not allyColors[allyID] then if allyID ~= gaiaAllyTeamID then - local r, g, b, a = Spring.GetTeamColor(teamID) + local r, g, b, a = SpringUnsynced.GetTeamColor(teamID) allyColors[allyID] = { r, g, b, SQUARE_ALPHA } else allyColors[allyID] = blankColor @@ -291,7 +291,7 @@ local function getMaxCameraHeight() local mapSizeX = Game.mapSizeX local mapSizeZ = Game.mapSizeZ local fallbackMaxFactor = 1.4 --to handle all camera modes - local maxFactor = Spring.GetConfigFloat("OverheadMaxHeightFactor", fallbackMaxFactor) + local maxFactor = SpringUnsynced.GetConfigFloat("OverheadMaxHeightFactor", fallbackMaxFactor) local absoluteMinimum = 500 local minimumFactor = 0.8 local reductionFactor = 0.8 @@ -330,7 +330,7 @@ local function createShader() local shaderCompiled = squareShader:Initialize() if not shaderCompiled then - Spring.Echo("Failed to compile territory square shader") + SpringShared.Echo("Failed to compile territory square shader") return false end return true @@ -454,7 +454,7 @@ function gadget:Initialize() return end - amSpectating = Spring.GetSpectatingState() + amSpectating = SpringUnsynced.GetSpectatingState() myAllyID = Spring.GetMyAllyTeamID() initializeAllyColors() @@ -499,7 +499,7 @@ local function updateGridSquareColor(gridData) end local function processSpectatorModeChange() - local currentSpectating = Spring.GetSpectatingState() + local currentSpectating = SpringUnsynced.GetSpectatingState() local currentAllyID = Spring.GetMyAllyTeamID() if currentSpectating ~= amSpectating or (previousAllyID and currentAllyID ~= previousAllyID) then diff --git a/luarules/gadgets/gui_awards.lua b/luarules/gadgets/gui_awards.lua index cde6a84ad89..0a2866a3f2b 100644 --- a/luarules/gadgets/gui_awards.lua +++ b/luarules/gadgets/gui_awards.lua @@ -15,8 +15,8 @@ end local topPlacementsCount = 3 -- Only report the top N places for each award if gadgetHandler:IsSyncedCode() then - local spAreTeamsAllied = Spring.AreTeamsAllied - local gaiaTeamID = Spring.GetGaiaTeamID() + local spAreTeamsAllied = SpringShared.AreTeamsAllied + local gaiaTeamID = SpringShared.GetGaiaTeamID() local teamInfo = {} local coopInfo = {} @@ -74,17 +74,17 @@ if gadgetHandler:IsSyncedCode() then function gadget:GameStart() -- make table of teams eligible for awards - local allyTeamIDs = Spring.GetAllyTeamList() + local allyTeamIDs = SpringShared.GetAllyTeamList() for i = 1, #allyTeamIDs do - local teamIDs = Spring.GetTeamList(allyTeamIDs[i]) + local teamIDs = SpringShared.GetTeamList(allyTeamIDs[i]) for j = 1, #teamIDs do - local isLuaAI = (Spring.GetTeamLuaAI(teamIDs[j]) ~= nil) - local isAiTeam = select(4, Spring.GetTeamInfo(teamIDs[j])) + local isLuaAI = (SpringShared.GetTeamLuaAI(teamIDs[j]) ~= nil) + local isAiTeam = select(4, SpringShared.GetTeamInfo(teamIDs[j])) if not (isLuaAI or isAiTeam or teamIDs[j] == gaiaTeamID) then - local playerIDs = Spring.GetPlayerList(teamIDs[j]) + local playerIDs = SpringShared.GetPlayerList(teamIDs[j]) local numPlayers = 0 for _, playerID in pairs(playerIDs) do - if not select(3, Spring.GetPlayerInfo(playerID, false)) then + if not select(3, SpringShared.GetPlayerInfo(playerID, false)) then numPlayers = numPlayers + 1 end end @@ -129,7 +129,7 @@ if gadgetHandler:IsSyncedCode() then end --keep track of who didn't kill for longest (sleeptimes) - local curTime = Spring.GetGameSeconds() + local curTime = SpringShared.GetGameSeconds() if curTime - teamInfo[attackerTeamID].lastKill > teamInfo[attackerTeamID].sleepTime then teamInfo[attackerTeamID].sleepTime = curTime - teamInfo[attackerTeamID].lastKill end @@ -158,16 +158,16 @@ if gadgetHandler:IsSyncedCode() then local totalEco = 1 local nTeams = 0 for tID, _ in pairs(teamInfo) do - local cur_max = Spring.GetTeamStatsHistory(tID) - local stats = Spring.GetTeamStatsHistory(tID, cur_max, cur_max) + local cur_max = SpringShared.GetTeamStatsHistory(tID) + local stats = SpringShared.GetTeamStatsHistory(tID, cur_max, cur_max) totalDmg = totalDmg + teamInfo[tID].allDmg totalEco = totalEco + stats[1].energyUsed + 60 * stats[1].metalUsed -- don't count excessed & reclaimed res nTeams = nTeams + 1 end -- calculate efficiency score - local cur_max = Spring.GetTeamStatsHistory(teamID) - local stats = Spring.GetTeamStatsHistory(teamID, cur_max, cur_max) + local cur_max = SpringShared.GetTeamStatsHistory(teamID) + local stats = SpringShared.GetTeamStatsHistory(teamID, cur_max, cur_max) local teamEco = stats[1].energyProduced + 60 * stats[1].metalProduced -- do count excessed & reclaimed res local pEco = teamEco / totalEco -- [0,1] local pDmg = teamInfo[teamID].allDmg / totalDmg -- [0,infty), due to m/e excessed, but typically [0,1] @@ -179,8 +179,8 @@ if gadgetHandler:IsSyncedCode() then function gadget:GameOver(winningAllyTeams) --get stuff from engine stats (not all of which is currently used) for teamID, _ in pairs(teamInfo) do - local cur_max = Spring.GetTeamStatsHistory(teamID) - local stats = Spring.GetTeamStatsHistory(teamID, cur_max, cur_max) + local cur_max = SpringShared.GetTeamStatsHistory(teamID) + local stats = SpringShared.GetTeamStatsHistory(teamID, cur_max, cur_max) teamInfo[teamID].ecoUsed = teamInfo[teamID].ecoUsed + stats[1].energyUsed + 60 * stats[1].metalUsed -- might already be non-zero due to accounting in UnitTaken teamInfo[teamID].ecoProd = stats[1].energyProduced + 60 * stats[1].metalProduced teamInfo[teamID].dmgDealt = stats[1].damageDealt @@ -227,7 +227,7 @@ if gadgetHandler:IsSyncedCode() then for teamID, _ in pairs(teamInfo) do --deal with sleep times - local curTime = Spring.GetGameSeconds() + local curTime = SpringShared.GetGameSeconds() if curTime - teamInfo[teamID].lastKill > teamInfo[teamID].sleepTime then teamInfo[teamID].sleepTime = curTime - teamInfo[teamID].lastKill end @@ -305,7 +305,7 @@ else local otherLine = "\164" .. tostring(1 + awards.goldenCow[1].teamID) .. "\165" .. tostring(1 + awards.eco[1].teamID) .. ":" .. tostring(awards.eco[1].score) .. "\166" .. tostring(1 + awards.damageReceived[1].teamID) .. ":" .. tostring(awards.damageReceived[1].score) .. "\167" .. tostring(1 + awards.sleep[1].teamID) .. ":" .. tostring(awards.sleep[1].score) local awardsMsg = ecoKillLine .. fightKillLine .. efficientKillLine .. otherLine - Spring.SendLuaRulesMsg(awardsMsg) + SpringUnsynced.SendLuaRulesMsg(awardsMsg) -- send to awards widget if Script.LuaUI("GadgetReceiveAwards") then diff --git a/luarules/gadgets/gui_display_dps.lua b/luarules/gadgets/gui_display_dps.lua index 59a2255358f..72174191237 100644 --- a/luarules/gadgets/gui_display_dps.lua +++ b/luarules/gadgets/gui_display_dps.lua @@ -29,23 +29,23 @@ if gadgetHandler:IsSyncedCode() then return end -local enabled = (tonumber(Spring.GetConfigInt("DisplayDPS", 0) or 0) == 1) +local enabled = (tonumber(SpringUnsynced.GetConfigInt("DisplayDPS", 0) or 0) == 1) -local fontfile = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") -local vsx, vsy = Spring.GetViewGeometry() +local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") +local vsx, vsy = SpringUnsynced.GetViewGeometry() local fontfileScale = 1 + (vsx * vsy / 5700000) local fontfileSize = 25 local fontfileOutlineSize = 6 local fontfileOutlineStrength = 1.3 local font = gl.LoadFont(fontfile, fontfileSize * fontfileScale, fontfileOutlineSize * fontfileScale, fontfileOutlineStrength) -local GetUnitDefID = Spring.GetUnitDefID -local GetUnitDefDimensions = Spring.GetUnitDefDimensions -local AreTeamsAllied = Spring.AreTeamsAllied -local GetGameSpeed = Spring.GetGameSpeed -local GetGameSeconds = Spring.GetGameSeconds -local GetUnitViewPosition = Spring.GetUnitViewPosition -local IsUnitInView = Spring.IsUnitInView +local GetUnitDefID = SpringShared.GetUnitDefID +local GetUnitDefDimensions = SpringShared.GetUnitDefDimensions +local AreTeamsAllied = SpringShared.AreTeamsAllied +local GetGameSpeed = SpringUnsynced.GetGameSpeed +local GetGameSeconds = SpringShared.GetGameSeconds +local GetUnitViewPosition = SpringUnsynced.GetUnitViewPosition +local IsUnitInView = SpringUnsynced.IsUnitInView local glTranslate = gl.Translate local glBillboard = gl.Billboard @@ -57,7 +57,7 @@ local glDrawFuncAtUnit = gl.DrawFuncAtUnit local glPushMatrix = gl.PushMatrix local glPopMatrix = gl.PopMatrix local glCallList = gl.CallList -local IsGUIHidden = Spring.IsGUIHidden +local IsGUIHidden = SpringUnsynced.IsGUIHidden local math_floor = math.floor local math_ceil = math.ceil local math_random = math.random @@ -87,14 +87,14 @@ local drawTextLists = {} local drawTextListsDeath = {} local drawTextListsEmp = {} local myTeamID = Spring.GetMyTeamID() -local _, fullview = Spring.GetSpectatingState() +local _, fullview = SpringUnsynced.GetSpectatingState() local chobbyInterface -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- function gadget:ViewResize(n_vsx, n_vsy) - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() local fontScale = 1 + (vsx * vsy / 5700000) gadget:Shutdown() font = gl.LoadFont(fontfile, 52 * fontScale, 17 * fontScale, 1.3) @@ -299,7 +299,7 @@ end function gadget:PlayerChanged(playerID) myTeamID = Spring.GetMyTeamID() - _, fullview = Spring.GetSpectatingState() + _, fullview = SpringUnsynced.GetSpectatingState() end function gadget:RecvLuaMsg(msg, playerID) @@ -310,7 +310,7 @@ end function checkEnabled() local prevEnabled = enabled - enabled = (tonumber(Spring.GetConfigInt("DisplayDPS", 0) or 0) == 1) + enabled = (tonumber(SpringUnsynced.GetConfigInt("DisplayDPS", 0) or 0) == 1) if prevEnabled ~= enabled then damageTable = {} unitParalyze = {} @@ -338,7 +338,7 @@ end local sec = 0 function gadget:Update() - sec = sec + Spring.GetLastUpdateSeconds() + sec = sec + SpringUnsynced.GetLastUpdateSeconds() if sec > 2 then sec = 0 checkEnabled() diff --git a/luarules/gadgets/gui_soundeffects.lua b/luarules/gadgets/gui_soundeffects.lua index f79ea33910e..b2a1650e5fc 100644 --- a/luarules/gadgets/gui_soundeffects.lua +++ b/luarules/gadgets/gui_soundeffects.lua @@ -18,7 +18,7 @@ function gadget:GetInfo() end -- no need to enable when sound is muted -local enabled = ((Spring.GetConfigInt("snd_unitsound", 1) or 1) ~= 0 and (Spring.GetConfigInt("snd_volmaster", 1) or 100) > 0 and ((Spring.GetConfigInt("snd_volui", 1) or 100) > 0 or (Spring.GetConfigInt("snd_volbattle", 1) or 100) > 0)) +local enabled = ((SpringUnsynced.GetConfigInt("snd_unitsound", 1) or 1) ~= 0 and (SpringUnsynced.GetConfigInt("snd_volmaster", 1) or 100) > 0 and ((SpringUnsynced.GetConfigInt("snd_volui", 1) or 100) > 0 or (SpringUnsynced.GetConfigInt("snd_volbattle", 1) or 100) > 0)) local DelayRandomization = 2 -- frames @@ -109,26 +109,26 @@ end GUIUnitSoundEffects = newGUIUnitSoundEffects newGUIUnitSoundEffects = nil -local CurrentGameFrame = Spring.GetGameFrame() +local CurrentGameFrame = SpringShared.GetGameFrame() local myTeamID = Spring.GetMyTeamID() local myAllyTeamID = Spring.GetMyAllyTeamID() -local spectator, fullview = Spring.GetSpectatingState() - -local spGetUnitIsActive = Spring.GetUnitIsActive -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetUnitPosition = Spring.GetUnitPosition -local spIsUnitInView = Spring.IsUnitInView -local spIsUnitInLos = Spring.IsUnitInLos -local spIsUnitSelected = Spring.IsUnitSelected -local spGetSelectedUnitsCount = Spring.GetSelectedUnitsCount -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetMouseState = Spring.GetMouseState +local spectator, fullview = SpringUnsynced.GetSpectatingState() + +local spGetUnitIsActive = SpringShared.GetUnitIsActive +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetUnitPosition = SpringShared.GetUnitPosition +local spIsUnitInView = SpringUnsynced.IsUnitInView +local spIsUnitInLos = SpringShared.IsUnitInLos +local spIsUnitSelected = SpringUnsynced.IsUnitSelected +local spGetSelectedUnitsCount = SpringUnsynced.GetSelectedUnitsCount +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetMouseState = SpringUnsynced.GetMouseState local spGetMyPlayerID = Spring.GetMyPlayerID local spGetMyTeamID = Spring.GetMyTeamID -local spGetGameFrame = Spring.GetGameFrame -local spPlaySoundFile = Spring.PlaySoundFile +local spGetGameFrame = SpringShared.GetGameFrame +local spPlaySoundFile = SpringUnsynced.PlaySoundFile local math_random = math.random @@ -206,7 +206,7 @@ end function gadget:Initialize() units = {} - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for i = 1, #allUnits do local unitID = allUnits[i] local unitDefID = spGetUnitDefID(unitID) @@ -255,7 +255,7 @@ end local slowTimer, fastTimer = 0, 0 function gadget:Update() - local dt = Spring.GetLastUpdateSeconds() + local dt = SpringUnsynced.GetLastUpdateSeconds() fastTimer = fastTimer + dt if fastTimer > commandSoundTimer then fastTimer = 0 @@ -266,8 +266,8 @@ function gadget:Update() slowTimer = 0 myTeamID = Spring.GetMyTeamID() myAllyTeamID = Spring.GetMyAllyTeamID() - spectator, fullview = Spring.GetSpectatingState() - enabled = ((Spring.GetConfigInt("snd_unitsound", 1) or 1) ~= 0 and (Spring.GetConfigInt("snd_volmaster", 1) or 100) > 0 and ((Spring.GetConfigInt("snd_volui", 1) or 100) > 0 or (Spring.GetConfigInt("snd_volbattle", 1) or 100) > 0)) + spectator, fullview = SpringUnsynced.GetSpectatingState() + enabled = ((SpringUnsynced.GetConfigInt("snd_unitsound", 1) or 1) ~= 0 and (SpringUnsynced.GetConfigInt("snd_volmaster", 1) or 100) > 0 and ((SpringUnsynced.GetConfigInt("snd_volui", 1) or 100) > 0 or (SpringUnsynced.GetConfigInt("snd_volbattle", 1) or 100) > 0)) end end @@ -366,7 +366,7 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) return end if builderID and GUIUnitSoundEffects[unitDefID] then - local _, buildProgress = Spring.GetUnitIsBeingBuilt(unitID) + local _, buildProgress = SpringShared.GetUnitIsBeingBuilt(unitID) if buildProgress < 0.05 then --buildProgress if myTeamID == spGetUnitTeam(builderID) then local posx, posy, posz = spGetUnitPosition(unitID) diff --git a/luarules/gadgets/include/GenBrdfLut.lua b/luarules/gadgets/include/GenBrdfLut.lua index 27176024285..fb1042f9be2 100644 --- a/luarules/gadgets/include/GenBrdfLut.lua +++ b/luarules/gadgets/include/GenBrdfLut.lua @@ -158,7 +158,7 @@ function GenBrdfLut:Initialize() }) if not self.tex then - Spring.Echo("GenBrdfLut: tex creation error:\n") + SpringShared.Echo("GenBrdfLut: tex creation error:\n") end self.fbo = gl.CreateFBO({ @@ -167,7 +167,7 @@ function GenBrdfLut:Initialize() }) if not self.fbo then - Spring.Echo("GenBrdfLut: FBO creation error:\n") + SpringShared.Echo("GenBrdfLut: FBO creation error:\n") end lutFS = lutFS:gsub("###G_OPTION###", tostring(self.gOption)) @@ -183,10 +183,10 @@ function GenBrdfLut:Initialize() local shLog = gl.GetShaderLog() or "" if not self.shader then - Spring.Echo(string.format("GenBrdfLut: [%s] shader errors:\n%s", "GenBrdfLut", shLog)) + SpringShared.Echo(string.format("GenBrdfLut: [%s] shader errors:\n%s", "GenBrdfLut", shLog)) return false elseif shLog ~= "" then - Spring.Echo(string.format("GenBrdfLut: [%s] shader warnings:\n%s", "GenBrdfLut", shLog)) + SpringShared.Echo(string.format("GenBrdfLut: [%s] shader warnings:\n%s", "GenBrdfLut", shLog)) end end @@ -208,7 +208,7 @@ function GenBrdfLut:Execute(saveDebug) gl.TexRect(-1, -1, 1, 1) end) if saveDebug then - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() gl.SaveImage(0, 0, self.textureSize, self.textureSize, string.format("brdf_%s.png", gf)) end end) diff --git a/luarules/gadgets/include/GenEnvLut.lua b/luarules/gadgets/include/GenEnvLut.lua index 5b31d527c4f..245782824ff 100644 --- a/luarules/gadgets/include/GenEnvLut.lua +++ b/luarules/gadgets/include/GenEnvLut.lua @@ -178,7 +178,7 @@ function GenEnvLut:Initialize() self.tex = gl.CreateTexture(3, 3, texParams) if not self.tex then - Spring.Echo("GenEnvLut: tex creation error:\n") + SpringShared.Echo("GenEnvLut: tex creation error:\n") end lutFS = lutFS:gsub("###ENV_SMPL_NUM###", tostring(self.numSamples)) @@ -195,10 +195,10 @@ function GenEnvLut:Initialize() local shLog = gl.GetShaderLog() or "" if not self.shader then - Spring.Echo(string.format("GenEnvLut: [%s] shader errors:\n%s", "GenEnvLut", shLog)) + SpringShared.Echo(string.format("GenEnvLut: [%s] shader errors:\n%s", "GenEnvLut", shLog)) return false elseif shLog ~= "" then - Spring.Echo(string.format("GenEnvLut: [%s] shader warnings:\n%s", "GenEnvLut", shLog)) + SpringShared.Echo(string.format("GenEnvLut: [%s] shader warnings:\n%s", "GenEnvLut", shLog)) end end @@ -221,7 +221,7 @@ function GenEnvLut:Execute(saveDebug) gl.TexRect(-1, -1, 1, 1) --gl.PopMatrix() if saveDebug then - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() gl.SaveImage(0, 0, 3, 3, string.format("envLut_%s.png", gf)) end gl.Blending(true) diff --git a/luarules/gadgets/include/LuaShader.lua b/luarules/gadgets/include/LuaShader.lua index efe87edee87..e39ffb5ef90 100644 --- a/luarules/gadgets/include/LuaShader.lua +++ b/luarules/gadgets/include/LuaShader.lua @@ -4,7 +4,7 @@ if not LuaShaderNewLocationMessageShown then local info = dest and dest.GetInfo() local name = info and info.name or "unknown" local msg = "A user widget (" .. name .. ") is including LuaRules/Gadgets/Include/LuaShader.lua directly, please change it to use gl.LuaShader instead." - Spring.Log("UserWidget", LOG.DEPRECATED, msg) + SpringShared.Log("UserWidget", LOG.DEPRECATED, msg) LuaShaderNewLocationMessageShown = true end diff --git a/luarules/gadgets/include/SpawnerEnemyLib.lua b/luarules/gadgets/include/SpawnerEnemyLib.lua index 2e9647c72c9..7abb6ad0d5c 100644 --- a/luarules/gadgets/include/SpawnerEnemyLib.lua +++ b/luarules/gadgets/include/SpawnerEnemyLib.lua @@ -22,7 +22,7 @@ local adjustStartBox = function(startBoxXMin, startBoxZMin, startBoxXMax, startB end EnemyLib.GetAdjustedStartBox = function(enemyAllyTeamID, spread) - local startBoxXMin, startBoxZMin, startBoxXMax, startBoxZMax = Spring.GetAllyTeamStartBox(enemyAllyTeamID) + local startBoxXMin, startBoxZMin, startBoxXMax, startBoxZMax = SpringShared.GetAllyTeamStartBox(enemyAllyTeamID) if startBoxXMin and startBoxZMin and startBoxXMax and startBoxZMax then startBoxXMin, startBoxZMin, startBoxXMax, startBoxZMax = adjustStartBox(startBoxXMin, startBoxZMin, startBoxXMax, startBoxZMax, spread) end diff --git a/luarules/gadgets/include/startbox_utilities.lua b/luarules/gadgets/include/startbox_utilities.lua index 35c870db26d..37fef1a548a 100644 --- a/luarules/gadgets/include/startbox_utilities.lua +++ b/luarules/gadgets/include/startbox_utilities.lua @@ -47,7 +47,7 @@ local function ParseBoxes() startBoxConfig = WrappedInclude(mapsideBoxes) else startBoxConfig = {} - local startboxString = Spring.GetModOptions().startboxes + local startboxString = SpringShared.GetModOptions().startboxes local startboxStringLoadedBoxes = false if startboxString then local springieBoxes = loadstring(startboxString)() diff --git a/luarules/gadgets/map_atmosphere_cegs.lua b/luarules/gadgets/map_atmosphere_cegs.lua index aaccaaddb8b..f36938d6172 100644 --- a/luarules/gadgets/map_atmosphere_cegs.lua +++ b/luarules/gadgets/map_atmosphere_cegs.lua @@ -1,5 +1,5 @@ -if not Spring.GetModOptions().map_atmosphere then +if not SpringShared.GetModOptions().map_atmosphere then return end @@ -17,7 +17,7 @@ function gadget:GetInfo() } end -local enableGenericConfig = Spring.GetModOptions().mapatmospherics or "enabled" +local enableGenericConfig = SpringShared.GetModOptions().mapatmospherics or "enabled" --if VFS.FileExists("luarules/configs/Atmosphereconfigs/" .. Game.mapName .. ".lua") then --elseif enableGenericConfig ~= "disabled" then @@ -26,16 +26,16 @@ local enableGenericConfig = Spring.GetModOptions().mapatmospherics or "enabled" local currentMapname = Game.mapName:lower() local mapList = VFS.DirList("luarules/configs/Atmosphereconfigs/", "*.lua") -Spring.Echo("[ATMOSPHERIC] Current map: " .. currentMapname) +SpringShared.Echo("[ATMOSPHERIC] Current map: " .. currentMapname) local mapFileName = "" -- (Include at bottom of this file) for i = 1, #mapList + 1 do if i == #mapList + 1 then - Spring.Echo("[ATMOSPHERIC] No map config found. Turning off the gadget") + SpringShared.Echo("[ATMOSPHERIC] No map config found. Turning off the gadget") return end mapFileName = string.sub(mapList[i], 36, string.len(mapList[i]) - 4):lower() if string.find(currentMapname, mapFileName) then - Spring.Echo("[ATMOSPHERIC] Success! Map names match!: " .. mapFileName) + SpringShared.Echo("[ATMOSPHERIC] Success! Map names match!: " .. mapFileName) break else --Spring.Echo("[ATMOSPHERIC] Map names don't match: " ..mapFileName) @@ -92,13 +92,13 @@ if not gadgetHandler:IsSyncedCode() then local function SetLightingAndAtmosphere(lightandatmos) if lightandatmos.atmosphere then - Spring.SetAtmosphere(lightandatmos.atmosphere) + SpringUnsynced.SetAtmosphere(lightandatmos.atmosphere) end if lightandatmos.lighting then - Spring.SetSunLighting(lightandatmos.lighting) + SpringUnsynced.SetSunLighting(lightandatmos.lighting) end if lightandatmos.sunDir then - Spring.SetSunDirection(lightandatmos.sunDir[1], lightandatmos.sunDir[2], lightandatmos.sunDir[3]) + SpringUnsynced.SetSunDirection(lightandatmos.sunDir[1], lightandatmos.sunDir[2], lightandatmos.sunDir[3]) end end @@ -306,19 +306,19 @@ if not gadgetHandler:IsSyncedCode() then end - Spring.SetSunLighting({ groundAmbientColor = { transitionred * gar, transitiongreen * gag, transitionblue * gab } }) - Spring.SetSunLighting({ unitAmbientColor = { transitionred * uar, transitiongreen * uag, transitionblue * uab } }) - Spring.SetSunLighting({ groundDiffuseColor = { transitionred * gdr, transitiongreen * gdg, transitionblue * gdb } }) - Spring.SetSunLighting({ unitDiffuseColor = { transitionred * udr, transitiongreen * udg, transitionblue * udb } }) - Spring.SetSunLighting({ groundSpecularColor = { transitionred * gsr, transitiongreen * gsg, transitionblue * gsb } }) - Spring.SetSunLighting({ unitSpecularColor = { transitionred * usr, transitiongreen * usg, transitionblue * usb } }) + SpringUnsynced.SetSunLighting({ groundAmbientColor = { transitionred * gar, transitiongreen * gag, transitionblue * gab } }) + SpringUnsynced.SetSunLighting({ unitAmbientColor = { transitionred * uar, transitiongreen * uag, transitionblue * uab } }) + SpringUnsynced.SetSunLighting({ groundDiffuseColor = { transitionred * gdr, transitiongreen * gdg, transitionblue * gdb } }) + SpringUnsynced.SetSunLighting({ unitDiffuseColor = { transitionred * udr, transitiongreen * udg, transitionblue * udb } }) + SpringUnsynced.SetSunLighting({ groundSpecularColor = { transitionred * gsr, transitiongreen * gsg, transitionblue * gsb } }) + SpringUnsynced.SetSunLighting({ unitSpecularColor = { transitionred * usr, transitiongreen * usg, transitionblue * usb } }) - Spring.SetAtmosphere({ skyColor = { transitionred * skycr, transitiongreen * skycg, transitionblue * skycb } }) - Spring.SetAtmosphere({ sunColor = { transitionred * suncr, transitiongreen * suncg, transitionblue * suncb } }) - Spring.SetAtmosphere({ cloudColor = { transitionred * clocr, transitiongreen * clocg, transitionblue * clocb } }) - Spring.SetAtmosphere({ fogColor = { transitionred * fogcr, transitiongreen * fogcg, transitionblue * fogcb } }) + SpringUnsynced.SetAtmosphere({ skyColor = { transitionred * skycr, transitiongreen * skycg, transitionblue * skycb } }) + SpringUnsynced.SetAtmosphere({ sunColor = { transitionred * suncr, transitiongreen * suncg, transitionblue * suncb } }) + SpringUnsynced.SetAtmosphere({ cloudColor = { transitionred * clocr, transitiongreen * clocg, transitionblue * clocb } }) + SpringUnsynced.SetAtmosphere({ fogColor = { transitionred * fogcr, transitiongreen * fogcg, transitionblue * fogcb } }) - Spring.SetSunLighting({ groundShadowDensity = transition * shadowdensity, modelShadowDensity = transition * shadowdensity }) + SpringUnsynced.SetSunLighting({ groundShadowDensity = transition * shadowdensity, modelShadowDensity = transition * shadowdensity }) end local function MapAtmosphereConfigSetFog(_, targetstart, targetend, transitionspeedstart, transitionspeedend) @@ -343,13 +343,13 @@ if not gadgetHandler:IsSyncedCode() then transitionend = transitionend - transitionspeedpercentedend end - Spring.SetAtmosphere({ fogStart = transitionstart * fogstartdefault }) - Spring.SetAtmosphere({ fogEnd = transitionend * fogenddefault }) + SpringUnsynced.SetAtmosphere({ fogStart = transitionstart * fogstartdefault }) + SpringUnsynced.SetAtmosphere({ fogEnd = transitionend * fogenddefault }) end function gadget:TextCommand(msg) if string.sub(msg, 1, 18) == "atmosplaysoundfile" then - Spring.PlaySoundFile(string.sub(msg, 20), 0.85, "ui") + SpringUnsynced.PlaySoundFile(string.sub(msg, 20), 0.85, "ui") end end @@ -378,8 +378,8 @@ else mapsizeZ = Game.mapSizeZ local math_random = math.random - local spSpawnCEG = Spring.SpawnCEG - local spGetGroundHeight = Spring.GetGroundHeight + local spSpawnCEG = SpringSynced.SpawnCEG + local spGetGroundHeight = SpringShared.GetGroundHeight function AtmosSendMessage(_, msg) if Script.LuaUI("GadgetAddMessage") then @@ -388,24 +388,24 @@ else end function AtmosSendVoiceMessage(filedirectory) - Spring.SendCommands("atmosplaysoundfile " .. filedirectory) + SpringUnsynced.SendCommands("atmosplaysoundfile " .. filedirectory) end function SpawnCEGInPosition(cegname, posx, posy, posz, damage, paralyzetime, damageradius, sound, soundvolume) spSpawnCEG(cegname, posx, posy, posz) if sound then - Spring.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") + SpringUnsynced.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") end if damage or paralyzetime then - local units = Spring.GetUnitsInCylinder(posx, posz, damageradius) + local units = SpringShared.GetUnitsInCylinder(posx, posz, damageradius) for i = 1, #units do - local uhealth, umaxhealth, uparalyze = Spring.GetUnitHealth(units[i]) + local uhealth, umaxhealth, uparalyze = SpringShared.GetUnitHealth(units[i]) if damage then --Spring.Echo("Damaged") if uhealth > damage then - Spring.SetUnitHealth(units[i], uhealth - damage) + SpringSynced.SetUnitHealth(units[i], uhealth - damage) else - Spring.DestroyUnit(units[i]) + SpringSynced.DestroyUnit(units[i]) end end if paralyzetime then @@ -413,10 +413,10 @@ else local paralyzemult = paralyzetime * 0.025 if uparalyze <= umaxhealth then local paralyzedamage = (umaxhealth - uparalyze) + (umaxhealth * paralyzemult) - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) else local paralyzedamage = (umaxhealth * paralyzemult) + uparalyze - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) end end end @@ -427,18 +427,18 @@ else local posy = spGetGroundHeight(posx, posz) + (groundOffset or 0) spSpawnCEG(cegname, posx, posy, posz) if sound then - Spring.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") + SpringUnsynced.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") end if damage or paralyzetime then - local units = Spring.GetUnitsInCylinder(posx, posz, damageradius) + local units = SpringShared.GetUnitsInCylinder(posx, posz, damageradius) for i = 1, #units do - local uhealth, umaxhealth, uparalyze = Spring.GetUnitHealth(units[i]) + local uhealth, umaxhealth, uparalyze = SpringShared.GetUnitHealth(units[i]) if damage then --Spring.Echo("Damaged") if uhealth > damage then - Spring.SetUnitHealth(units[i], uhealth - damage) + SpringSynced.SetUnitHealth(units[i], uhealth - damage) else - Spring.DestroyUnit(units[i]) + SpringSynced.DestroyUnit(units[i]) end end if paralyzetime then @@ -446,10 +446,10 @@ else local paralyzemult = paralyzetime * 0.025 if uparalyze <= umaxhealth then local paralyzedamage = (umaxhealth - uparalyze) + (umaxhealth * paralyzemult) - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) else local paralyzedamage = (umaxhealth * paralyzemult) + uparalyze - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) end end end @@ -461,18 +461,18 @@ else local posz = midposz + math_random(-radius, radius) spSpawnCEG(cegname, posx, posy, posz) if sound then - Spring.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") + SpringUnsynced.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") end if damage or paralyzetime then - local units = Spring.GetUnitsInCylinder(posx, posz, damageradius) + local units = SpringShared.GetUnitsInCylinder(posx, posz, damageradius) for i = 1, #units do - local uhealth, umaxhealth, uparalyze = Spring.GetUnitHealth(units[i]) + local uhealth, umaxhealth, uparalyze = SpringShared.GetUnitHealth(units[i]) if damage then --Spring.Echo("Damaged") if uhealth > damage then - Spring.SetUnitHealth(units[i], uhealth - damage) + SpringSynced.SetUnitHealth(units[i], uhealth - damage) else - Spring.DestroyUnit(units[i]) + SpringSynced.DestroyUnit(units[i]) end end if paralyzetime then @@ -480,10 +480,10 @@ else local paralyzemult = paralyzetime * 0.025 if uparalyze <= umaxhealth then local paralyzedamage = (umaxhealth - uparalyze) + (umaxhealth * paralyzemult) - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) else local paralyzedamage = (umaxhealth * paralyzemult) + uparalyze - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) end end end @@ -496,18 +496,18 @@ else local posy = spGetGroundHeight(posx, posz) + (groundOffset or 0) spSpawnCEG(cegname, posx, posy, posz) if sound then - Spring.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") + SpringUnsynced.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") end if damage or paralyzetime then - local units = Spring.GetUnitsInCylinder(posx, posz, damageradius) + local units = SpringShared.GetUnitsInCylinder(posx, posz, damageradius) for i = 1, #units do - local uhealth, umaxhealth, uparalyze = Spring.GetUnitHealth(units[i]) + local uhealth, umaxhealth, uparalyze = SpringShared.GetUnitHealth(units[i]) if damage then --Spring.Echo("Damaged") if uhealth > damage then - Spring.SetUnitHealth(units[i], uhealth - damage) + SpringSynced.SetUnitHealth(units[i], uhealth - damage) else - Spring.DestroyUnit(units[i]) + SpringSynced.DestroyUnit(units[i]) end end if paralyzetime then @@ -515,10 +515,10 @@ else local paralyzemult = paralyzetime * 0.025 if uparalyze <= umaxhealth then local paralyzedamage = (umaxhealth - uparalyze) + (umaxhealth * paralyzemult) - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) else local paralyzedamage = (umaxhealth * paralyzemult) + uparalyze - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) end end end @@ -531,18 +531,18 @@ else local posy = spGetGroundHeight(posx, posz) + (groundOffset or 0) spSpawnCEG(cegname, posx, posy, posz) if sound then - Spring.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") + SpringUnsynced.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") end if damage or paralyzetime then - local units = Spring.GetUnitsInCylinder(posx, posz, damageradius) + local units = SpringShared.GetUnitsInCylinder(posx, posz, damageradius) for i = 1, #units do - local uhealth, umaxhealth, uparalyze = Spring.GetUnitHealth(units[i]) + local uhealth, umaxhealth, uparalyze = SpringShared.GetUnitHealth(units[i]) if damage then --Spring.Echo("Damaged") if uhealth > damage then - Spring.SetUnitHealth(units[i], uhealth - damage) + SpringSynced.SetUnitHealth(units[i], uhealth - damage) else - Spring.DestroyUnit(units[i]) + SpringSynced.DestroyUnit(units[i]) end end if paralyzetime then @@ -550,10 +550,10 @@ else local paralyzemult = paralyzetime * 0.025 if uparalyze <= umaxhealth then local paralyzedamage = (umaxhealth - uparalyze) + (umaxhealth * paralyzemult) - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) else local paralyzedamage = (umaxhealth * paralyzemult) + uparalyze - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) end end end @@ -565,11 +565,11 @@ else local posx = math_random(0, mapsizeX) local posz = math_random(0, mapsizeZ) local posy = spGetGroundHeight(posx, posz) + (groundOffset or 0) - local units = Spring.GetUnitsInCylinder(posx, posz, radius) + local units = SpringShared.GetUnitsInCylinder(posx, posz, radius) if #units == 0 then spSpawnCEG(cegname, posx, posy, posz) if sound then - Spring.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") + SpringUnsynced.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") end break end @@ -585,7 +585,7 @@ else if groundposy <= spawnOnlyBelowY then spSpawnCEG(cegname, posx, posy, posz) if sound then - Spring.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") + SpringUnsynced.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") end break end @@ -593,15 +593,15 @@ else if damage or paralyzetime then local posx = math_random(0, mapsizeX) local posz = math_random(0, mapsizeZ) - local units = Spring.GetUnitsInCylinder(posx, posz, damageradius) + local units = SpringShared.GetUnitsInCylinder(posx, posz, damageradius) for i = 1, #units do - local uhealth, umaxhealth, uparalyze = Spring.GetUnitHealth(units[i]) + local uhealth, umaxhealth, uparalyze = SpringShared.GetUnitHealth(units[i]) if damage then --Spring.Echo("Damaged") if uhealth > damage then - Spring.SetUnitHealth(units[i], uhealth - damage) + SpringSynced.SetUnitHealth(units[i], uhealth - damage) else - Spring.DestroyUnit(units[i]) + SpringSynced.DestroyUnit(units[i]) end end if paralyzetime then @@ -609,10 +609,10 @@ else local paralyzemult = paralyzetime * 0.025 if uparalyze <= umaxhealth then local paralyzedamage = (umaxhealth - uparalyze) + (umaxhealth * paralyzemult) - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) else local paralyzedamage = (umaxhealth * paralyzemult) + uparalyze - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) end end end @@ -624,18 +624,18 @@ else local posz = math_random(0, mapsizeZ) spSpawnCEG(cegname, posx, posy, posz) if sound then - Spring.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") + SpringUnsynced.PlaySoundFile(sound, soundvolume, posx, posy, posz, "sfx") end if damage or paralyzetime then - local units = Spring.GetUnitsInCylinder(posx, posz, damageradius) + local units = SpringShared.GetUnitsInCylinder(posx, posz, damageradius) for i = 1, #units do - local uhealth, umaxhealth, uparalyze = Spring.GetUnitHealth(units[i]) + local uhealth, umaxhealth, uparalyze = SpringShared.GetUnitHealth(units[i]) if damage then --Spring.Echo("Damaged") if uhealth > damage then - Spring.SetUnitHealth(units[i], uhealth - damage) + SpringSynced.SetUnitHealth(units[i], uhealth - damage) else - Spring.DestroyUnit(units[i]) + SpringSynced.DestroyUnit(units[i]) end end if paralyzetime then @@ -643,10 +643,10 @@ else local paralyzemult = paralyzetime * 0.025 if uparalyze <= umaxhealth then local paralyzedamage = (umaxhealth - uparalyze) + (umaxhealth * paralyzemult) - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) else local paralyzedamage = (umaxhealth * paralyzemult) + uparalyze - Spring.SetUnitHealth(units[i], { paralyze = paralyzedamage }) + SpringSynced.SetUnitHealth(units[i], { paralyze = paralyzedamage }) end end end diff --git a/luarules/gadgets/map_explosion_deformation_fix.lua b/luarules/gadgets/map_explosion_deformation_fix.lua index 6cb9aa0b022..7c66b854fba 100644 --- a/luarules/gadgets/map_explosion_deformation_fix.lua +++ b/luarules/gadgets/map_explosion_deformation_fix.lua @@ -20,9 +20,9 @@ function gadget:UnitCreated(unitID, unitDefID) -- Terraform gadget already deals with structures restoring themselves to their original heights after -- explosions. Unlike engine restoration it does this with an infrequent poll, so hitting bewteen nuke -- crater and nuke damage is unlikely. - if Spring.ValidUnitID(unitID) then - local b1, b2, b3, b4, b5, b6, b7 = Spring.GetUnitBlocking(unitID) - Spring.SetUnitBlocking(unitID, b1, b2, b3, b4, b5, b6, false) + if SpringShared.ValidUnitID(unitID) then + local b1, b2, b3, b4, b5, b6, b7 = SpringShared.GetUnitBlocking(unitID) + SpringSynced.SetUnitBlocking(unitID, b1, b2, b3, b4, b5, b6, false) end end diff --git a/luarules/gadgets/map_geofix.lua b/luarules/gadgets/map_geofix.lua index 685c0d4351a..092604fd532 100644 --- a/luarules/gadgets/map_geofix.lua +++ b/luarules/gadgets/map_geofix.lua @@ -22,11 +22,11 @@ if gadgetHandler:IsSyncedCode() then geoFeatureDefs[defID] = true end end - local features = Spring.GetAllFeatures() + local features = SpringShared.GetAllFeatures() for i = 1, #features do - if geoFeatureDefs[Spring.GetFeatureDefID(features[i])] then - local x, y, z = Spring.GetFeaturePosition(features[i]) - Spring.SetFeaturePosition(features[i], x, Spring.GetGroundHeight(x, z), z, true) -- snaptoground = true + if geoFeatureDefs[SpringShared.GetFeatureDefID(features[i])] then + local x, y, z = SpringShared.GetFeaturePosition(features[i]) + SpringSynced.SetFeaturePosition(features[i], x, SpringShared.GetGroundHeight(x, z), z, true) -- snaptoground = true end end gadgetHandler:RemoveGadget(self) diff --git a/luarules/gadgets/map_lava.lua b/luarules/gadgets/map_lava.lua index 09dc39a5ffb..d626c59f508 100644 --- a/luarules/gadgets/map_lava.lua +++ b/luarules/gadgets/map_lava.lua @@ -45,18 +45,18 @@ if gadgetHandler:IsSyncedCode() then local lavaEffectDamage = lava.effectDamage -- speedups - local spAddUnitDamage = Spring.AddUnitDamage - local spAddFeatureDamage = Spring.AddFeatureDamage - local spGetAllUnits = Spring.GetAllUnits - local spGetFeatureDefID = Spring.GetFeatureDefID - local spGetFeaturePosition = Spring.GetFeaturePosition - local spGetUnitBasePosition = Spring.GetUnitBasePosition - local spGetUnitDefID = Spring.GetUnitDefID - local spGetMoveData = Spring.GetUnitMoveTypeData - local spMoveCtrlEnabled = Spring.MoveCtrl.IsEnabled - local spSetMoveData = Spring.MoveCtrl.SetGroundMoveTypeData - local spGetGroundHeight = Spring.GetGroundHeight - local spSpawnCEG = Spring.SpawnCEG + local spAddUnitDamage = SpringSynced.AddUnitDamage + local spAddFeatureDamage = SpringSynced.AddFeatureDamage + local spGetAllUnits = SpringShared.GetAllUnits + local spGetFeatureDefID = SpringShared.GetFeatureDefID + local spGetFeaturePosition = SpringShared.GetFeaturePosition + local spGetUnitBasePosition = SpringShared.GetUnitBasePosition + local spGetUnitDefID = SpringShared.GetUnitDefID + local spGetMoveData = SpringShared.GetUnitMoveTypeData + local spMoveCtrlEnabled = SpringSynced.MoveCtrl.IsEnabled + local spSetMoveData = SpringSynced.MoveCtrl.SetGroundMoveTypeData + local spGetGroundHeight = SpringShared.GetGroundHeight + local spSpawnCEG = SpringSynced.SpawnCEG local random = math.random local clamp = math.clamp @@ -75,7 +75,7 @@ if gadgetHandler:IsSyncedCode() then turnDefs[unitDefID] = unitDef.turnRate accDefs[unitDefID] = unitDef.maxAcc end - unitHeight[unitDefID] = Spring.GetUnitDefDimensions(unitDefID).height + unitHeight[unitDefID] = SpringShared.GetUnitDefDimensions(unitDefID).height end local geoThermal = {} for featureDefID, featureDef in pairs(FeatureDefs) do @@ -146,7 +146,7 @@ if gadgetHandler:IsSyncedCode() then -- slow down and damage unit+features in lava function lavaObjectsCheck() - local gaiaTeamID = Spring.GetGaiaTeamID() + local gaiaTeamID = SpringShared.GetGaiaTeamID() local all_units = spGetAllUnits() for _, unitID in ipairs(all_units) do local unitDefID = spGetUnitDefID(unitID) @@ -182,7 +182,7 @@ if gadgetHandler:IsSyncedCode() then end end if lavaDamageFeatures then - local all_features = Spring.GetAllFeatures() + local all_features = SpringShared.GetAllFeatures() for _, featureID in ipairs(all_features) do local FeatureDefID = spGetFeatureDefID(featureID) if not geoThermal[FeatureDefID] then @@ -201,10 +201,10 @@ if gadgetHandler:IsSyncedCode() then gadgetHandler:RemoveGadget(self) return end - minGroundHeight = select(3, Spring.GetGroundExtremes()) + minGroundHeight = select(3, SpringShared.GetGroundExtremes()) _G.lavaLevel = lavaLevel _G.lavaGrow = lavaGrow - Spring.SetGameRulesParam("lavaLevel", -99999) + SpringSynced.SetGameRulesParam("lavaLevel", -99999) end function gadget:GameFrame(f) @@ -214,7 +214,7 @@ if gadgetHandler:IsSyncedCode() then -- Periodically refresh cached min ground height (handles terraforming) if f % GROUND_EXTREMES_UPDATE_RATE == 0 then - minGroundHeight = select(3, Spring.GetGroundExtremes()) + minGroundHeight = select(3, SpringShared.GetGroundExtremes()) end local lavaAboveGround = lavaLevel >= minGroundHeight @@ -230,7 +230,7 @@ if gadgetHandler:IsSyncedCode() then updateLava() lavaLevel = lavaLevel + (lavaGrow / gameSpeed) - Spring.SetGameRulesParam("lavaLevel", lavaLevel) + SpringSynced.SetGameRulesParam("lavaLevel", lavaLevel) -- burst and sound effects (skip entirely when lava is below the map surface) if lavaAboveGround and f % 5 == 0 then @@ -249,7 +249,7 @@ if gadgetHandler:IsSyncedCode() then if lavaEffectBurstSounds and #lavaEffectBurstSounds > 0 then local soundIndex = random(1, #lavaEffectBurstSounds) local sound = lavaEffectBurstSounds[soundIndex] - Spring.PlaySoundFile(sound[1], random(sound[2], sound[3]) / 100, x, y, z, "sfx") + SpringUnsynced.PlaySoundFile(sound[1], random(sound[2], sound[3]) / 100, x, y, z, "sfx") end end end @@ -264,7 +264,7 @@ if gadgetHandler:IsSyncedCode() then if y < lavaLevel then local soundIndex = random(1, #lavaAmbientSounds) local sound = lavaAmbientSounds[soundIndex] - Spring.PlaySoundFile(sound[1], random(sound[2], sound[3]) / 100, x, y, z, "sfx") + SpringUnsynced.PlaySoundFile(sound[1], random(sound[2], sound[3]) / 100, x, y, z, "sfx") break end end @@ -326,7 +326,7 @@ else -- UNSYCNED local foglightenabled = lava.fogEnabled local fogheightabovelava = lava.fogHeight - local allowDeferredMapRendering = (Spring.GetConfigInt("AllowDeferredMapRendering") == 1) -- map depth buffer is required for the foglight shader pass + local allowDeferredMapRendering = (SpringUnsynced.GetConfigInt("AllowDeferredMapRendering") == 1) -- map depth buffer is required for the foglight shader pass local tideamplitude = lava.tideAmplitude local tideperiod = lava.tidePeriod @@ -418,7 +418,7 @@ else -- UNSYCNED local myPlayerID = tostring(Spring.GetMyPlayerID()) function gadget:GameFrame(f) if SYNCED.lavaLevel then - lavatidelevel = math.sin(Spring.GetGameFrame() / tideperiod) * tideamplitude + SYNCED.lavaLevel + lavatidelevel = math.sin(SpringShared.GetGameFrame() / tideperiod) * tideamplitude + SYNCED.lavaLevel end if SYNCED.lavaGrow then local lavaGrow = SYNCED.lavaGrow @@ -451,7 +451,7 @@ else -- UNSYCNED return end - Spring.SetDrawWater(false) + SpringUnsynced.SetDrawWater(false) -- Now for all intents and purposes, we kinda need to make a lava plane that is 3x the rez of our map -- If, e.g our map size is 16x16, we will have 1024 heightmap. If we make a 128 size vbo, then what? @@ -467,7 +467,7 @@ else -- UNSYCNED lavaShader = LuaShader.CheckShaderUpdates(lavaShaderSourceCache) if not lavaShader then - Spring.Echo("Failed to compile Lava Shader") + SpringShared.Echo("Failed to compile Lava Shader") gadgetHandler:RemoveGadget() return end @@ -475,7 +475,7 @@ else -- UNSYCNED foglightShader = LuaShader.CheckShaderUpdates(fogLightShaderSourceCache) if not foglightShader then - Spring.Echo("Failed to compile foglightShader") + SpringShared.Echo("Failed to compile foglightShader") gadgetHandler:RemoveGadget() return end @@ -483,11 +483,11 @@ else -- UNSYCNED function gadget:DrawWorldPreUnit() if lavatidelevel then - local _, gameSpeed, isPaused = Spring.GetGameSpeed() + local _, gameSpeed, isPaused = SpringUnsynced.GetGameSpeed() if not isPaused then - local camX, camY, camZ = Spring.GetCameraDirection() + local camX, camY, camZ = SpringUnsynced.GetCameraDirection() local camvlength = math.sqrt(camX * camX + camZ * camZ + 0.01) - smoothFPS = 0.9 * smoothFPS + 0.1 * math.max(Spring.GetFPS(), 15) + smoothFPS = 0.9 * smoothFPS + 0.1 * math.max(SpringUnsynced.GetFPS(), 15) heatdistortx = heatdistortx - camX / (camvlength * smoothFPS) heatdistortz = heatdistortz - camZ / (camvlength * smoothFPS) end @@ -564,7 +564,7 @@ else -- UNSYCNED end function gadget:Shutdown() - Spring.SetDrawWater(true) + SpringUnsynced.SetDrawWater(true) end end --ende unsync diff --git a/luarules/gadgets/map_metal_spot_placer.lua b/luarules/gadgets/map_metal_spot_placer.lua index f8e639a3709..bab584808dd 100644 --- a/luarules/gadgets/map_metal_spot_placer.lua +++ b/luarules/gadgets/map_metal_spot_placer.lua @@ -37,7 +37,7 @@ function gadget:Initialize() local hasMetalmap = false for x = 1, MAP_SIZE_X / 4 do for z = 1, MAP_SIZE_Z / 4 do - if select(3, Spring.GetGroundInfo(x * 4, z * 4)) > 0 then + if select(3, SpringShared.GetGroundInfo(x * 4, z * 4)) > 0 then hasMetalmap = true break end @@ -47,9 +47,9 @@ function gadget:Initialize() end end - if not hasMetalmap and mapConfig and Spring.GetGameFrame() == 0 then + if not hasMetalmap and mapConfig and SpringShared.GetGameFrame() == 0 then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Loading map-side lua metal spot configuration...") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Loading map-side lua metal spot configuration...") local spots = mapConfig.spots local metalFactor = 0.43 * 9 / 21 @@ -79,7 +79,7 @@ function gadget:Initialize() zi = zIndex + dzi if xi > 0 and xi < MAP_SIZE_X_SCALED and zi > 0 and zi < MAP_SIZE_Z_SCALED then - Spring.SetMetalAmount(xi, zi, metal * metalFactor * 255) + SpringShared.SetMetalAmount(xi, zi, metal * metalFactor * 255) end end end diff --git a/luarules/gadgets/map_nightmode.lua b/luarules/gadgets/map_nightmode.lua index fa779ab8a22..54f17ac79b1 100644 --- a/luarules/gadgets/map_nightmode.lua +++ b/luarules/gadgets/map_nightmode.lua @@ -111,16 +111,16 @@ if not gadgetHandler:IsSyncedCode() then end for _, s in ipairs({ "lighting", "atmosphere" }) do - Spring.Echo(s) + SpringShared.Echo(s) for k, v in pairs(l[s]) do if type(v) == "table" then - Spring.Echo(string.format(" %s = {%s},", k, quicktablestring(v))) + SpringShared.Echo(string.format(" %s = {%s},", k, quicktablestring(v))) else - Spring.Echo(string.format(" %s = %s,", k, tostring(v))) + SpringShared.Echo(string.format(" %s = %s,", k, tostring(v))) end end end - Spring.Echo("sunDir = " .. quicktablestring(l["sunDir"])) + SpringShared.Echo("sunDir = " .. quicktablestring(l["sunDir"])) end local function GetLightingAndAtmosphere() -- returns a table of the common parameters @@ -175,17 +175,17 @@ if not gadgetHandler:IsSyncedCode() then --if lightandatmos.water then Spring.SetWaterParams(lightandatmos.water) end if lightandatmos.lighting then - Spring.SetSunLighting(lightandatmos.lighting) + SpringUnsynced.SetSunLighting(lightandatmos.lighting) end if lightandatmos.sunDir then - Spring.SetSunDirection(lightandatmos.sunDir[1], lightandatmos.sunDir[2], lightandatmos.sunDir[3]) + SpringUnsynced.SetSunDirection(lightandatmos.sunDir[1], lightandatmos.sunDir[2], lightandatmos.sunDir[3]) end if lightandatmos.atmosphere then - Spring.SetAtmosphere(lightandatmos.atmosphere) + SpringUnsynced.SetAtmosphere(lightandatmos.atmosphere) end --if lightandatmos.lighting then Spring.SetSunLighting({groundShadowDensity = lightandatmos.lighting.groundShadowDensity}) end -- for some godforsaken reason, this needs to be set TWICE! if lightandatmos.lighting then - Spring.SetSunLighting({}) + SpringUnsynced.SetSunLighting({}) end -- for some godforsaken reason, this needs to be set TWICE! --gadgetHandler:SetGlobal("NightModeParams", {r=1, g=1, b=1, s=1, a= 1}) @@ -359,14 +359,14 @@ if not gadgetHandler:IsSyncedCode() then local function SetNightMode(cmd, line, words, playerID) -- line is the full line -- words is a table here, of each of the words AFTER /luarules NightMode a b c -> {a,b,c} - Spring.Echo("SetNightMode", cmd, line, words, playerID) + SpringShared.Echo("SetNightMode", cmd, line, words, playerID) if #words <= 1 then - Spring.Echo("Resetting Lighting") + SpringShared.Echo("Resetting Lighting") SetLightingAndAtmosphere(initial_atmosphere_lighting) return end - Spring.Echo("Expecting /luarules NightMode nightR nightG nightB azimuth altitude shadowfactor") + SpringShared.Echo("Expecting /luarules NightMode nightR nightG nightB azimuth altitude shadowfactor") local nightR = (words[1] and tonumber(words[1])) or 1 local nightG = (words[2] and tonumber(words[2])) or 1 local nightB = (words[3] and tonumber(words[3])) or 1 @@ -375,7 +375,7 @@ if not gadgetHandler:IsSyncedCode() then local shadowfactor = (words[6] and tonumber(words[6])) or 1 local newNightLight = GetNightLight(nil, { nightR, nightG, nightB, shadowfactor }, azimuth, altitude) - Spring.Echo(newNightLight) + SpringShared.Echo(newNightLight) -- If this command is recieved, immediately stop any existing nightModeConfig transitionenabled = false SetLightingAndAtmosphere(newNightLight) @@ -386,7 +386,7 @@ if not gadgetHandler:IsSyncedCode() then end local function PrintSun(cmd, line, words, playerID) - Spring.Echo("Current sun settings are") + SpringShared.Echo("Current sun settings are") local sun = GetLightingAndAtmosphere() EchoSun(sun) end @@ -433,7 +433,7 @@ if not gadgetHandler:IsSyncedCode() then local lastSunChanged = -1 function gadget:SunChanged() -- Note that map_nightmode.lua gadget has to change sun twice in a single draw frame to update all - local df = Spring.GetDrawFrame() + local df = SpringUnsynced.GetDrawFrame() if df == lastSunChanged then return end diff --git a/luarules/gadgets/map_sun_handler.lua b/luarules/gadgets/map_sun_handler.lua index 84ba20f2fec..9d062b4dd8c 100644 --- a/luarules/gadgets/map_sun_handler.lua +++ b/luarules/gadgets/map_sun_handler.lua @@ -25,11 +25,11 @@ end -------------------------------------------------------------------------------- function gadget:Initialize() - if (Spring.SetSunLighting ~= nil) and (gl.GetAtmosphere ~= nil) and (Spring.GetConfigInt("AdvMapShading", 1) == 1) then + if (SpringUnsynced.SetSunLighting ~= nil) and (gl.GetAtmosphere ~= nil) and (SpringUnsynced.GetConfigInt("AdvMapShading", 1) == 1) then local mapSpecR, mapSpecG, mapSpecB = gl.GetSun("specular") if (math.abs(mapSpecR - 0.1) + math.abs(mapSpecG - 0.1) + math.abs(mapSpecB - 0.1)) < 0.0001 then --default groundSpecularColor is (0.1, 0.1, 0.1) - Spring.Echo("Map Sun Handler: Clearing groundSpecularColor via SetSunLighting because map does not change it from default.") - Spring.SetSunLighting({ groundSpecularColor = { 0, 0, 0, 0 } }) + SpringShared.Echo("Map Sun Handler: Clearing groundSpecularColor via SetSunLighting because map does not change it from default.") + SpringUnsynced.SetSunLighting({ groundSpecularColor = { 0, 0, 0, 0 } }) end end gadgetHandler:RemoveGadget() diff --git a/luarules/gadgets/map_voidground.lua b/luarules/gadgets/map_voidground.lua index 32242a2ec9e..96fa00f685e 100644 --- a/luarules/gadgets/map_voidground.lua +++ b/luarules/gadgets/map_voidground.lua @@ -18,7 +18,7 @@ end local success, mapinfo = pcall(VFS.Include, "mapinfo.lua") -- load mapinfo.lua confs if not success or mapinfo == nil then - Spring.Echo("Map VoidWater failed to load the mapinfo.lua") + SpringShared.Echo("Map VoidWater failed to load the mapinfo.lua") return end @@ -36,15 +36,15 @@ for unitDefID, unitDef in pairs(UnitDefs) do end end -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetFeaturePosition = Spring.GetFeaturePosition +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetFeaturePosition = SpringShared.GetFeaturePosition local mapx = Game.mapSizeX local mapz = Game.mapSizeZ function gadget:FeatureCreated(featureID) if select(2, spGetFeaturePosition(featureID)) <= 1 then - Spring.DestroyFeature(featureID, false) + SpringSynced.DestroyFeature(featureID, false) end end @@ -52,13 +52,13 @@ end function gadget:GameFrame(gf) if gf % 49 == 1 then - local units = Spring.GetAllUnits() + local units = SpringShared.GetAllUnits() for k = 1, #units do local unitID = units[k] if isVoidGroundTarget[spGetUnitDefID(unitID)] then local x, y, z = spGetUnitPosition(unitID) if x ~= nil and (y < 0) and (x > 0 and x < mapx) and (z > 0 and z < mapz) then - Spring.DestroyUnit(unitID) + SpringSynced.DestroyUnit(unitID) end end end diff --git a/luarules/gadgets/map_waterlevel.lua b/luarules/gadgets/map_waterlevel.lua index 69332af04e2..6aff688526e 100644 --- a/luarules/gadgets/map_waterlevel.lua +++ b/luarules/gadgets/map_waterlevel.lua @@ -21,35 +21,35 @@ local PACKET_HEADER_LENGTH = string.len(PACKET_HEADER) if gadgetHandler:IsSyncedCode() then - local waterlevel = Spring.GetModOptions().map_waterlevel + local waterlevel = SpringShared.GetModOptions().map_waterlevel function adjustFeatureHeight() - local featuretable = Spring.GetAllFeatures() + local featuretable = SpringShared.GetAllFeatures() local x, y, z for i = 1, #featuretable do - x, y, z = Spring.GetFeaturePosition(featuretable[i]) - Spring.SetFeaturePosition(featuretable[i], x, y, z, true) -- snaptoground = true + x, y, z = SpringShared.GetFeaturePosition(featuretable[i]) + SpringSynced.SetFeaturePosition(featuretable[i], x, y, z, true) -- snaptoground = true end end function adjustWaterlevel() -- Spring.SetMapRenderingParams({ voidWater = false}) - Spring.Echo("Map Waterlevel: adjusting water level with: " .. waterlevel) - Spring.AdjustHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, -waterlevel) - Spring.AdjustOriginalHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, -waterlevel) - Spring.AdjustSmoothMesh(0, 0, Game.mapSizeX, Game.mapSizeZ, -waterlevel) + SpringShared.Echo("Map Waterlevel: adjusting water level with: " .. waterlevel) + SpringSynced.AdjustHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, -waterlevel) + SpringSynced.AdjustOriginalHeightMap(0, 0, Game.mapSizeX, Game.mapSizeZ, -waterlevel) + SpringSynced.AdjustSmoothMesh(0, 0, Game.mapSizeX, Game.mapSizeZ, -waterlevel) adjustFeatureHeight() end function gadget:Initialize() - if Spring.GetGameFrame() == 0 then - local modOptions = Spring.GetModOptions() + if SpringShared.GetGameFrame() == 0 then + local modOptions = SpringShared.GetModOptions() if modOptions.map_waterlevel ~= 0 then waterlevel = modOptions.map_waterlevel -- adjust tidal strength if previosuly not present and applicable - if (modOptions.map_tidal == nil or modOptions.map_tidal == "unchanged") and Spring.GetTidal() == 0 and select(1, Spring.GetGroundExtremes()) > 0 then - Spring.SetTidal(15) + if (modOptions.map_tidal == nil or modOptions.map_tidal == "unchanged") and SpringShared.GetTidal() == 0 and select(1, SpringShared.GetGroundExtremes()) > 0 then + SpringSynced.SetTidal(15) end adjustWaterlevel() @@ -77,14 +77,14 @@ if gadgetHandler:IsSyncedCode() then local accountID = Spring.Utilities.GetAccountID(playerID) local authorized = _G.permissions.waterlevel[accountID] - if not (authorized or Spring.IsCheatingEnabled()) then + if not (authorized or SpringShared.IsCheatingEnabled()) then return end local params = string.split(msg, ":") waterlevel = tonumber(params[2]) adjustWaterlevel() - Spring.Echo("Changed waterlevel: " .. waterlevel) + SpringShared.Echo("Changed waterlevel: " .. waterlevel) end else -- UNSYNCED @@ -95,8 +95,8 @@ else -- UNSYNCED local function waterlevel(cmd, line, words, playerID) if words[1] then - if (authorized or Spring.IsCheatingEnabled()) and playerID == myPlayerID then - Spring.SendLuaRulesMsg(PACKET_HEADER .. ":" .. words[1]) + if (authorized or SpringShared.IsCheatingEnabled()) and playerID == myPlayerID then + SpringUnsynced.SendLuaRulesMsg(PACKET_HEADER .. ":" .. words[1]) end end end diff --git a/luarules/gadgets/mo_battle_royale.lua b/luarules/gadgets/mo_battle_royale.lua index e3ed0c43885..b4b5c02601b 100644 --- a/luarules/gadgets/mo_battle_royale.lua +++ b/luarules/gadgets/mo_battle_royale.lua @@ -33,10 +33,10 @@ end ]] -- -- in minutes -local starttime = tonumber(Spring.GetModOptions().battle_royale_starttime) or -1 +local starttime = tonumber(SpringShared.GetModOptions().battle_royale_starttime) or -1 -- in minutes, hopefully never less than the commander's walk rate -local shrinktime = tonumber(Spring.GetModOptions().battle_royale_shrinktime) or 5 +local shrinktime = tonumber(SpringShared.GetModOptions().battle_royale_shrinktime) or 5 if starttime <= 0 then return false @@ -56,7 +56,7 @@ if gadgetHandler:IsSyncedCode() then end local function BattleRoyaleDebug() - Spring.Echo("Battle Royale reset to", startradius / 2) + SpringShared.Echo("Battle Royale reset to", startradius / 2) radius = startradius / 2 end @@ -76,10 +76,10 @@ if gadgetHandler:IsSyncedCode() then radius = math.max(radius, 0) radiussquared = radius * radius if gameFrame % 11 == 0 then - local allunits = Spring.GetAllUnits() + local allunits = SpringShared.GetAllUnits() local numdestroyed = 0 for _, unitID in ipairs(allunits) do - local ux, uy, uz = Spring.GetUnitPosition(unitID) + local ux, uy, uz = SpringShared.GetUnitPosition(unitID) if ux and distsqrgreater(ux - mapCenterX, uz - mapCenterZ, radiussquared) then --Spring.DestroyUnit(unitID, true, false) numdestroyed = numdestroyed + 1 @@ -112,7 +112,7 @@ else local hextexture = "LuaUI/Images/hexgrid.tga" local function goodbye(reason) - Spring.Echo("Ground Circle GL4 widget exiting with reason: " .. reason) + SpringShared.Echo("Ground Circle GL4 widget exiting with reason: " .. reason) if circleShader then circleShader:Finalize() end @@ -238,7 +238,7 @@ else local battleroyaleradius = -1 local function BattleRoyaleRadius(_, radius) if battleroyaleradius == -1 then - Spring.SendMessage("Battle Royale has begun, you have " .. tostring(shrinktime) .. " minutes left") + SpringUnsynced.SendMessage("Battle Royale has begun, you have " .. tostring(shrinktime) .. " minutes left") end battleroyaleradius = radius pushElementInstance( @@ -252,7 +252,7 @@ else local function BattleRoyaleDebug() end function gadget:Initialize() - minY, maxY = Spring.GetGroundExtremes() + minY, maxY = SpringShared.GetGroundExtremes() gadgetHandler:AddSyncAction("BattleRoyaleRadius", BattleRoyaleRadius) initgl4() end diff --git a/luarules/gadgets/mo_com_counter.lua b/luarules/gadgets/mo_com_counter.lua index d1f9416389a..861980aa4d9 100644 --- a/luarules/gadgets/mo_com_counter.lua +++ b/luarules/gadgets/mo_com_counter.lua @@ -16,7 +16,7 @@ if not gadgetHandler:IsSyncedCode() then return false end -local spSetTeamRulesParam = Spring.SetTeamRulesParam +local spSetTeamRulesParam = SpringSynced.SetTeamRulesParam local isCommander = {} for unitDefID, unitDef in pairs(UnitDefs) do @@ -27,12 +27,12 @@ end local teamComs = {} local teamAllyTeam = {} -local teamList = Spring.GetTeamList() +local teamList = SpringShared.GetTeamList() for _, teamID in pairs(teamList) do - teamAllyTeam[teamID] = select(6, Spring.GetTeamInfo(teamID, false)) + teamAllyTeam[teamID] = select(6, SpringShared.GetTeamInfo(teamID, false)) local newCount = 0 for unitDefID, _ in pairs(isCommander) do - newCount = newCount + Spring.GetTeamUnitDefCount(teamID, unitDefID) + newCount = newCount + SpringShared.GetTeamUnitDefCount(teamID, unitDefID) end teamComs[teamID] = newCount end diff --git a/luarules/gadgets/mo_coop_II.lua b/luarules/gadgets/mo_coop_II.lua index f7b682a298f..03bcaa92d41 100644 --- a/luarules/gadgets/mo_coop_II.lua +++ b/luarules/gadgets/mo_coop_II.lua @@ -14,7 +14,7 @@ function gadget:GetInfo() end -- Modoption check -if not Spring.GetModOptions().coop then +if not SpringShared.GetModOptions().coop then return false end @@ -42,10 +42,10 @@ if gadgetHandler:IsSyncedCode() then do local coopHasEffect = false local teamHasPlayers = {} - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for i = 1, #playerList do local playerID = playerList[i] - local _, _, isSpec, teamID = Spring.GetPlayerInfo(playerID, false) + local _, _, isSpec, teamID = SpringShared.GetPlayerInfo(playerID, false) if not isSpec then if teamHasPlayers[teamID] then SetCoopStartPoint(playerID, -1, -1, -1) @@ -80,14 +80,14 @@ if gadgetHandler:IsSyncedCode() then -- his coop buddy readies up after, then the first will have his start point overwritten by the second. -- This can be prevented by not allowing the first to place on second, either. - local _, _, _, teamID, allyID = Spring.GetPlayerInfo(playerID, false) - local osx, _, osz = Spring.GetTeamStartPosition(teamID) + local _, _, _, teamID, allyID = SpringShared.GetPlayerInfo(playerID, false) + local osx, _, osz = SpringShared.GetTeamStartPosition(teamID) if x ~= osx or z ~= osz then - local xmin, zmin, xmax, zmax = Spring.GetAllyTeamStartBox(allyID) + local xmin, zmin, xmax, zmax = SpringShared.GetAllyTeamStartBox(allyID) x = math.clamp(x, xmin, xmax) z = math.clamp(z, zmin, zmax) - SetCoopStartPoint(playerID, x, Spring.GetGroundHeight(x, z), z) -- record coop start point, display it + SetCoopStartPoint(playerID, x, SpringShared.GetGroundHeight(x, z), z) -- record coop start point, display it return false end end @@ -100,20 +100,20 @@ if gadgetHandler:IsSyncedCode() then local mtta = math.acos(1.0 - 0.41221) - 0.02 -- http://springrts.com/wiki/Movedefs.lua#How_slope_is_determined & the -0.02 is for safety local a1, a2, a3, a4 = 0, 0, 0, 0 local d = 5 - local y = Spring.GetGroundHeight(x, z) - local y1 = Spring.GetGroundHeight(x + d, z) + local y = SpringShared.GetGroundHeight(x, z) + local y1 = SpringShared.GetGroundHeight(x + d, z) if math.abs(y1 - y) > 0.1 then a1 = math.atan((y1 - y) / d) end - local y2 = Spring.GetGroundHeight(x, z + d) + local y2 = SpringShared.GetGroundHeight(x, z + d) if math.abs(y2 - y) > 0.1 then a2 = math.atan((y2 - y) / d) end - local y3 = Spring.GetGroundHeight(x - d, z) + local y3 = SpringShared.GetGroundHeight(x - d, z) if math.abs(y3 - y) > 0.1 then a3 = math.atan((y3 - y) / d) end - local y4 = Spring.GetGroundHeight(x, z + d) + local y4 = SpringShared.GetGroundHeight(x, z + d) if math.abs(y4 - y) > 0.1 then a4 = math.atan((y4 - y) / d) end @@ -125,7 +125,7 @@ if gadgetHandler:IsSyncedCode() then end local function SpawnTeamStartUnit(playerID, teamID, allyID, x, z) - local startUnit = Spring.GetTeamRulesParam(teamID, "startUnit") + local startUnit = SpringShared.GetTeamRulesParam(teamID, "startUnit") if GG.playerStartingUnits then --use that player specific start unit if available startUnit = GG.playerStartingUnits[playerID] or startUnit end @@ -136,13 +136,13 @@ if gadgetHandler:IsSyncedCode() then else startUnit = armcomDefID end - if Spring.GetModOptions().experimentallegionfaction and math.random() > 0.33 then + if SpringShared.GetModOptions().experimentallegionfaction and math.random() > 0.33 then startUnit = legcomDefID end end if x <= 0 or z <= 0 then --TODO: improve this - local xmin, zmin, xmax, zmax = Spring.GetAllyTeamStartBox(allyID) + local xmin, zmin, xmax, zmax = SpringShared.GetAllyTeamStartBox(allyID) local tx, tz if GG.teamStartPoints then tx = GG.teamStartPoints[teamID][1] @@ -167,18 +167,18 @@ if gadgetHandler:IsSyncedCode() then end -- create - local unitID = Spring.CreateUnit(startUnit, x, Spring.GetGroundHeight(x, z), z, 0, teamID) + local unitID = SpringSynced.CreateUnit(startUnit, x, SpringShared.GetGroundHeight(x, z), z, 0, teamID) coopStartPoints[playerID] = { x, z } GG.playerStartingUnits[playerID] = startUnit -- we set unit rule to mark who belongs to, so initial queue knows which com unitID belongs to which player's initial queue - Spring.SetUnitRulesParam(unitID, "startingOwner", playerID) + SpringSynced.SetUnitRulesParam(unitID, "startingOwner", playerID) end function gadget:GameFrame(n) -- spawn cooped coms if n == 0 and GG.coopMode then for playerID, startPos in pairs(coopStartPoints) do - local _, _, _, teamID, allyID = Spring.GetPlayerInfo(playerID, false) + local _, _, _, teamID, allyID = SpringShared.GetPlayerInfo(playerID, false) SpawnTeamStartUnit(playerID, teamID, allyID, startPos[1], startPos[3]) end end diff --git a/luarules/gadgets/mo_ffa.lua b/luarules/gadgets/mo_ffa.lua index 9942a9dcea9..88d9667d722 100644 --- a/luarules/gadgets/mo_ffa.lua +++ b/luarules/gadgets/mo_ffa.lua @@ -27,22 +27,22 @@ if gadgetHandler:IsSyncedCode() then lateDropGrace = Game.gameSpeed * 8 end - local leaveWreckage = Spring.GetModOptions().ffa_wreckage or false + local leaveWreckage = SpringShared.GetModOptions().ffa_wreckage or false local leaveWreckageFromFrame = Game.gameSpeed * 60 * 3 - local GetPlayerInfo = Spring.GetPlayerInfo - local GetPlayerList = Spring.GetPlayerList - local GetAIInfo = Spring.GetAIInfo - local GetTeamLuaAI = Spring.GetTeamLuaAI + local GetPlayerInfo = SpringShared.GetPlayerInfo + local GetPlayerList = SpringShared.GetPlayerList + local GetAIInfo = SpringShared.GetAIInfo + local GetTeamLuaAI = SpringShared.GetTeamLuaAI local deadTeam = {} local droppedTeam = {} local teamsWithUnitsToKill = {} - local gaiaTeamID = Spring.GetGaiaTeamID() - local teamList = Spring.GetTeamList() + local gaiaTeamID = SpringShared.GetGaiaTeamID() + local teamList = SpringShared.GetTeamList() local teamInfo = {} function gadget:Initialize() - if Spring.GetGameFrame() >= leaveWreckageFromFrame then + if SpringShared.GetGameFrame() >= leaveWreckageFromFrame then GG.wipeoutWithWreckage = leaveWreckage end end @@ -57,33 +57,33 @@ if gadgetHandler:IsSyncedCode() then -- Check if the entire allyteam is dead and wipeout their units if so local allyTeamDead = true - local allyTeamID = select(6, Spring.GetTeamInfo(teamID)) - local allyTeamList = Spring.GetTeamList(allyTeamID) + local allyTeamID = select(6, SpringShared.GetTeamInfo(teamID)) + local allyTeamList = SpringShared.GetTeamList(allyTeamID) if allyTeamList then for _, checkTeamID in ipairs(allyTeamList) do - if checkTeamID ~= teamID and not select(3, Spring.GetTeamInfo(checkTeamID)) then + if checkTeamID ~= teamID and not select(3, SpringShared.GetTeamInfo(checkTeamID)) then allyTeamDead = false break end end -- ensure the wipeout is initiated (for some reason game_end doesnt kill the allyteam I think) if allyTeamDead then - local wipeoutAllyID = select(6, Spring.GetTeamInfo(teamID)) + local wipeoutAllyID = select(6, SpringShared.GetTeamInfo(teamID)) if GG.wipeoutAllyTeam then GG.wipeoutAllyTeam(wipeoutAllyID) else - local teams = Spring.GetTeamList(wipeoutAllyID) + local teams = SpringShared.GetTeamList(wipeoutAllyID) for _, tID in pairs(teams) do - local teamUnits = Spring.GetTeamUnits(tID) + local teamUnits = SpringShared.GetTeamUnits(tID) for i = 1, #teamUnits do - Spring.DestroyUnit(teamUnits[i], false, leaveWreckage) + SpringSynced.DestroyUnit(teamUnits[i], false, leaveWreckage) end end end end end - Spring.KillTeam(teamID) + SpringSynced.KillTeam(teamID) deadTeam[teamID] = true end @@ -149,9 +149,9 @@ if gadgetHandler:IsSyncedCode() then if gameFrame - frame > (frame < earlyDropLimit and earlyDropGrace or lateDropGrace) then if gameFrame < leaveWreckageFromFrame then -- silent removal - local teamUnits = Spring.GetTeamUnits(teamID) + local teamUnits = SpringShared.GetTeamUnits(teamID) for i = 1, #teamUnits do - Spring.DestroyUnit(teamUnits[i], false, true) -- reclaim, dont want to leave FFA comwreck for idling starts + SpringSynced.DestroyUnit(teamUnits[i], false, true) -- reclaim, dont want to leave FFA comwreck for idling starts end end destroyTeam(teamID) @@ -173,21 +173,21 @@ else -- UNSYNCED local function teamDestroyed(_, teamID) if Script.LuaUI("GadgetMessageProxy") then local message = Script.LuaUI.GadgetMessageProxy("ui.ffaNoOwner.destroyed", { team = teamID }) - Spring.SendMessage(message) + SpringUnsynced.SendMessage(message) end end local function playerWarned(_, teamID, gracePeriod) if Script.LuaUI("GadgetMessageProxy") then local message = Script.LuaUI.GadgetMessageProxy("ui.ffaNoOwner.disconnected", { team = teamID, gracePeriod = gracePeriod }) - Spring.SendMessage(message) + SpringUnsynced.SendMessage(message) end end local function playerReconnected(_, teamID) if Script.LuaUI("GadgetMessageProxy") then local message = Script.LuaUI.GadgetMessageProxy("ui.ffaNoOwner.reconnected", { team = teamID }) - Spring.SendMessage(message) + SpringUnsynced.SendMessage(message) end end diff --git a/luarules/gadgets/mo_preventcombomb.lua b/luarules/gadgets/mo_preventcombomb.lua index 5c13e9a7bd4..3c06f1f102d 100644 --- a/luarules/gadgets/mo_preventcombomb.lua +++ b/luarules/gadgets/mo_preventcombomb.lua @@ -16,18 +16,18 @@ if not gadgetHandler:IsSyncedCode() then return false end -local GetTeamInfo = Spring.GetTeamInfo -local GetUnitPosition = Spring.GetUnitPosition -local GetUnitHealth = Spring.GetUnitHealth -local GetGroundHeight = Spring.GetGroundHeight -local GetTeamUnitDefCount = Spring.GetTeamUnitDefCount -local GetTeamList = Spring.GetTeamList -local MoveCtrlEnable = Spring.MoveCtrl.Enable -local MoveCtrlDisable = Spring.MoveCtrl.Disable -local MoveCtrlSetPosition = Spring.MoveCtrl.SetPosition -local GetGameFrame = Spring.GetGameFrame -local DestroyUnit = Spring.DestroyUnit -local GetUnitTeam = Spring.GetUnitTeam +local GetTeamInfo = SpringShared.GetTeamInfo +local GetUnitPosition = SpringShared.GetUnitPosition +local GetUnitHealth = SpringShared.GetUnitHealth +local GetGroundHeight = SpringShared.GetGroundHeight +local GetTeamUnitDefCount = SpringShared.GetTeamUnitDefCount +local GetTeamList = SpringShared.GetTeamList +local MoveCtrlEnable = SpringSynced.MoveCtrl.Enable +local MoveCtrlDisable = SpringSynced.MoveCtrl.Disable +local MoveCtrlSetPosition = SpringSynced.MoveCtrl.SetPosition +local GetGameFrame = SpringShared.GetGameFrame +local DestroyUnit = SpringSynced.DestroyUnit +local GetUnitTeam = SpringShared.GetUnitTeam local math_random = math.random local immuneDgunList = {} diff --git a/luarules/gadgets/pve_areahealers.lua b/luarules/gadgets/pve_areahealers.lua index 3b82461c39e..3bb619ba114 100644 --- a/luarules/gadgets/pve_areahealers.lua +++ b/luarules/gadgets/pve_areahealers.lua @@ -17,22 +17,22 @@ if not gadgetHandler:IsSyncedCode() then end if Spring.Utilities.Gametype.IsRaptors() then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Raptor Defense Spawner Activated!") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Raptor Defense Spawner Activated!") elseif Spring.Utilities.Gametype.IsScavengers() then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Scav Defense Spawner Activated!") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Scav Defense Spawner Activated!") else - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Defense Spawner Deactivated!") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Defense Spawner Deactivated!") return false end -local spGetUnitHealth = Spring.GetUnitHealth -local spAreTeamsAllied = Spring.AreTeamsAllied -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitsInSphere = Spring.GetUnitsInSphere -local spGetUnitNearestEnemy = Spring.GetUnitNearestEnemy -local spGetUnitDefID = Spring.GetUnitDefID -local spSetUnitHealth = Spring.SetUnitHealth -local spSpawnCEG = Spring.SpawnCEG +local spGetUnitHealth = SpringShared.GetUnitHealth +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitsInSphere = SpringShared.GetUnitsInSphere +local spGetUnitNearestEnemy = SpringShared.GetUnitNearestEnemy +local spGetUnitDefID = SpringShared.GetUnitDefID +local spSetUnitHealth = SpringSynced.SetUnitHealth +local spSpawnCEG = SpringSynced.SpawnCEG local mathCeil = math.ceil local unitTeams = {} diff --git a/luarules/gadgets/pve_attachments.lua b/luarules/gadgets/pve_attachments.lua index e11538184b0..f5d54fb3a6d 100644 --- a/luarules/gadgets/pve_attachments.lua +++ b/luarules/gadgets/pve_attachments.lua @@ -27,9 +27,9 @@ local unitAttachedTo = {} function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponID, projectileID, attackerID, attackerDefID, attackerTeam) if unitAttachedTo[unitID] and not paralyzer then - local h, mh = Spring.GetUnitHealth(unitAttachedTo[unitID]) + local h, mh = SpringShared.GetUnitHealth(unitAttachedTo[unitID]) if h and mh then - Spring.SetUnitHealth(unitAttachedTo[unitID], h - damage) + SpringSynced.SetUnitHealth(unitAttachedTo[unitID], h - damage) end damage = 0 end @@ -46,7 +46,7 @@ function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID) for i = 1, #deleteAttachments do if deleteAttachments[i] then unitAttachedTo[deleteAttachments[i]] = nil - Spring.DestroyUnit(deleteAttachments[i], false, true) + SpringSynced.DestroyUnit(deleteAttachments[i], false, true) end end deleteAttachments = {} @@ -60,10 +60,10 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam) local posx = unitAttachments[unitDefID][i].posx local posz = unitAttachments[unitDefID][i].posz local dir = unitAttachments[unitDefID][i].dir or 0 - local bx, by, bz = Spring.GetUnitPosition(unitID) - local attachmentID = Spring.CreateUnit(unitType, bx + posx, by, bz + posz, dir, unitTeam) + local bx, by, bz = SpringShared.GetUnitPosition(unitID) + local attachmentID = SpringSynced.CreateUnit(unitType, bx + posx, by, bz + posz, dir, unitTeam) if attachmentID then - Spring.SetUnitBlocking(attachmentID, false, false) + SpringSynced.SetUnitBlocking(attachmentID, false, false) unitAttachedTo[attachmentID] = unitID end end @@ -72,10 +72,10 @@ end function gadget:GameFrame(frame) for attachment, attachedTo in pairs(unitAttachedTo) do - local h, mh = Spring.GetUnitHealth(attachedTo) + local h, mh = SpringShared.GetUnitHealth(attachedTo) if h and mh then - Spring.SetUnitMaxHealth(attachment, mh) - Spring.SetUnitHealth(attachment, h) + SpringSynced.SetUnitMaxHealth(attachment, mh) + SpringSynced.SetUnitHealth(attachment, h) end end end diff --git a/luarules/gadgets/pve_boss_drones.lua b/luarules/gadgets/pve_boss_drones.lua index 9a38e5a5abc..6aa5a8e0858 100644 --- a/luarules/gadgets/pve_boss_drones.lua +++ b/luarules/gadgets/pve_boss_drones.lua @@ -1,5 +1,5 @@ if not (Spring.Utilities.Gametype.IsRaptors() or Spring.Utilities.Gametype.IsScavengers()) then - Spring.Echo("REMOVED PVE BOSS DRONES") + SpringShared.Echo("REMOVED PVE BOSS DRONES") return false end @@ -22,7 +22,7 @@ if not gadgetHandler:IsSyncedCode() then end local pveTeamID = Spring.Utilities.GetScavTeamID() or Spring.Utilities.GetRaptorTeamID() -local raptorQueenCount = Spring.GetModOptions().raptor_queen_count +local raptorQueenCount = SpringShared.GetModOptions().raptor_queen_count local positionCheckLibrary = VFS.Include("luarules/utilities/damgam_lib/position_checks.lua") @@ -528,7 +528,7 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) for i = 1, #unitList[unitDefID] do aliveCarriers[unitID][i] = { aliveDrones = 0, - lastSpawned = Spring.GetGameSeconds(), + lastSpawned = SpringShared.GetGameSeconds(), } end end @@ -555,16 +555,16 @@ end function gadget:GameFrame(frame) if frame % 30 == 13 then for unitID, unitDroneStats in pairs(aliveCarriers) do - local unitDefID = Spring.GetUnitDefID(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) for index, stats in pairs(unitDroneStats) do - if stats.aliveDrones <= (unitList[unitDefID][index].maxAllowed - unitList[unitDefID][index].spawnedPerWave) and Spring.GetGameSeconds() >= stats.lastSpawned + unitList[unitDefID][index].spawnTimer then + if stats.aliveDrones <= (unitList[unitDefID][index].maxAllowed - unitList[unitDefID][index].spawnedPerWave) and SpringShared.GetGameSeconds() >= stats.lastSpawned + unitList[unitDefID][index].spawnTimer then for _ = 1, unitList[unitDefID][index].spawnedPerWave do - local x, y, z = Spring.GetUnitPosition(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) local spawnx = x + math.random(-unitList[unitDefID][index].spawnRadius, unitList[unitDefID][index].spawnRadius) local spawny = y local spawnz = z + math.random(-unitList[unitDefID][index].spawnRadius, unitList[unitDefID][index].spawnRadius) - if (unitList[unitDefID][index].type == "air" and UnitDefNames[unitList[unitDefID][index].name].canFly) or (unitList[unitDefID][index].type == "ground" and positionCheckLibrary.FlatAreaCheck(spawnx, spawny, spawnz, 64, 30, true)) or (unitList[unitDefID][index].type == "land" and positionCheckLibrary.FlatAreaCheck(spawnx, spawny, spawnz, 64, 30, true) and Spring.GetGroundHeight(spawnx, spawnz) > 0) or (unitList[unitDefID][index].type == "sea" and positionCheckLibrary.FlatAreaCheck(spawnx, spawny, spawnz, 64, 30, true) and Spring.GetGroundHeight(spawnx, spawnz) <= 0) then - local droneID = Spring.CreateUnit(unitList[unitDefID][index].name, spawnx, spawny, spawnz, math.random(0, 3), Spring.GetUnitTeam(unitID)) + if (unitList[unitDefID][index].type == "air" and UnitDefNames[unitList[unitDefID][index].name].canFly) or (unitList[unitDefID][index].type == "ground" and positionCheckLibrary.FlatAreaCheck(spawnx, spawny, spawnz, 64, 30, true)) or (unitList[unitDefID][index].type == "land" and positionCheckLibrary.FlatAreaCheck(spawnx, spawny, spawnz, 64, 30, true) and SpringShared.GetGroundHeight(spawnx, spawnz) > 0) or (unitList[unitDefID][index].type == "sea" and positionCheckLibrary.FlatAreaCheck(spawnx, spawny, spawnz, 64, 30, true) and SpringShared.GetGroundHeight(spawnx, spawnz) <= 0) then + local droneID = SpringSynced.CreateUnit(unitList[unitDefID][index].name, spawnx, spawny, spawnz, math.random(0, 3), SpringShared.GetUnitTeam(unitID)) if droneID then aliveDrones[droneID] = { owner = unitID, @@ -573,8 +573,8 @@ function gadget:GameFrame(frame) fightRadius = unitList[unitDefID][index].fightRadius, } aliveCarriers[unitID][index].aliveDrones = aliveCarriers[unitID][index].aliveDrones + 1 - aliveCarriers[unitID][index].lastSpawned = Spring.GetGameSeconds() - Spring.GiveOrderToUnit(droneID, 37382, { 1 }, 0) + aliveCarriers[unitID][index].lastSpawned = SpringShared.GetGameSeconds() + SpringSynced.GiveOrderToUnit(droneID, 37382, { 1 }, 0) --Spring.GiveOrderToUnit(droneID, CMD.MOVE_STATE, 2, 0) end end @@ -587,15 +587,15 @@ function gadget:GameFrame(frame) if frame % 30 == 14 then for droneID, stats in pairs(aliveDrones) do if stats.owner then - local x, y, z = Spring.GetUnitPosition(stats.owner) + local x, y, z = SpringShared.GetUnitPosition(stats.owner) if math.random(0, 4) == 0 then - Spring.GiveOrderToUnit(droneID, CMD.PATROL, { x + math.random(-stats.fightRadius, stats.fightRadius), y, z + math.random(-stats.fightRadius, stats.fightRadius) }, { "shift" }) + SpringSynced.GiveOrderToUnit(droneID, CMD.PATROL, { x + math.random(-stats.fightRadius, stats.fightRadius), y, z + math.random(-stats.fightRadius, stats.fightRadius) }, { "shift" }) elseif math.random(0, 6) == 0 then - Spring.GiveOrderToUnit(droneID, CMD.PATROL, { x + math.random(-stats.fightRadius, stats.fightRadius), y, z + math.random(-stats.fightRadius, stats.fightRadius) }, {}) + SpringSynced.GiveOrderToUnit(droneID, CMD.PATROL, { x + math.random(-stats.fightRadius, stats.fightRadius), y, z + math.random(-stats.fightRadius, stats.fightRadius) }, {}) end else if math.random(0, 10) == 0 then - Spring.GiveOrderToUnit(droneID, CMD.PATROL, { math.random(0, Game.mapSizeX), 0, math.random(0, Game.mapSizeZ) }, { "shift" }) + SpringSynced.GiveOrderToUnit(droneID, CMD.PATROL, { math.random(0, Game.mapSizeX), 0, math.random(0, Game.mapSizeZ) }, { "shift" }) end end end diff --git a/luarules/gadgets/pve_boss_priority_targetting.lua b/luarules/gadgets/pve_boss_priority_targetting.lua index 4454e1ee9c3..2ce0c9c5a5a 100644 --- a/luarules/gadgets/pve_boss_priority_targetting.lua +++ b/luarules/gadgets/pve_boss_priority_targetting.lua @@ -77,13 +77,13 @@ end function gadget:GameFrame(frame) if frame % 30 == 21 then for queenID, _ in pairs(aliveQueens) do - local queenx, queeny, queenz = Spring.GetUnitPosition(queenID) - local queenTeamID = Spring.GetUnitTeam(queenID) - local surroundingUnits = CallAsTeam(queenTeamID, Spring.GetUnitsInSphere, queenx, queeny, queenz, 750, -4) + local queenx, queeny, queenz = SpringShared.GetUnitPosition(queenID) + local queenTeamID = SpringShared.GetUnitTeam(queenID) + local surroundingUnits = CallAsTeam(queenTeamID, SpringShared.GetUnitsInSphere, queenx, queeny, queenz, 750, -4) for i = 1, #surroundingUnits do if aliveTargets[surroundingUnits[i]] then - Spring.GiveOrderToUnit(queenID, CMD.STOP, 0, 0) - Spring.GiveOrderToUnit(queenID, CMD.ATTACK, { surroundingUnits[i] }, 0) + SpringSynced.GiveOrderToUnit(queenID, CMD.STOP, 0, 0) + SpringSynced.GiveOrderToUnit(queenID, CMD.ATTACK, { surroundingUnits[i] }, 0) break end end diff --git a/luarules/gadgets/pve_builder_controller.lua b/luarules/gadgets/pve_builder_controller.lua index b21955ff6b1..c49fc28f08c 100644 --- a/luarules/gadgets/pve_builder_controller.lua +++ b/luarules/gadgets/pve_builder_controller.lua @@ -17,11 +17,11 @@ if not gadgetHandler:IsSyncedCode() then end if Spring.Utilities.Gametype.IsRaptors() then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Raptor Defense Spawner Activated!") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Raptor Defense Spawner Activated!") elseif Spring.Utilities.Gametype.IsScavengers() then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Scav Defense Spawner Activated!") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Scav Defense Spawner Activated!") else - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Defense Spawner Deactivated!") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Defense Spawner Deactivated!") return false end @@ -60,10 +60,10 @@ function gadget:GameFrame(frame) if frame > lastTurretFrame + 150 then if frame % 30 == 9 then for unitID, data in pairs(aliveBuilders) do - if (Spring.GetUnitNearestEnemy(unitID, data.range * 5, true) and math.random(0, 15) == 0) or data.isFactory then + if (SpringShared.GetUnitNearestEnemy(unitID, data.range * 5, true) and math.random(0, 15) == 0) or data.isFactory then --Spring.Echo(data.unitDefName, "NearestEnemyInRange") - local unitCommands = not data.isFactory and Spring.GetUnitCommands(unitID, 1) or {} - if (data.isFactory and #Spring.GetFullBuildQueue(unitID) < 5) or (not data.isFactory and (not unitCommands[1] or (unitCommands[1] and unitCommands[1].id > 0 and unitCommands[1].id ~= CMD.REPAIR))) then + local unitCommands = not data.isFactory and SpringShared.GetUnitCommands(unitID, 1) or {} + if (data.isFactory and #SpringShared.GetFullBuildQueue(unitID) < 5) or (not data.isFactory and (not unitCommands[1] or (unitCommands[1] and unitCommands[1].id > 0 and unitCommands[1].id ~= CMD.REPAIR))) then --Spring.Echo(data.unitDefName, "Isn't building anything") local turretOptions = {} for buildOptionIndex, buildOptionID in pairs(data.buildOptions) do @@ -75,11 +75,11 @@ function gadget:GameFrame(frame) end if #turretOptions > 1 then local turret = turretOptions[math.random(1, #turretOptions)] - local x, y, z = Spring.GetUnitPosition(unitID) - Spring.GiveOrderToUnit(unitID, -turret, { x + math.random(-data.range, data.range), y, z + math.random(-data.range, data.range) }, {}) + local x, y, z = SpringShared.GetUnitPosition(unitID) + SpringSynced.GiveOrderToUnit(unitID, -turret, { x + math.random(-data.range, data.range), y, z + math.random(-data.range, data.range) }, {}) if data.isFactory then for i = 1, math.random(1, 5) do - Spring.GiveOrderToUnit(unitID, -turret, { x + math.random(-data.range, data.range), y, z + math.random(-data.range, data.range) }, {}) + SpringSynced.GiveOrderToUnit(unitID, -turret, { x + math.random(-data.range, data.range), y, z + math.random(-data.range, data.range) }, {}) end else lastTurretFrame = frame diff --git a/luarules/gadgets/pve_nuke_controller.lua b/luarules/gadgets/pve_nuke_controller.lua index 614d8c5f667..d6e7e88a778 100644 --- a/luarules/gadgets/pve_nuke_controller.lua +++ b/luarules/gadgets/pve_nuke_controller.lua @@ -19,13 +19,13 @@ end local difficulty = "normal" if Spring.Utilities.Gametype.IsRaptors() then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Raptor Defense Spawner Activated!") - difficulty = Spring.GetModOptions().raptor_difficulty + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Raptor Defense Spawner Activated!") + difficulty = SpringShared.GetModOptions().raptor_difficulty elseif Spring.Utilities.Gametype.IsScavengers() then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Scav Defense Spawner Activated!") - difficulty = Spring.GetModOptions().scav_difficulty + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Scav Defense Spawner Activated!") + difficulty = SpringShared.GetModOptions().scav_difficulty else - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Defense Spawner Deactivated!") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Defense Spawner Deactivated!") return false end @@ -48,7 +48,7 @@ local aliveNukeLaunchers = {} function gadget:UnitCreated(unitID, unitDefID, unitTeam) if nukeDefs[unitDefID] and (unitTeam == pveTeamID) then - aliveNukeLaunchers[unitID] = Spring.GetGameSeconds() + math.random(5, 10) + aliveNukeLaunchers[unitID] = SpringShared.GetGameSeconds() + math.random(5, 10) end end @@ -73,7 +73,7 @@ local mapSizeZ = Game.mapSizeZ local targetGridCells = {} local numOfCellsX = math.ceil(mapSizeX / gridSize) local numOfCellsZ = math.ceil(mapSizeZ / gridSize) -local GetGameSeconds = Spring.GetGameSeconds +local GetGameSeconds = SpringShared.GetGameSeconds for cellX = 1, numOfCellsX do for cellZ = 1, numOfCellsZ do @@ -103,17 +103,17 @@ end function gadget:GameFrame(frame) if frame % 30 == 17 then - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for nukeID, cooldown in pairs(aliveNukeLaunchers) do if cooldown <= GetGameSeconds() then local targetID = allUnits[math.random(1, #allUnits)] - if Spring.GetUnitTeam(targetID) ~= Spring.GetUnitTeam(nukeID) then - local x, y, z = Spring.GetUnitPosition(targetID) + if SpringShared.GetUnitTeam(targetID) ~= SpringShared.GetUnitTeam(nukeID) then + local x, y, z = SpringShared.GetUnitPosition(targetID) x = x + math.random(-1024, 1024) z = z + math.random(-1024, 1024) - y = math.max(Spring.GetGroundHeight(x, z), 0) + y = math.max(SpringShared.GetGroundHeight(x, z), 0) if x and z and x > 0 and x < mapSizeX and z > 0 and z < mapSizeZ and checkTargetCell(x, z, nukeID) then - Spring.GiveOrderToUnit(nukeID, CMD.ATTACK, { x, y, z }, 0) + SpringSynced.GiveOrderToUnit(nukeID, CMD.ATTACK, { x, y, z }, 0) aliveNukeLaunchers[nukeID] = GetGameSeconds() + math.random(10, 90) end end diff --git a/luarules/gadgets/pve_supply_drops.lua b/luarules/gadgets/pve_supply_drops.lua index 95afe83dc6a..6366ab0ae03 100644 --- a/luarules/gadgets/pve_supply_drops.lua +++ b/luarules/gadgets/pve_supply_drops.lua @@ -1,4 +1,4 @@ -local teams = Spring.GetTeamList() +local teams = SpringShared.GetTeamList() mapsizeX = Game.mapSizeX mapsizeZ = Game.mapSizeZ local scavengerAITeamID = Spring.Utilities.GetScavTeamID() @@ -6,7 +6,7 @@ local scavengerAllyTeamID = Spring.Utilities.GetScavAllyTeamID() if Spring.Utilities.Gametype.IsScavengers() then scavengersAIEnabled = true - ScavengerStartboxXMin, ScavengerStartboxZMin, ScavengerStartboxXMax, ScavengerStartboxZMax = Spring.GetAllyTeamStartBox(scavengerAllyTeamID) + ScavengerStartboxXMin, ScavengerStartboxZMin, ScavengerStartboxXMax, ScavengerStartboxZMax = SpringShared.GetAllyTeamStartBox(scavengerAllyTeamID) if ScavengerStartboxXMin == 0 and ScavengerStartboxZMin == 0 and ScavengerStartboxXMax == mapsizeX and ScavengerStartboxZMax == mapsizeZ then ScavengerStartboxExists = false else @@ -14,7 +14,7 @@ if Spring.Utilities.Gametype.IsScavengers() then end end -if Spring.GetModOptions().lootboxes == "enabled" or (Spring.GetModOptions().lootboxes == "scav_only" and scavengersAIEnabled) then +if SpringShared.GetModOptions().lootboxes == "enabled" or (SpringShared.GetModOptions().lootboxes == "scav_only" and scavengersAIEnabled) then lootboxSpawnEnabled = true --Spring.Echo("LOOTBOXES ENABLED") else @@ -82,15 +82,15 @@ local mapsizeZ = Game.mapSizeZ local xBorder = math.floor(mapsizeX / 10) local zBorder = math.floor(mapsizeZ / 10) local math_random = math.random -local spGroundHeight = Spring.GetGroundHeight -local spGaiaTeam = Spring.GetGaiaTeamID() -local spGaiaAllyTeam = select(6, Spring.GetTeamInfo(Spring.GetGaiaTeamID())) -local spCreateUnit = Spring.CreateUnit -local spSetUnitNeutral = Spring.SetUnitNeutral -local spSetUnitAlwaysVisible = Spring.SetUnitAlwaysVisible -local spSpawnCEG = Spring.SpawnCEG -local spPlaySoundFile = Spring.PlaySoundFile -local spGetUnitPosition = Spring.GetUnitPosition +local spGroundHeight = SpringShared.GetGroundHeight +local spGaiaTeam = SpringShared.GetGaiaTeamID() +local spGaiaAllyTeam = select(6, SpringShared.GetTeamInfo(SpringShared.GetGaiaTeamID())) +local spCreateUnit = SpringSynced.CreateUnit +local spSetUnitNeutral = SpringSynced.SetUnitNeutral +local spSetUnitAlwaysVisible = SpringSynced.SetUnitAlwaysVisible +local spSpawnCEG = SpringSynced.SpawnCEG +local spPlaySoundFile = SpringUnsynced.PlaySoundFile +local spGetUnitPosition = SpringShared.GetUnitPosition -- Use hash tables instead of arrays for O(1) lookup local aliveLootboxes = {} @@ -109,7 +109,7 @@ local aliveLootboxTier = {} -- Cache tier for each lootbox local LootboxesToSpawn = 0 -local lootboxesDensity = Spring.GetModOptions().lootboxes_density +local lootboxesDensity = SpringShared.GetModOptions().lootboxes_density local lootboxDensityMultiplier = 1 if lootboxesDensity == "veryrare" then lootboxDensityMultiplier = 0.2 @@ -237,7 +237,7 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam) if UnitName == "lootdroppod_gold" or UnitName == "lootdroppod_gold_scav" then spSetUnitNeutral(unitID, true) spSetUnitAlwaysVisible(unitID, true) - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, { "shift" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, { "shift" }) end end diff --git a/luarules/gadgets/raptor_spawner_defense.lua b/luarules/gadgets/raptor_spawner_defense.lua index cad7e60cbb2..8677fbc189f 100644 --- a/luarules/gadgets/raptor_spawner_defense.lua +++ b/luarules/gadgets/raptor_spawner_defense.lua @@ -1,8 +1,8 @@ if Spring.Utilities.Gametype.IsRaptors() and not Spring.Utilities.Gametype.IsScavengers() then - Spring.Log("Raptor Defense Spawner", LOG.INFO, "Raptor Defense Spawner Activated!") + SpringShared.Log("Raptor Defense Spawner", LOG.INFO, "Raptor Defense Spawner Activated!") else - Spring.Log("Raptor Defense Spawner", LOG.INFO, "Raptor Defense Spawner Deactivated!") + SpringShared.Log("Raptor Defense Spawner", LOG.INFO, "Raptor Defense Spawner Deactivated!") return false end @@ -55,50 +55,50 @@ if gadgetHandler:IsSyncedCode() then end -- - local ValidUnitID = Spring.ValidUnitID - local GetUnitNeutral = Spring.GetUnitNeutral - local GetTeamList = Spring.GetTeamList - local GetTeamLuaAI = Spring.GetTeamLuaAI - local GetGaiaTeamID = Spring.GetGaiaTeamID - local SetGameRulesParam = Spring.SetGameRulesParam - local GetGameRulesParam = Spring.GetGameRulesParam - local GetTeamUnitCount = Spring.GetTeamUnitCount - local GetGameFrame = Spring.GetGameFrame - local GetGameSeconds = Spring.GetGameSeconds - local DestroyUnit = Spring.DestroyUnit - local GetTeamUnits = Spring.GetTeamUnits - local GetUnitPosition = Spring.GetUnitPosition - local GiveOrderToUnit = Spring.GiveOrderToUnit - local TestBuildOrder = Spring.TestBuildOrder - local GetGroundBlocked = Spring.GetGroundBlocked - local CreateUnit = Spring.CreateUnit - local SetUnitBlocking = Spring.SetUnitBlocking - local GetGroundHeight = Spring.GetGroundHeight - local GetUnitHealth = Spring.GetUnitHealth - local SetUnitExperience = Spring.SetUnitExperience - local GetUnitIsDead = Spring.GetUnitIsDead - local SetUnitPosition = Spring.SetUnitPosition - local GetUnitSeparation = Spring.GetUnitSeparation - local GetUnitDefID = Spring.GetUnitDefID - local GetTeamUnitDefCount = Spring.GetTeamUnitDefCount - local GetUnitCommandCount = Spring.GetUnitCommandCount - local GetUnitTeam = Spring.GetUnitTeam - local SetUnitHealth = Spring.SetUnitHealth - local SetUnitAlwaysVisible = Spring.SetUnitAlwaysVisible - local KillTeam = Spring.KillTeam - local GetTeamInfo = Spring.GetTeamInfo - local GetPlayerList = Spring.GetPlayerList - local GetPlayerInfo = Spring.GetPlayerInfo - local AssignPlayerToTeam = Spring.AssignPlayerToTeam - local CreateFeature = Spring.CreateFeature - local SetFeatureMoveCtrl = Spring.SetFeatureMoveCtrl - local SetFeatureVelocity = Spring.SetFeatureVelocity - local SetFeatureResources = Spring.SetFeatureResources - local SetFeatureHealth = Spring.SetFeatureHealth - local GetFeatureHealth = Spring.GetFeatureHealth - local DestroyFeature = Spring.DestroyFeature - local GetFeatureDefID = Spring.GetFeatureDefID - local SpawnCEG = Spring.SpawnCEG + local ValidUnitID = SpringShared.ValidUnitID + local GetUnitNeutral = SpringShared.GetUnitNeutral + local GetTeamList = SpringShared.GetTeamList + local GetTeamLuaAI = SpringShared.GetTeamLuaAI + local GetGaiaTeamID = SpringShared.GetGaiaTeamID + local SetGameRulesParam = SpringSynced.SetGameRulesParam + local GetGameRulesParam = SpringShared.GetGameRulesParam + local GetTeamUnitCount = SpringShared.GetTeamUnitCount + local GetGameFrame = SpringShared.GetGameFrame + local GetGameSeconds = SpringShared.GetGameSeconds + local DestroyUnit = SpringSynced.DestroyUnit + local GetTeamUnits = SpringShared.GetTeamUnits + local GetUnitPosition = SpringShared.GetUnitPosition + local GiveOrderToUnit = SpringSynced.GiveOrderToUnit + local TestBuildOrder = SpringShared.TestBuildOrder + local GetGroundBlocked = SpringShared.GetGroundBlocked + local CreateUnit = SpringSynced.CreateUnit + local SetUnitBlocking = SpringSynced.SetUnitBlocking + local GetGroundHeight = SpringShared.GetGroundHeight + local GetUnitHealth = SpringShared.GetUnitHealth + local SetUnitExperience = SpringSynced.SetUnitExperience + local GetUnitIsDead = SpringShared.GetUnitIsDead + local SetUnitPosition = SpringSynced.SetUnitPosition + local GetUnitSeparation = SpringShared.GetUnitSeparation + local GetUnitDefID = SpringShared.GetUnitDefID + local GetTeamUnitDefCount = SpringShared.GetTeamUnitDefCount + local GetUnitCommandCount = SpringShared.GetUnitCommandCount + local GetUnitTeam = SpringShared.GetUnitTeam + local SetUnitHealth = SpringSynced.SetUnitHealth + local SetUnitAlwaysVisible = SpringSynced.SetUnitAlwaysVisible + local KillTeam = SpringSynced.KillTeam + local GetTeamInfo = SpringShared.GetTeamInfo + local GetPlayerList = SpringShared.GetPlayerList + local GetPlayerInfo = SpringShared.GetPlayerInfo + local AssignPlayerToTeam = SpringSynced.AssignPlayerToTeam + local CreateFeature = SpringSynced.CreateFeature + local SetFeatureMoveCtrl = SpringSynced.SetFeatureMoveCtrl + local SetFeatureVelocity = SpringSynced.SetFeatureVelocity + local SetFeatureResources = SpringSynced.SetFeatureResources + local SetFeatureHealth = SpringSynced.SetFeatureHealth + local GetFeatureHealth = SpringShared.GetFeatureHealth + local DestroyFeature = SpringSynced.DestroyFeature + local GetFeatureDefID = SpringShared.GetFeatureDefID + local SpawnCEG = SpringSynced.SpawnCEG local mRandom = math.random local math = math @@ -106,14 +106,14 @@ if gadgetHandler:IsSyncedCode() then local table = table local ipairs = ipairs local pairs = pairs - local modOptions = Spring.GetModOptions() + local modOptions = SpringShared.GetModOptions() local MAPSIZEX = Game.mapSizeX local MAPSIZEZ = Game.mapSizeZ -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- - Spring.SetGameRulesParam("BossFightStarted", 0) + SpringSynced.SetGameRulesParam("BossFightStarted", 0) local nKilledQueens = 0 local nSpawnedQueens = 0 local nTotalQueens = modOptions.raptor_queen_count or 1 @@ -725,9 +725,9 @@ if gadgetHandler:IsSyncedCode() then end end elseif not UnitDefNames[raptorType] then - Spring.Echo("[ERROR] Invalid Raptor Unit Name", raptorType) + SpringShared.Echo("[ERROR] Invalid Raptor Unit Name", raptorType) else - Spring.Echo("[ERROR] Invalid Raptor Squad", raptorType) + SpringShared.Echo("[ERROR] Invalid Raptor Squad", raptorType) end else squadCounter = 0 @@ -760,9 +760,9 @@ if gadgetHandler:IsSyncedCode() then end end elseif not UnitDefNames[raptorName] then - Spring.Echo("[ERROR] Invalid Raptor Unit Name", raptorName) + SpringShared.Echo("[ERROR] Invalid Raptor Unit Name", raptorName) else - Spring.Echo("[ERROR] Invalid Raptor Squad", raptorName) + SpringShared.Echo("[ERROR] Invalid Raptor Squad", raptorName) end end end @@ -1189,9 +1189,9 @@ if gadgetHandler:IsSyncedCode() then end end elseif not UnitDefNames[raptorName] then - Spring.Echo("[ERROR] Invalid Raptor Unit Name", raptorName) + SpringShared.Echo("[ERROR] Invalid Raptor Unit Name", raptorName) else - Spring.Echo("[ERROR] Invalid Raptor Squad", raptorName) + SpringShared.Echo("[ERROR] Invalid Raptor Squad", raptorName) end end end @@ -1218,9 +1218,9 @@ if gadgetHandler:IsSyncedCode() then end end elseif not UnitDefNames[raptorName] then - Spring.Echo("[ERROR] Invalid Raptor Unit Name", raptorName) + SpringShared.Echo("[ERROR] Invalid Raptor Unit Name", raptorName) else - Spring.Echo("[ERROR] Invalid Raptor Squad", raptorName) + SpringShared.Echo("[ERROR] Invalid Raptor Squad", raptorName) end end end @@ -1503,9 +1503,9 @@ if gadgetHandler:IsSyncedCode() then end end elseif not UnitDefNames[raptorName] then - Spring.Echo("[ERROR] Invalid Raptor Unit Name", raptorName) + SpringShared.Echo("[ERROR] Invalid Raptor Unit Name", raptorName) else - Spring.Echo("[ERROR] Invalid Raptor Squad", raptorName) + SpringShared.Echo("[ERROR] Invalid Raptor Squad", raptorName) end end end @@ -1645,11 +1645,11 @@ if gadgetHandler:IsSyncedCode() then lsx1, lsz1, lsx2, lsz2 = RaptorStartboxXMin, RaptorStartboxZMin, RaptorStartboxXMax, RaptorStartboxZMax if not lsx1 or not lsz1 or not lsx2 or not lsz2 then config.burrowSpawnType = "avoid" - Spring.Log(gadget:GetInfo().name, LOG.INFO, "No Raptor start box available, Burrow Placement set to 'Avoid Players'") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "No Raptor start box available, Burrow Placement set to 'Avoid Players'") noRaptorStartbox = true elseif lsx1 == 0 and lsz1 == 0 and lsx2 == Game.mapSizeX and lsz2 == Game.mapSizeX then config.burrowSpawnType = "avoid" - Spring.Log(gadget:GetInfo().name, LOG.INFO, "No Raptor start box available, Burrow Placement set to 'Avoid Players'") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "No Raptor start box available, Burrow Placement set to 'Avoid Players'") noRaptorStartbox = true end end diff --git a/luarules/gadgets/ruins/Blueprints/BYAR/blueprint_controller.lua b/luarules/gadgets/ruins/Blueprints/BYAR/blueprint_controller.lua index 99ea14fa567..7e57ed028cc 100644 --- a/luarules/gadgets/ruins/Blueprints/BYAR/blueprint_controller.lua +++ b/luarules/gadgets/ruins/Blueprints/BYAR/blueprint_controller.lua @@ -65,13 +65,13 @@ local function populateBlueprints(blueprintType) local success, fileContents = pcall(VFS.Include, blueprintFile) if not success then - Spring.Echo("[Ruins Blueprints] Failed to load blueprint file: " .. blueprintFile .. " - " .. fileContents) + SpringShared.Echo("[Ruins Blueprints] Failed to load blueprint file: " .. blueprintFile .. " - " .. fileContents) else for _, blueprintFunction in ipairs(fileContents) do local blueprintSuccess, blueprint = pcall(blueprintFunction) if not blueprintSuccess then - Spring.Echo("[Ruins Blueprints] Failed to execute blueprint function in file: " .. blueprintFile .. " - " .. blueprint) + SpringShared.Echo("[Ruins Blueprints] Failed to execute blueprint function in file: " .. blueprintFile .. " - " .. blueprint) else if blueprintsConfig[1].tiered then for _, tier in ipairs(blueprint.tiers) do diff --git a/luarules/gadgets/ruins/Blueprints/BYAR/blueprint_tiers.lua b/luarules/gadgets/ruins/Blueprints/BYAR/blueprint_tiers.lua index 2e7c4f2ae08..9324d732c9f 100644 --- a/luarules/gadgets/ruins/Blueprints/BYAR/blueprint_tiers.lua +++ b/luarules/gadgets/ruins/Blueprints/BYAR/blueprint_tiers.lua @@ -1,5 +1,5 @@ local UDN = UnitDefNames -local gaiaTeamID = Spring.Utilities.GetScavTeamID() or Spring.GetGaiaTeamID() +local gaiaTeamID = Spring.Utilities.GetScavTeamID() or SpringShared.GetGaiaTeamID() local wallUnitDefs = { ["arm"] = { diff --git a/luarules/gadgets/scav_cloud_spawner.lua b/luarules/gadgets/scav_cloud_spawner.lua index 87423ffe35f..e74dd63eee5 100644 --- a/luarules/gadgets/scav_cloud_spawner.lua +++ b/luarules/gadgets/scav_cloud_spawner.lua @@ -17,7 +17,7 @@ if not Spring.Utilities.Gametype.IsScavengers() then end if gadgetHandler:IsSyncedCode() then -- Synced - local teams = Spring.GetTeamList() + local teams = SpringShared.GetTeamList() local scavTeamID = Spring.Utilities.GetScavTeamID() local mapx = Game.mapSizeX local mapz = Game.mapSizeZ @@ -35,19 +35,19 @@ if gadgetHandler:IsSyncedCode() then -- Synced local cooldown = 0 -- 1 minute cooldown at the start local mRandom = math.random - local spGetGroundHeight = Spring.GetGroundHeight - local spSpawnCEG = Spring.SpawnCEG - local spPlaySoundFile = Spring.PlaySoundFile - local spGetUnitPosition = Spring.GetUnitPosition - local spDestroyUnit = Spring.DestroyUnit - local spGetTeamUnitDefCount = Spring.GetTeamUnitDefCount - local spGetFeaturePosition = Spring.GetFeaturePosition - local spGetFeatureResurrect = Spring.GetFeatureResurrect - local spGetFeatureHealth = Spring.GetFeatureHealth - local spSetFeatureResurrect = Spring.SetFeatureResurrect - local spSetFeatureHealth = Spring.SetFeatureHealth - local spDestroyFeature = Spring.DestroyFeature - local spCreateUnit = Spring.CreateUnit + local spGetGroundHeight = SpringShared.GetGroundHeight + local spSpawnCEG = SpringSynced.SpawnCEG + local spPlaySoundFile = SpringUnsynced.PlaySoundFile + local spGetUnitPosition = SpringShared.GetUnitPosition + local spDestroyUnit = SpringSynced.DestroyUnit + local spGetTeamUnitDefCount = SpringShared.GetTeamUnitDefCount + local spGetFeaturePosition = SpringShared.GetFeaturePosition + local spGetFeatureResurrect = SpringShared.GetFeatureResurrect + local spGetFeatureHealth = SpringShared.GetFeatureHealth + local spSetFeatureResurrect = SpringSynced.SetFeatureResurrect + local spSetFeatureHealth = SpringSynced.SetFeatureHealth + local spDestroyFeature = SpringSynced.DestroyFeature + local spCreateUnit = SpringSynced.CreateUnit local SendToUnsynced = SendToUnsynced function gadget:GameFrame(frame) diff --git a/luarules/gadgets/scav_lootbox_collector.lua b/luarules/gadgets/scav_lootbox_collector.lua index 9ec7ebfb298..e7c95d52ec6 100644 --- a/luarules/gadgets/scav_lootbox_collector.lua +++ b/luarules/gadgets/scav_lootbox_collector.lua @@ -12,7 +12,7 @@ function gadget:GetInfo() } end -if (not gadgetHandler:IsSyncedCode()) or (not Spring.Utilities.Gametype.IsScavengers()) or Spring.GetModOptions().unit_restrictions_noair then +if (not gadgetHandler:IsSyncedCode()) or (not Spring.Utilities.Gametype.IsScavengers()) or SpringShared.GetModOptions().unit_restrictions_noair then return false elseif Spring.Utilities.Gametype.IsRaptors() then return false @@ -59,7 +59,7 @@ local aliveSpawners = {} local aliveSpawnersCount = 0 local lastTransportSentFrame = 0 local handledLootboxesList = {} -local RaptorStartboxXMin, RaptorStartboxZMin, RaptorStartboxXMax, RaptorStartboxZMax = Spring.GetAllyTeamStartBox(scavAllyTeamID) +local RaptorStartboxXMin, RaptorStartboxZMin, RaptorStartboxXMax, RaptorStartboxZMax = SpringShared.GetAllyTeamStartBox(scavAllyTeamID) local config = VFS.Include("LuaRules/Configs/scav_spawn_defs.lua") @@ -88,7 +88,7 @@ function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerD end function gadget:GameFrame(frame) - if frame % 30 == 12 and Spring.GetGameRulesParam("scavBossAnger") >= 1 and Spring.GetGameRulesParam("scavTechAnger") >= config.airStartAnger then + if frame % 30 == 12 and SpringShared.GetGameRulesParam("scavBossAnger") >= 1 and SpringShared.GetGameRulesParam("scavTechAnger") >= config.airStartAnger then if aliveLootboxesCount > 0 and aliveSpawnersCount > 0 then if SetCount(handledLootboxesList) > 0 then handledLootboxesList = {} @@ -98,7 +98,7 @@ function gadget:GameFrame(frame) local loopCount = 0 local success = false for lootboxID, lootboxTier in pairs(aliveLootboxes) do - local lootboxPosX, lootboxPosY, lootboxPosZ = Spring.GetUnitPosition(lootboxID) + local lootboxPosX, lootboxPosY, lootboxPosZ = SpringShared.GetUnitPosition(lootboxID) if lootboxPosX and not GG.IsPosInRaptorScum(lootboxPosX, lootboxPosY, lootboxPosZ) then if math.random(0, aliveLootboxesCount) == 0 and not handledLootboxesList[lootboxID] then for transportDefID, transportTier in pairs(transportsList) do @@ -106,24 +106,24 @@ function gadget:GameFrame(frame) for spawnerID, _ in pairs(aliveSpawners) do if math.random(0, SetCount(aliveSpawners)) == 0 and not handledLootboxesList[lootboxID] then targetLootboxID = lootboxID - local spawnerPosX, spawnerPosY, spawnerPosZ = Spring.GetUnitPosition(spawnerID) + local spawnerPosX, spawnerPosY, spawnerPosZ = SpringShared.GetUnitPosition(spawnerID) for j = 1, 5 do if math.random() <= config.spawnChance then - local transportID = Spring.CreateUnit(transportDefID, spawnerPosX + math.random(-1024, 1024), spawnerPosY + 100, spawnerPosZ + math.random(-1024, 1024), math.random(0, 3), scavTeamID) + local transportID = SpringSynced.CreateUnit(transportDefID, spawnerPosX + math.random(-1024, 1024), spawnerPosY + 100, spawnerPosZ + math.random(-1024, 1024), math.random(0, 3), scavTeamID) if transportID then handledLootboxesList[targetLootboxID] = true success = true lastTransportSentFrame = frame - Spring.GiveOrderToUnit(transportID, CMD.LOAD_UNITS, { targetLootboxID }, { "shift" }) + SpringSynced.GiveOrderToUnit(transportID, CMD.LOAD_UNITS, { targetLootboxID }, { "shift" }) for i = 1, 100 do local randomX = math.random(0, Game.mapSizeX) local randomZ = math.random(0, Game.mapSizeZ) - local randomY = math.max(0, Spring.GetGroundHeight(randomX, randomZ)) + local randomY = math.max(0, SpringShared.GetGroundHeight(randomX, randomZ)) if GG.IsPosInRaptorScum(randomX, randomY, randomZ) then - Spring.GiveOrderToUnit(transportID, CMD.UNLOAD_UNITS, { randomX, randomY, randomZ, 1024 }, { "shift" }) + SpringSynced.GiveOrderToUnit(transportID, CMD.UNLOAD_UNITS, { randomX, randomY, randomZ, 1024 }, { "shift" }) end if i == 100 then - Spring.GiveOrderToUnit(transportID, CMD.MOVE, { randomX + math.random(-256, 256), randomY, randomZ + math.random(-256, 256) }, { "shift" }) + SpringSynced.GiveOrderToUnit(transportID, CMD.MOVE, { randomX + math.random(-256, 256), randomY, randomZ + math.random(-256, 256) }, { "shift" }) end end end diff --git a/luarules/gadgets/scav_spawn_effect.lua b/luarules/gadgets/scav_spawn_effect.lua index 19ba8a62c5e..0bf267bacfb 100644 --- a/luarules/gadgets/scav_spawn_effect.lua +++ b/luarules/gadgets/scav_spawn_effect.lua @@ -52,30 +52,30 @@ if gadgetHandler:IsSyncedCode() then -- Synced end function ScavengersSpawnEffectUnitID(unitID) - local posx, posy, posz = Spring.GetUnitPosition(unitID) - local unitDefID = Spring.GetUnitDefID(unitID) + local posx, posy, posz = SpringShared.GetUnitPosition(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) local size = getUnitSize(unitDefID) - Spring.SpawnCEG("scav-spawnexplo-" .. size, posx, posy, posz, 0, 0, 0) + SpringSynced.SpawnCEG("scav-spawnexplo-" .. size, posx, posy, posz, 0, 0, 0) end GG.ScavengersSpawnEffectUnitID = ScavengersSpawnEffectUnitID function ScavengersSpawnEffectUnitDefID(unitDefID, posx, posy, posz) local size = getUnitSize(unitDefID) - Spring.SpawnCEG("scav-spawnexplo-" .. size, posx, posy, posz, 0, 0, 0) + SpringSynced.SpawnCEG("scav-spawnexplo-" .. size, posx, posy, posz, 0, 0, 0) end GG.ScavengersSpawnEffectUnitDefID = ScavengersSpawnEffectUnitDefID function ScavengersSpawnEffectFeatureID(featureID) - local posx, posy, posz = Spring.GetFeaturePosition(featureID) - local featureDefID = Spring.GetFeatureDefID(featureID) + local posx, posy, posz = SpringShared.GetFeaturePosition(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) local size = getFeatureSize(featureDefID) - Spring.SpawnCEG("scav-spawnexplo-" .. size, posx, posy, posz, 0, 0, 0) + SpringSynced.SpawnCEG("scav-spawnexplo-" .. size, posx, posy, posz, 0, 0, 0) end GG.ScavengersSpawnEffectFeatureID = ScavengersSpawnEffectFeatureID function ScavengersSpawnEffectFeatureDefID(featureDefID, posx, posy, posz) local size = getFeatureSize(featureDefID) - Spring.SpawnCEG("scav-spawnexplo-" .. size, posx, posy, posz, 0, 0, 0) + SpringSynced.SpawnCEG("scav-spawnexplo-" .. size, posx, posy, posz, 0, 0, 0) end GG.ScavengersSpawnEffectFeatureDefID = ScavengersSpawnEffectFeatureDefID end diff --git a/luarules/gadgets/scav_spawner_defense.lua b/luarules/gadgets/scav_spawner_defense.lua index 1edab736f2c..8847a41a4bf 100644 --- a/luarules/gadgets/scav_spawner_defense.lua +++ b/luarules/gadgets/scav_spawner_defense.lua @@ -13,12 +13,12 @@ function gadget:GetInfo() end if Spring.Utilities.Gametype.IsScavengers() and not Spring.Utilities.Gametype.IsRaptors() then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Scav Defense Spawner Activated!") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Scav Defense Spawner Activated!") else - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Scav Defense Spawner Deactivated!") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Scav Defense Spawner Deactivated!") return false end -Spring.SetLogSectionFilterLevel("Dynamic Difficulty", LOG.INFO) +SpringUnsynced.SetLogSectionFilterLevel("Dynamic Difficulty", LOG.INFO) local config = VFS.Include("LuaRules/Configs/scav_spawn_defs.lua") local EnemyLib = VFS.Include("LuaRules/Gadgets/Include/SpawnerEnemyLib.lua") @@ -33,37 +33,37 @@ if gadgetHandler:IsSyncedCode() then -- Speed-ups -- - local ValidUnitID = Spring.ValidUnitID - local GetUnitNeutral = Spring.GetUnitNeutral - local GetTeamList = Spring.GetTeamList - local GetTeamLuaAI = Spring.GetTeamLuaAI - local GetGaiaTeamID = Spring.GetGaiaTeamID - local SetGameRulesParam = Spring.SetGameRulesParam - local GetGameRulesParam = Spring.GetGameRulesParam - local GetTeamUnitCount = Spring.GetTeamUnitCount - local GetGameFrame = Spring.GetGameFrame - local GetGameSeconds = Spring.GetGameSeconds - local DestroyUnit = Spring.DestroyUnit - local GetTeamUnits = Spring.GetTeamUnits - local GetUnitPosition = Spring.GetUnitPosition - local GiveOrderToUnit = Spring.GiveOrderToUnit - local TestBuildOrder = Spring.TestBuildOrder - local GetGroundBlocked = Spring.GetGroundBlocked - local CreateUnit = Spring.CreateUnit - local SetUnitBlocking = Spring.SetUnitBlocking - local GetGroundHeight = Spring.GetGroundHeight - local GetUnitHealth = Spring.GetUnitHealth - local SetUnitExperience = Spring.SetUnitExperience - local GetUnitIsDead = Spring.GetUnitIsDead - local SetUnitPosition = Spring.SetUnitPosition - local GetUnitSeparation = Spring.GetUnitSeparation - local GetUnitDefID = Spring.GetUnitDefID - local GetTeamUnitDefCount = Spring.GetTeamUnitDefCount - local GetUnitCommandCount = Spring.GetUnitCommandCount - local SpawnCEG = Spring.SpawnCEG - local SetUnitHealth = Spring.SetUnitHealth - local TransferUnit = Spring.TransferUnit - local GetUnitBuildFacing = Spring.GetUnitBuildFacing + local ValidUnitID = SpringShared.ValidUnitID + local GetUnitNeutral = SpringShared.GetUnitNeutral + local GetTeamList = SpringShared.GetTeamList + local GetTeamLuaAI = SpringShared.GetTeamLuaAI + local GetGaiaTeamID = SpringShared.GetGaiaTeamID + local SetGameRulesParam = SpringSynced.SetGameRulesParam + local GetGameRulesParam = SpringShared.GetGameRulesParam + local GetTeamUnitCount = SpringShared.GetTeamUnitCount + local GetGameFrame = SpringShared.GetGameFrame + local GetGameSeconds = SpringShared.GetGameSeconds + local DestroyUnit = SpringSynced.DestroyUnit + local GetTeamUnits = SpringShared.GetTeamUnits + local GetUnitPosition = SpringShared.GetUnitPosition + local GiveOrderToUnit = SpringSynced.GiveOrderToUnit + local TestBuildOrder = SpringShared.TestBuildOrder + local GetGroundBlocked = SpringShared.GetGroundBlocked + local CreateUnit = SpringSynced.CreateUnit + local SetUnitBlocking = SpringSynced.SetUnitBlocking + local GetGroundHeight = SpringShared.GetGroundHeight + local GetUnitHealth = SpringShared.GetUnitHealth + local SetUnitExperience = SpringSynced.SetUnitExperience + local GetUnitIsDead = SpringShared.GetUnitIsDead + local SetUnitPosition = SpringSynced.SetUnitPosition + local GetUnitSeparation = SpringShared.GetUnitSeparation + local GetUnitDefID = SpringShared.GetUnitDefID + local GetTeamUnitDefCount = SpringShared.GetTeamUnitDefCount + local GetUnitCommandCount = SpringShared.GetUnitCommandCount + local SpawnCEG = SpringSynced.SpawnCEG + local SetUnitHealth = SpringSynced.SetUnitHealth + local TransferUnit = SpringSynced.TransferUnit + local GetUnitBuildFacing = SpringShared.GetUnitBuildFacing local mRandom = math.random local math = math @@ -77,10 +77,10 @@ if gadgetHandler:IsSyncedCode() then -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- - Spring.SetGameRulesParam("BossFightStarted", 0) + SpringSynced.SetGameRulesParam("BossFightStarted", 0) local nKilledBosses = 0 local nSpawnedBosses = 0 - local nTotalBosses = Spring.GetModOptions().scav_boss_count or 1 + local nTotalBosses = SpringShared.GetModOptions().scav_boss_count or 1 local maxTries = 30 local scavUnitCap = math.floor(Game.maxUnits * 0.80) local minBurrows = 1 @@ -165,7 +165,7 @@ if gadgetHandler:IsSyncedCode() then local squadCreationQueue = { units = {}, role = false, - life = math.ceil(10 * Spring.GetModOptions().scav_spawntimemult), + life = math.ceil(10 * SpringShared.GetModOptions().scav_spawntimemult), regroupenabled = true, regrouping = false, needsregroup = false, @@ -174,7 +174,7 @@ if gadgetHandler:IsSyncedCode() then squadCreationQueueDefaults = { units = {}, role = false, - life = math.ceil(10 * Spring.GetModOptions().scav_spawntimemult), + life = math.ceil(10 * SpringShared.GetModOptions().scav_spawntimemult), regroupenabled = true, regrouping = false, needsregroup = false, @@ -211,36 +211,36 @@ if gadgetHandler:IsSyncedCode() then local gaiaTeamID = GetGaiaTeamID() if not scavTeamID then scavTeamID = gaiaTeamID - scavAllyTeamID = select(6, Spring.GetTeamInfo(scavTeamID)) + scavAllyTeamID = select(6, SpringShared.GetTeamInfo(scavTeamID)) end humanTeams[gaiaTeamID] = nil function PutScavAlliesInScavTeam(n) - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() for i = 1, #players do local player = players[i] - local name, active, spectator, teamID, allyTeamID = Spring.GetPlayerInfo(player, false) + local name, active, spectator, teamID, allyTeamID = SpringShared.GetPlayerInfo(player, false) if allyTeamID == scavAllyTeamID and not spectator then - Spring.AssignPlayerToTeam(player, scavTeamID) + SpringSynced.AssignPlayerToTeam(player, scavTeamID) local units = GetTeamUnits(teamID) scavteamhasplayers = true for u = 1, #units do - Spring.DestroyUnit(units[u], false, true) + SpringSynced.DestroyUnit(units[u], false, true) end - Spring.KillTeam(teamID) + SpringSynced.KillTeam(teamID) end end - local scavAllies = Spring.GetTeamList(scavAllyTeamID) + local scavAllies = SpringShared.GetTeamList(scavAllyTeamID) for i = 1, #scavAllies do - local _, _, _, AI = Spring.GetTeamInfo(scavAllies[i], false) - local LuaAI = Spring.GetTeamLuaAI(scavAllies[i]) + local _, _, _, AI = SpringShared.GetTeamInfo(scavAllies[i], false) + local LuaAI = SpringShared.GetTeamLuaAI(scavAllies[i]) if (AI or LuaAI) and scavAllies[i] ~= scavTeamID then local units = GetTeamUnits(scavAllies[i]) for u = 1, #units do - Spring.DestroyUnit(units[u], false, true) - Spring.KillTeam(scavAllies[i]) + SpringSynced.DestroyUnit(units[u], false, true) + SpringSynced.KillTeam(scavAllies[i]) end end end @@ -290,7 +290,7 @@ if gadgetHandler:IsSyncedCode() then for target in pairs(squadPotentialHighValueTarget) do if mRandom(1, highValueTargetCount) == 1 then if ValidUnitID(target) and not GetUnitIsDead(target) and not GetUnitNeutral(target) then - local x, y, z = Spring.GetUnitPosition(target) + local x, y, z = SpringShared.GetUnitPosition(target) pos = { x = x + mRandom(-32, 32), y = y, z = z + mRandom(-32, 32) } pickedTarget = target break @@ -301,7 +301,7 @@ if gadgetHandler:IsSyncedCode() then for target in pairs(squadPotentialTarget) do if mRandom(1, targetCount) == 1 then if ValidUnitID(target) and not GetUnitIsDead(target) and not GetUnitNeutral(target) then - local x, y, z = Spring.GetUnitPosition(target) + local x, y, z = SpringShared.GetUnitPosition(target) pos = { x = x + mRandom(-32, 32), y = y, z = z + mRandom(-32, 32) } pickedTarget = target break @@ -454,9 +454,9 @@ if gadgetHandler:IsSyncedCode() then -- Spring.Echo("Life is 0, time to do some killing") if SetCount(squadsTable[i].squadUnits) > 0 and SetCount(burrows) > 2 then if squadsTable[i].squadBurrow and nSpawnedBosses == 0 then - if Spring.GetUnitTeam(squadsTable[i].squadBurrow) == scavTeamID then - Spring.DestroyUnit(squadsTable[i].squadBurrow, true, false) - elseif Spring.GetUnitIsDead(squadsTable[i].squadBurrow) == false then + if SpringShared.GetUnitTeam(squadsTable[i].squadBurrow) == scavTeamID then + SpringSynced.DestroyUnit(squadsTable[i].squadBurrow, true, false) + elseif SpringShared.GetUnitIsDead(squadsTable[i].squadBurrow) == false then squadsTable[i].squadBurrow = nil end end @@ -471,8 +471,8 @@ if gadgetHandler:IsSyncedCode() then end for j = 1, #destroyQueue do -- Spring.Echo("Destroying Unit. ID: ".. unitID .. ", Name:" .. UnitDefs[Spring.GetUnitDefID(unitID)].name) - if Spring.GetUnitTeam(destroyQueue[j]) == scavTeamID then - Spring.DestroyUnit(destroyQueue[j], true, false) + if SpringShared.GetUnitTeam(destroyQueue[j]) == scavTeamID then + SpringSynced.DestroyUnit(destroyQueue[j], true, false) end end destroyQueue = nil @@ -497,7 +497,7 @@ if gadgetHandler:IsSyncedCode() then local count = 0 for i, unitID in pairs(units) do if ValidUnitID(unitID) and not GetUnitIsDead(unitID) and not GetUnitNeutral(unitID) then - local x, y, z = Spring.GetUnitPosition(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) if x < xmin then xmin = x end @@ -522,7 +522,7 @@ if gadgetHandler:IsSyncedCode() then if xmin < xaverage - 512 or xmax > xaverage + 512 or zmin < zaverage - 512 or zmax > zaverage + 512 then targetx = xaverage targetz = zaverage - targety = Spring.GetGroundHeight(targetx, targetz) + targety = SpringShared.GetGroundHeight(targetx, targetz) role = "raid" squadsTable[squadID].squadNeedsRegroup = true else @@ -538,35 +538,35 @@ if gadgetHandler:IsSyncedCode() then if ValidUnitID(unitID) and not GetUnitIsDead(unitID) and not GetUnitNeutral(unitID) then -- Spring.Echo("GiveOrderToUnit #" .. i) if not unitCowardCooldown[unitID] then - if config.scavBehaviours.ALWAYSMOVE[Spring.GetUnitDefID(unitID)] then + if config.scavBehaviours.ALWAYSMOVE[SpringShared.GetUnitDefID(unitID)] then local pos = getRandomEnemyPos() - Spring.GiveOrderToUnit(unitID, CMD.MOVE, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256) }, { "shift" }) - elseif config.scavBehaviours.ALWAYSFIGHT[Spring.GetUnitDefID(unitID)] then + SpringSynced.GiveOrderToUnit(unitID, CMD.MOVE, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256) }, { "shift" }) + elseif config.scavBehaviours.ALWAYSFIGHT[SpringShared.GetUnitDefID(unitID)] then local pos = getRandomEnemyPos() - Spring.GiveOrderToUnit(unitID, CMD.FIGHT, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256) }, { "shift" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.FIGHT, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256) }, { "shift" }) elseif role == "assault" or role == "artillery" then - Spring.GiveOrderToUnit(unitID, CMD.FIGHT, { targetx + mRandom(-256, 256), targety, targetz + mRandom(-256, 256) }, {}) + SpringSynced.GiveOrderToUnit(unitID, CMD.FIGHT, { targetx + mRandom(-256, 256), targety, targetz + mRandom(-256, 256) }, {}) elseif role == "raid" then - Spring.GiveOrderToUnit(unitID, CMD.MOVE, { targetx + mRandom(-256, 256), targety, targetz + mRandom(-256, 256) }, {}) + SpringSynced.GiveOrderToUnit(unitID, CMD.MOVE, { targetx + mRandom(-256, 256), targety, targetz + mRandom(-256, 256) }, {}) elseif role == "aircraft" then local pos = getRandomEnemyPos() - Spring.GiveOrderToUnit(unitID, CMD.FIGHT, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256) }, {}) + SpringSynced.GiveOrderToUnit(unitID, CMD.FIGHT, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256) }, {}) elseif role == "kamikaze" then - Spring.GiveOrderToUnit(unitID, CMD.MOVE, { targetx + mRandom(-256, 256), targety, targetz + mRandom(-256, 256) }, {}) + SpringSynced.GiveOrderToUnit(unitID, CMD.MOVE, { targetx + mRandom(-256, 256), targety, targetz + mRandom(-256, 256) }, {}) elseif role == "healer" then local pos = getRandomEnemyPos() - Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, {}) + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, {}, {}) if math.random() < 0.75 then - Spring.GiveOrderToUnit(unitID, CMD.RESURRECT, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256), 20000 }, { "shift" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.RESURRECT, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256), 20000 }, { "shift" }) end if math.random() < 0.75 then - Spring.GiveOrderToUnit(unitID, CMD.CAPTURE, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256), 20000 }, { "shift" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.CAPTURE, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256), 20000 }, { "shift" }) end if math.random() < 0.75 then - Spring.GiveOrderToUnit(unitID, CMD.REPAIR, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256), 20000 }, { "shift" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.REPAIR, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256), 20000 }, { "shift" }) end - Spring.GiveOrderToUnit(unitID, CMD.RESURRECT, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256), 20000 }, { "shift" }) - Spring.GiveOrderToUnit(unitID, CMD.FIGHT, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256) }, { "shift" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.RESURRECT, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256), 20000 }, { "shift" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.FIGHT, { pos.x + mRandom(-256, 256), pos.y, pos.z + mRandom(-256, 256) }, { "shift" }) end end end @@ -621,7 +621,7 @@ if gadgetHandler:IsSyncedCode() then role = newSquad.role end if not newSquad.life then - newSquad.life = math.ceil(10 * Spring.GetModOptions().scav_spawntimemult) + newSquad.life = math.ceil(10 * SpringShared.GetModOptions().scav_spawntimemult) end squadsTable[squadID] = { @@ -706,7 +706,7 @@ if gadgetHandler:IsSyncedCode() then local nearestDistance = 999999 for burrowID, burrow in pairs(burrows) do local bx, by, bz = GetUnitPosition(burrowID) - if bx and by and bz and burrow.lastBackupSpawn + 1800 <= Spring.GetGameFrame() then + if bx and by and bz and burrow.lastBackupSpawn + 1800 <= SpringShared.GetGameFrame() then local distance = math.ceil((math.abs(tx - bx) + math.abs(ty - by) + math.abs(tz - bz)) * 0.5) if distance < nearestDistance then nearestDistance = distance @@ -738,16 +738,16 @@ if gadgetHandler:IsSyncedCode() then end end elseif not UnitDefNames[scavType] then - Spring.Echo("[ERROR] Invalid Scav Unit Name", scavType) + SpringShared.Echo("[ERROR] Invalid Scav Unit Name", scavType) else - Spring.Echo("[ERROR] Invalid Scav Squad", scavType) + SpringShared.Echo("[ERROR] Invalid Scav Squad", scavType) end else squadCounter = 0 local squad local airRandom = mRandom(1, 100) local specialRandom = mRandom(1, 100) - local burrowX, burrowY, burrowZ = Spring.GetUnitPosition(burrowID) + local burrowX, burrowY, burrowZ = SpringShared.GetUnitPosition(burrowID) local surface = positionCheckLibrary.LandOrSeaCheck(burrowX, burrowY, burrowZ, config.burrowSize) if waveParameters.waveTechAnger > config.airStartAnger and airRandom <= waveParameters.waveAirPercentage then @@ -815,9 +815,9 @@ if gadgetHandler:IsSyncedCode() then end end elseif not UnitDefNames[scavName] then - Spring.Echo("[ERROR] Invalid Scav Unit Name", scavName) + SpringShared.Echo("[ERROR] Invalid Scav Unit Name", scavName) else - Spring.Echo("[ERROR] Invalid Scav Squad", scavName) + SpringShared.Echo("[ERROR] Invalid Scav Squad", scavName) end end end @@ -850,16 +850,16 @@ if gadgetHandler:IsSyncedCode() then end end elseif not UnitDefNames[scavName] then - Spring.Echo("[ERROR] Invalid Scav Unit Name", scavName) + SpringShared.Echo("[ERROR] Invalid Scav Unit Name", scavName) else - Spring.Echo("[ERROR] Invalid Scav Squad", scavName) + SpringShared.Echo("[ERROR] Invalid Scav Squad", scavName) end end end end if mRandom() <= 0.5 then for name, data in pairs(squadSpawnOptions.commanders) do - if mRandom() <= config.spawnChance and mRandom(1, SetCount(squadSpawnOptions.commanders)) == 1 and not waveParameters.commanders.waveCommanders[name] and data.minAnger <= waveParameters.waveTechAnger and data.maxAnger >= waveParameters.waveTechAnger and Spring.GetTeamUnitDefCount(scavTeamID, UnitDefNames[name].id) < data.maxAlive and CommandersPopulation + waveParameters.commanders.waveCommanderCount < SetCount(humanTeams) * (waveParameters.waveTechAnger * 0.005) then + if mRandom() <= config.spawnChance and mRandom(1, SetCount(squadSpawnOptions.commanders)) == 1 and not waveParameters.commanders.waveCommanders[name] and data.minAnger <= waveParameters.waveTechAnger and data.maxAnger >= waveParameters.waveTechAnger and SpringShared.GetTeamUnitDefCount(scavTeamID, UnitDefNames[name].id) < data.maxAlive and CommandersPopulation + waveParameters.commanders.waveCommanderCount < SetCount(humanTeams) * (waveParameters.waveTechAnger * 0.005) then waveParameters.commanders.waveCommanders[name] = true waveParameters.commanders.waveCommanderCount = waveParameters.commanders.waveCommanderCount + 1 table.insert(spawnQueue, { burrow = burrowID, unitName = name, team = scavTeamID, squadID = 1 }) @@ -868,7 +868,7 @@ if gadgetHandler:IsSyncedCode() then end else for name, data in pairs(squadSpawnOptions.decoyCommanders) do - if mRandom() <= config.spawnChance and mRandom(1, SetCount(squadSpawnOptions.decoyCommanders)) == 1 and not waveParameters.commanders.waveDecoyCommanders[name] and data.minAnger <= waveParameters.waveTechAnger and data.maxAnger >= waveParameters.waveTechAnger and Spring.GetTeamUnitDefCount(scavTeamID, UnitDefNames[name].id) < data.maxAlive and DecoyCommandersPopulation + waveParameters.commanders.waveDecoyCommanderCount < SetCount(humanTeams) * (waveParameters.waveTechAnger * 0.005) then + if mRandom() <= config.spawnChance and mRandom(1, SetCount(squadSpawnOptions.decoyCommanders)) == 1 and not waveParameters.commanders.waveDecoyCommanders[name] and data.minAnger <= waveParameters.waveTechAnger and data.maxAnger >= waveParameters.waveTechAnger and SpringShared.GetTeamUnitDefCount(scavTeamID, UnitDefNames[name].id) < data.maxAlive and DecoyCommandersPopulation + waveParameters.commanders.waveDecoyCommanderCount < SetCount(humanTeams) * (waveParameters.waveTechAnger * 0.005) then waveParameters.commanders.waveDecoyCommanders[name] = true waveParameters.commanders.waveDecoyCommanderCount = waveParameters.commanders.waveDecoyCommanderCount + 1 table.insert(spawnQueue, { burrow = burrowID, unitName = name, team = scavTeamID, squadID = 1 }) @@ -882,7 +882,7 @@ if gadgetHandler:IsSyncedCode() then function SetupBurrow(unitID, x, y, z) burrows[unitID] = { - lastBackupSpawn = Spring.GetGameFrame(), + lastBackupSpawn = SpringShared.GetGameFrame(), } SetUnitBlocking(unitID, false, false) setScavXP(unitID) @@ -901,7 +901,7 @@ if gadgetHandler:IsSyncedCode() then for _ = 1, 1000 do spawnPosX = mRandom(spread, MAPSIZEX - spread) spawnPosZ = mRandom(spread, MAPSIZEZ - spread) - spawnPosY = Spring.GetGroundHeight(spawnPosX, spawnPosZ) + spawnPosY = SpringShared.GetGroundHeight(spawnPosX, spawnPosZ) canSpawnBurrow = positionCheckLibrary.FlatAreaCheck(spawnPosX, spawnPosY, spawnPosZ, spread, 30, true) if canSpawnBurrow then canSpawnBurrow = positionCheckLibrary.OccupancyCheck(spawnPosX, spawnPosY, spawnPosZ, spread) @@ -924,7 +924,7 @@ if gadgetHandler:IsSyncedCode() then for _ = 1, 1000 do spawnPosX = mRandom(lsx1 + spread, lsx2 - spread) spawnPosZ = mRandom(lsz1 + spread, lsz2 - spread) - spawnPosY = Spring.GetGroundHeight(spawnPosX, spawnPosZ) + spawnPosY = SpringShared.GetGroundHeight(spawnPosX, spawnPosZ) canSpawnBurrow = positionCheckLibrary.FlatAreaCheck(spawnPosX, spawnPosY, spawnPosZ, spread, 30, true) if canSpawnBurrow then canSpawnBurrow = positionCheckLibrary.OccupancyCheck(spawnPosX, spawnPosY, spawnPosZ, spread) @@ -947,7 +947,7 @@ if gadgetHandler:IsSyncedCode() then for _ = 1, 100 do spawnPosX = mRandom(ScavStartboxXMin + spread, ScavStartboxXMax - spread) spawnPosZ = mRandom(ScavStartboxZMin + spread, ScavStartboxZMax - spread) - spawnPosY = Spring.GetGroundHeight(spawnPosX, spawnPosZ) + spawnPosY = SpringShared.GetGroundHeight(spawnPosX, spawnPosZ) canSpawnBurrow = positionCheckLibrary.FlatAreaCheck(spawnPosX, spawnPosY, spawnPosZ, spread, 30, true) if canSpawnBurrow then canSpawnBurrow = positionCheckLibrary.OccupancyCheck(spawnPosX, spawnPosY, spawnPosZ, spread) @@ -968,7 +968,7 @@ if gadgetHandler:IsSyncedCode() then for _ = 1, 100 do -- Attempt #1 Avoid all sensors spawnPosX = mRandom(lsx1 + spread, lsx2 - spread) spawnPosZ = mRandom(lsz1 + spread, lsz2 - spread) - spawnPosY = Spring.GetGroundHeight(spawnPosX, spawnPosZ) + spawnPosY = SpringShared.GetGroundHeight(spawnPosX, spawnPosZ) canSpawnBurrow = positionCheckLibrary.FlatAreaCheck(spawnPosX, spawnPosY, spawnPosZ, spread, 30, true) if canSpawnBurrow then canSpawnBurrow = positionCheckLibrary.OccupancyCheck(spawnPosX, spawnPosY, spawnPosZ, spread) @@ -985,7 +985,7 @@ if gadgetHandler:IsSyncedCode() then for _ = 1, 100 do spawnPosX = mRandom(lsx1 + spread, lsx2 - spread) spawnPosZ = mRandom(lsz1 + spread, lsz2 - spread) - spawnPosY = Spring.GetGroundHeight(spawnPosX, spawnPosZ) + spawnPosY = SpringShared.GetGroundHeight(spawnPosX, spawnPosZ) canSpawnBurrow = positionCheckLibrary.FlatAreaCheck(spawnPosX, spawnPosY, spawnPosZ, spread, 30, true) if canSpawnBurrow then canSpawnBurrow = positionCheckLibrary.OccupancyCheck(spawnPosX, spawnPosY, spawnPosZ, spread) @@ -1003,7 +1003,7 @@ if gadgetHandler:IsSyncedCode() then for _ = 1, 100 do spawnPosX = mRandom(lsx1 + spread, lsx2 - spread) spawnPosZ = mRandom(lsz1 + spread, lsz2 - spread) - spawnPosY = Spring.GetGroundHeight(spawnPosX, spawnPosZ) + spawnPosY = SpringShared.GetGroundHeight(spawnPosX, spawnPosZ) canSpawnBurrow = positionCheckLibrary.FlatAreaCheck(spawnPosX, spawnPosY, spawnPosZ, spread, 30, true) if canSpawnBurrow then canSpawnBurrow = positionCheckLibrary.OccupancyCheck(spawnPosX, spawnPosY, spawnPosZ, spread) @@ -1034,8 +1034,8 @@ if gadgetHandler:IsSyncedCode() then local burrowID = CreateUnit(name, spawnPosX, spawnPosY, spawnPosZ, mRandom(0, 3), scavTeamID) if burrowID then SetupBurrow(burrowID, spawnPosX, spawnPosY, spawnPosZ) - Spring.SpawnCEG("commander-spawn-alwaysvisible", spawnPosX, spawnPosY, spawnPosZ, 0, 0, 0) - Spring.PlaySoundFile("commanderspawn-mono", 0.15, spawnPosX, spawnPosY, spawnPosZ, 0, 0, 0, "sfx") + SpringSynced.SpawnCEG("commander-spawn-alwaysvisible", spawnPosX, spawnPosY, spawnPosZ, 0, 0, 0) + SpringUnsynced.PlaySoundFile("commanderspawn-mono", 0.15, spawnPosX, spawnPosY, spawnPosZ, 0, 0, 0, "sfx") GG.ComSpawnDefoliate(spawnPosX, spawnPosY, spawnPosZ) break end @@ -1097,7 +1097,7 @@ if gadgetHandler:IsSyncedCode() then if sx and sy and sz then if bestBurrowID then - Spring.DestroyUnit(bestBurrowID, true, false) + SpringSynced.DestroyUnit(bestBurrowID, true, false) end return CreateUnit(config.bossName, sx, sy, sz, mRandom(0, 3), scavTeamID), burrowID end @@ -1186,7 +1186,7 @@ if gadgetHandler:IsSyncedCode() then local couldDetermineDifficulty = calculateDifficultyMultiplier(peakScavPower, totalPlayerTeamPower) squadManagerKillerLoop() - Spring.Log("Dynamic Difficulty", LOG.INFO, "Scavengers dynamicDifficultyClamped: " .. tostring(dynamicDifficultyClamped)) + SpringShared.Log("Dynamic Difficulty", LOG.INFO, "Scavengers dynamicDifficultyClamped: " .. tostring(dynamicDifficultyClamped)) waveParameters.baseCooldown = waveParameters.baseCooldown - 1 waveParameters.airWave.cooldown = waveParameters.airWave.cooldown - 1 @@ -1312,7 +1312,7 @@ if gadgetHandler:IsSyncedCode() then local airRandom = mRandom(1, 100) local specialRandom = mRandom(1, 100) local squad - local burrowX, burrowY, burrowZ = Spring.GetUnitPosition(burrowID) + local burrowX, burrowY, burrowZ = SpringShared.GetUnitPosition(burrowID) local surface = positionCheckLibrary.LandOrSeaCheck(burrowX, burrowY, burrowZ, config.burrowSize) if waveParameters.waveTechAnger > config.airStartAnger and airRandom <= waveParameters.waveAirPercentage then for _ = 1, 1000 do @@ -1380,9 +1380,9 @@ if gadgetHandler:IsSyncedCode() then end end elseif not UnitDefNames[scavName] then - Spring.Echo("[ERROR] Invalid Scav Unit Name", scavName) + SpringShared.Echo("[ERROR] Invalid Scav Unit Name", scavName) else - Spring.Echo("[ERROR] Invalid Scav Squad", scavName) + SpringShared.Echo("[ERROR] Invalid Scav Squad", scavName) end end end @@ -1416,16 +1416,16 @@ if gadgetHandler:IsSyncedCode() then end end elseif not UnitDefNames[scavName] then - Spring.Echo("[ERROR] Invalid Scav Unit Name", scavName) + SpringShared.Echo("[ERROR] Invalid Scav Unit Name", scavName) else - Spring.Echo("[ERROR] Invalid Scav Squad", scavName) + SpringShared.Echo("[ERROR] Invalid Scav Squad", scavName) end end end end if mRandom() <= 0.5 then for name, data in pairs(squadSpawnOptions.commanders) do - if mRandom() <= config.spawnChance and mRandom(1, SetCount(squadSpawnOptions.commanders)) == 1 and not waveParameters.commanders.waveCommanders[name] and data.minAnger <= waveParameters.waveTechAnger and data.maxAnger >= waveParameters.waveTechAnger and Spring.GetTeamUnitDefCount(scavTeamID, UnitDefNames[name].id) < data.maxAlive and CommandersPopulation + waveParameters.commanders.waveCommanderCount < SetCount(humanTeams) * (waveParameters.waveTechAnger * 0.005) then + if mRandom() <= config.spawnChance and mRandom(1, SetCount(squadSpawnOptions.commanders)) == 1 and not waveParameters.commanders.waveCommanders[name] and data.minAnger <= waveParameters.waveTechAnger and data.maxAnger >= waveParameters.waveTechAnger and SpringShared.GetTeamUnitDefCount(scavTeamID, UnitDefNames[name].id) < data.maxAlive and CommandersPopulation + waveParameters.commanders.waveCommanderCount < SetCount(humanTeams) * (waveParameters.waveTechAnger * 0.005) then waveParameters.commanders.waveCommanders[name] = true waveParameters.commanders.waveCommanderCount = waveParameters.commanders.waveCommanderCount + 1 table.insert(spawnQueue, { burrow = burrowID, unitName = name, team = scavTeamID, squadID = 1 }) @@ -1435,7 +1435,7 @@ if gadgetHandler:IsSyncedCode() then end else for name, data in pairs(squadSpawnOptions.decoyCommanders) do - if mRandom() <= config.spawnChance and mRandom(1, SetCount(squadSpawnOptions.decoyCommanders)) == 1 and not waveParameters.commanders.waveDecoyCommanders[name] and data.minAnger <= waveParameters.waveTechAnger and data.maxAnger >= waveParameters.waveTechAnger and Spring.GetTeamUnitDefCount(scavTeamID, UnitDefNames[name].id) < data.maxAlive and DecoyCommandersPopulation + waveParameters.commanders.waveDecoyCommanderCount < SetCount(humanTeams) * (waveParameters.waveTechAnger * 0.005) then + if mRandom() <= config.spawnChance and mRandom(1, SetCount(squadSpawnOptions.decoyCommanders)) == 1 and not waveParameters.commanders.waveDecoyCommanders[name] and data.minAnger <= waveParameters.waveTechAnger and data.maxAnger >= waveParameters.waveTechAnger and SpringShared.GetTeamUnitDefCount(scavTeamID, UnitDefNames[name].id) < data.maxAlive and DecoyCommandersPopulation + waveParameters.commanders.waveDecoyCommanderCount < SetCount(humanTeams) * (waveParameters.waveTechAnger * 0.005) then waveParameters.commanders.waveDecoyCommanders[name] = true waveParameters.commanders.waveDecoyCommanderCount = waveParameters.commanders.waveDecoyCommanderCount + 1 table.insert(spawnQueue, { burrow = burrowID, unitName = name, team = scavTeamID, squadID = 1 }) @@ -1482,7 +1482,7 @@ if gadgetHandler:IsSyncedCode() then for _ = 1, 5 do spawnPosX = mRandom(spread, MAPSIZEX - spread) spawnPosZ = mRandom(spread, MAPSIZEZ - spread) - spawnPosY = Spring.GetGroundHeight(spawnPosX, spawnPosZ) + spawnPosY = SpringShared.GetGroundHeight(spawnPosX, spawnPosZ) canSpawnStructure = positionCheckLibrary.FlatAreaCheck(spawnPosX, spawnPosY, spawnPosZ, spread, 30, true) if canSpawnStructure then canSpawnStructure = positionCheckLibrary.OccupancyCheck(spawnPosX, spawnPosY, spawnPosZ, spread) @@ -1502,7 +1502,7 @@ if gadgetHandler:IsSyncedCode() then for _ = 1, 5 do spawnPosX = mRandom(lsx1 + spread, lsx2 - spread) spawnPosZ = mRandom(lsz1 + spread, lsz2 - spread) - spawnPosY = Spring.GetGroundHeight(spawnPosX, spawnPosZ) + spawnPosY = SpringShared.GetGroundHeight(spawnPosX, spawnPosZ) canSpawnStructure = positionCheckLibrary.FlatAreaCheck(spawnPosX, spawnPosY, spawnPosZ, spread, 30, true) if canSpawnStructure then canSpawnStructure = positionCheckLibrary.OccupancyCheck(spawnPosX, spawnPosY, spawnPosZ, spread) @@ -1523,7 +1523,7 @@ if gadgetHandler:IsSyncedCode() then end if canSpawnStructure then - local structureUnitID = Spring.CreateUnit(unitDefName, spawnPosX, spawnPosY, spawnPosZ, mRandom(0, 3), scavTeamID) + local structureUnitID = SpringSynced.CreateUnit(unitDefName, spawnPosX, spawnPosY, spawnPosZ, mRandom(0, 3), scavTeamID) if structureUnitID then SetUnitBlocking(structureUnitID, false, false) return structureUnitID, spawnPosX, spawnPosY, spawnPosZ @@ -1547,7 +1547,7 @@ if gadgetHandler:IsSyncedCode() then end --Spring.Echo(uName,"MaxExisting",maxExisting,"MaxAllowed",maxAllowedToSpawn) for i = 1, math.ceil(numOfTurrets) do - if mRandom() < config.spawnChance * math.min((GetGameSeconds() / config.gracePeriodInitial), 1) and UnitDefNames[uName] and (Spring.GetTeamUnitDefCount(scavTeamID, UnitDefNames[uName].id) <= maxAllowedToSpawn) then + if mRandom() < config.spawnChance * math.min((GetGameSeconds() / config.gracePeriodInitial), 1) and UnitDefNames[uName] and (SpringShared.GetTeamUnitDefCount(scavTeamID, UnitDefNames[uName].id) <= maxAllowedToSpawn) then if i <= numOfTurrets or math.random() <= numOfTurrets % 1 then local attempts = 0 local footprintX = UnitDefNames[uName].xsize -- why the fuck is this footprint *2?????? @@ -1562,9 +1562,9 @@ if gadgetHandler:IsSyncedCode() then if turretUnitID then setScavXP(turretUnitID) if UnitDefNames[uName].isFactory then - Spring.GiveOrderToUnit(turretUnitID, CMD.FIGHT, { spawnPosX + mRandom(-256, 256), spawnPosY, spawnPosZ + mRandom(-256, 256) }, { "meta" }) + SpringSynced.GiveOrderToUnit(turretUnitID, CMD.FIGHT, { spawnPosX + mRandom(-256, 256), spawnPosY, spawnPosZ + mRandom(-256, 256) }, { "meta" }) else - Spring.GiveOrderToUnit(turretUnitID, CMD.PATROL, { spawnPosX + mRandom(-128, 128), spawnPosY, spawnPosZ + mRandom(-128, 128) }, { "meta" }) + SpringSynced.GiveOrderToUnit(turretUnitID, CMD.PATROL, { spawnPosX + mRandom(-128, 128), spawnPosY, spawnPosZ + mRandom(-128, 128) }, { "meta" }) end end until turretUnitID or attempts > 10 @@ -1589,30 +1589,30 @@ if gadgetHandler:IsSyncedCode() then local createUnitQueue = {} function gadget:UnitCreated(unitID, unitDefID, unitTeam) if unitTeam == scavTeamID then - local _, maxH = Spring.GetUnitHealth(unitID) - Spring.SetUnitHealth(unitID, maxH) - local x, y, z = Spring.GetUnitPosition(unitID) + local _, maxH = SpringShared.GetUnitHealth(unitID) + SpringSynced.SetUnitHealth(unitID, maxH) + local x, y, z = SpringShared.GetUnitPosition(unitID) if not UnitDefs[unitDefID].customParams.isscavenger then --Spring.Echo(UnitDefs[unitDefID].name, "unit created swap", UnitDefs[unitDefID].customParams.scav_swap_override_created) if not UnitDefs[unitDefID].customParams.scav_swap_override_created then if UnitDefs[unitDefID] and UnitDefs[unitDefID].name and UnitDefNames[UnitDefs[unitDefID].name .. "_scav"] then - createUnitQueue[#createUnitQueue + 1] = { UnitDefs[unitDefID].name .. "_scav", x, y, z, Spring.GetUnitBuildFacing(unitID) or 0, scavTeamID } - Spring.DestroyUnit(unitID, true, true) + createUnitQueue[#createUnitQueue + 1] = { UnitDefs[unitDefID].name .. "_scav", x, y, z, SpringShared.GetUnitBuildFacing(unitID) or 0, scavTeamID } + SpringSynced.DestroyUnit(unitID, true, true) end elseif UnitDefs[unitDefID].customParams.scav_swap_override_created == "delete" then - Spring.DestroyUnit(unitID, true, true) + SpringSynced.DestroyUnit(unitID, true, true) elseif UnitDefs[unitDefID].customParams.scav_swap_override_created ~= "null" then if UnitDefNames[UnitDefs[unitDefID].customParams.scav_swap_override_created] then - createUnitQueue[#createUnitQueue + 1] = { UnitDefs[unitDefID].customParams.scav_swap_override_created, x, y, z, Spring.GetUnitBuildFacing(unitID) or 0, scavTeamID } + createUnitQueue[#createUnitQueue + 1] = { UnitDefs[unitDefID].customParams.scav_swap_override_created, x, y, z, SpringShared.GetUnitBuildFacing(unitID) or 0, scavTeamID } end - Spring.DestroyUnit(unitID, true, true) + SpringSynced.DestroyUnit(unitID, true, true) end return else - Spring.GiveOrderToUnit(unitID, CMD.FIRE_STATE, { config.defaultScavFirestate }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.FIRE_STATE, { config.defaultScavFirestate }, 0) GG.ScavengersSpawnEffectUnitID(unitID) if UnitDefs[unitDefID].canCloak then - Spring.GiveOrderToUnit(unitID, 37382, { 1 }, 0) + SpringSynced.GiveOrderToUnit(unitID, 37382, { 1 }, 0) end if squadSpawnOptions.commanders[UnitDefs[unitDefID].name] then CommandersPopulation = CommandersPopulation + 1 @@ -1784,8 +1784,8 @@ if gadgetHandler:IsSyncedCode() then curH = math.max(curH, maxH * 0.05) local spawnChance = math.max(0, math.ceil(curH / maxH * 10000)) if mRandom(0, spawnChance) == 1 then - SpawnMinions(unitID, Spring.GetUnitDefID(unitID)) - SpawnMinions(unitID, Spring.GetUnitDefID(unitID)) + SpawnMinions(unitID, SpringShared.GetUnitDefID(unitID)) + SpawnMinions(unitID, SpringShared.GetUnitDefID(unitID)) end end if attackerTeam and attackerTeam ~= scavTeamID then @@ -1808,16 +1808,16 @@ if gadgetHandler:IsSyncedCode() then function gadget:SetInitialSpawnBox() if config.burrowSpawnType == "initialbox" or config.burrowSpawnType == "alwaysbox" or config.burrowSpawnType == "initialbox_post" then - local _, _, _, _, _, luaAllyID = Spring.GetTeamInfo(scavTeamID, false) + local _, _, _, _, _, luaAllyID = SpringShared.GetTeamInfo(scavTeamID, false) if luaAllyID then lsx1, lsz1, lsx2, lsz2 = ScavStartboxXMin, ScavStartboxZMin, ScavStartboxXMax, ScavStartboxZMax if not lsx1 or not lsz1 or not lsx2 or not lsz2 then config.burrowSpawnType = "avoid" - Spring.Log(gadget:GetInfo().name, LOG.INFO, "No Scav start box available, Burrow Placement set to 'Avoid Players'") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "No Scav start box available, Burrow Placement set to 'Avoid Players'") noScavStartbox = true elseif lsx1 == 0 and lsz1 == 0 and lsx2 == Game.mapSizeX and lsz2 == Game.mapSizeX then config.burrowSpawnType = "avoid" - Spring.Log(gadget:GetInfo().name, LOG.INFO, "No Scav start box available, Burrow Placement set to 'Avoid Players'") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "No Scav start box available, Burrow Placement set to 'Avoid Players'") noScavStartbox = true end end @@ -1886,8 +1886,8 @@ if gadgetHandler:IsSyncedCode() then if config.scavBehaviours.HEALER[UnitDefNames[defs.unitName].id] then squadCreationQueue.role = "healer" squadCreationQueue.regroupenabled = false - if squadCreationQueue.life < math.ceil(20 * Spring.GetModOptions().scav_spawntimemult) then - squadCreationQueue.life = math.ceil(20 * Spring.GetModOptions().scav_spawntimemult) + if squadCreationQueue.life < math.ceil(20 * SpringShared.GetModOptions().scav_spawntimemult) then + squadCreationQueue.life = math.ceil(20 * SpringShared.GetModOptions().scav_spawntimemult) end end if config.scavBehaviours.ARTILLERY[UnitDefNames[defs.unitName].id] then @@ -1897,19 +1897,19 @@ if gadgetHandler:IsSyncedCode() then if config.scavBehaviours.KAMIKAZE[UnitDefNames[defs.unitName].id] then squadCreationQueue.role = "kamikaze" squadCreationQueue.regroupenabled = false - if squadCreationQueue.life < math.ceil(100 * Spring.GetModOptions().scav_spawntimemult) then - squadCreationQueue.life = math.ceil(100 * Spring.GetModOptions().scav_spawntimemult) + if squadCreationQueue.life < math.ceil(100 * SpringShared.GetModOptions().scav_spawntimemult) then + squadCreationQueue.life = math.ceil(100 * SpringShared.GetModOptions().scav_spawntimemult) end end if UnitDefNames[defs.unitName].canFly then squadCreationQueue.role = "aircraft" squadCreationQueue.regroupenabled = false - if squadCreationQueue.life < math.ceil(100 * Spring.GetModOptions().scav_spawntimemult) then - squadCreationQueue.life = math.ceil(100 * Spring.GetModOptions().scav_spawntimemult) + if squadCreationQueue.life < math.ceil(100 * SpringShared.GetModOptions().scav_spawntimemult) then + squadCreationQueue.life = math.ceil(100 * SpringShared.GetModOptions().scav_spawntimemult) end end if defs.alwaysVisible then - Spring.SetUnitAlwaysVisible(unitID, true) + SpringSynced.SetUnitAlwaysVisible(unitID, true) end GiveOrderToUnit(unitID, CMD.STOP, 0, 0) @@ -1940,11 +1940,11 @@ if gadgetHandler:IsSyncedCode() then spawnQueue = {} scavEvent("boss") -- notify unsynced about boss spawn local _, bossMaxHP = GetUnitHealth(bossID) - Spring.SetUnitHealth(bossID, math.max(bossMaxHP * (techAnger * 0.01), bossMaxHP * 0.2)) + SpringSynced.SetUnitHealth(bossID, math.max(bossMaxHP * (techAnger * 0.01), bossMaxHP * 0.2)) SetUnitExperience(bossID, 0) timeOfLastWave = t burrows[bossID] = { - lastBackupSpawn = Spring.GetGameFrame(), + lastBackupSpawn = SpringShared.GetGameFrame(), } SetUnitBlocking(bossID, false, false) for burrowID, _ in pairs(burrows) do @@ -1954,8 +1954,8 @@ if gadgetHandler:IsSyncedCode() then SpawnRandomOffWaveSquad(burrowID) end end - Spring.SetGameRulesParam("BossFightStarted", 1) - Spring.SetUnitAlwaysVisible(bossID, true) + SpringSynced.SetGameRulesParam("BossFightStarted", 1) + SpringSynced.SetUnitAlwaysVisible(bossID, true) end end end @@ -2049,10 +2049,10 @@ if gadgetHandler:IsSyncedCode() then else currentMaxWaveSize = math.ceil((minWaveSize + math.ceil((techAnger * 0.01) * (maxWaveSize - minWaveSize))) * (config.bossFightWaveSizeScale * 0.01)) end - if pastFirstBoss or Spring.GetModOptions().scav_graceperiodmult <= 1 then - techAnger = (t - config.gracePeriodInitial) / ((bossTime / Spring.GetModOptions().scav_bosstimemult) - config.gracePeriodInitial) * 100 + if pastFirstBoss or SpringShared.GetModOptions().scav_graceperiodmult <= 1 then + techAnger = (t - config.gracePeriodInitial) / ((bossTime / SpringShared.GetModOptions().scav_bosstimemult) - config.gracePeriodInitial) * 100 else - techAnger = (t - (config.gracePeriodInitial / Spring.GetModOptions().scav_graceperiodmult)) / ((bossTime / Spring.GetModOptions().scav_bosstimemult) - (config.gracePeriodInitial / Spring.GetModOptions().scav_graceperiodmult)) * 100 + techAnger = (t - (config.gracePeriodInitial / SpringShared.GetModOptions().scav_graceperiodmult)) / ((bossTime / SpringShared.GetModOptions().scav_bosstimemult) - (config.gracePeriodInitial / SpringShared.GetModOptions().scav_graceperiodmult)) * 100 end --techAnger = (t - config.gracePeriodInitial) / ((bossTime/(Spring.GetModOptions().scav_bosstimemult)) - config.gracePeriodInitial) * 100 techAnger = math.ceil(techAnger * ((config.economyScale * 0.5) + 0.5)) @@ -2067,7 +2067,7 @@ if gadgetHandler:IsSyncedCode() then minBurrows = 1 else bossAnger = 100 - if Spring.GetModOptions().scav_endless then + if SpringShared.GetModOptions().scav_endless then minBurrows = 4 else minBurrows = 1 @@ -2194,7 +2194,7 @@ if gadgetHandler:IsSyncedCode() then captureProgress = captureProgress / math.max(0.000001, (health / maxHealth) ^ 3) end captureProgress = math.min(0.05, captureProgress) - if Spring.GetUnitTeam(unitID) ~= scavTeamID and GG.IsPosInRaptorScum(ux, uy, uz) then + if SpringShared.GetUnitTeam(unitID) ~= scavTeamID and GG.IsPosInRaptorScum(ux, uy, uz) then if captureLevel + captureProgress >= 0.99 then SpawnCEG("scavmist", ux, uy + 100, uz, 0, 0, 0) SpawnCEG("scavradiation", ux, uy + 100, uz, 0, 0, 0) @@ -2216,7 +2216,7 @@ if gadgetHandler:IsSyncedCode() then if mRandom() <= 0.1 then SpawnCEG("scavmist", ux, uy + 100, uz, 0, 0, 0) end - if mRandom(0, 60) == 0 and mRandom() <= config.spawnChance and Spring.GetUnitTeam(unitID) ~= gaiaTeamID and waveParameters.lastBackupSquadSpawnFrame + 300 < GetGameFrame() then + if mRandom(0, 60) == 0 and mRandom() <= config.spawnChance and SpringShared.GetUnitTeam(unitID) ~= gaiaTeamID and waveParameters.lastBackupSquadSpawnFrame + 300 < GetGameFrame() then local burrow, distance = getNearestScavBeacon(ux, uy, uz) --Spring.Echo("Nearest Beacon Distance", distance) if ux and burrow and distance and distance < 2500 then @@ -2231,7 +2231,7 @@ if gadgetHandler:IsSyncedCode() then end GG.addUnitToCaptureDecay(unitID) end - elseif Spring.GetUnitTeam(unitID) == scavTeamID and captureLevel > 0 then + elseif SpringShared.GetUnitTeam(unitID) == scavTeamID and captureLevel > 0 then GG.addUnitToCaptureDecay(unitID) end end @@ -2353,40 +2353,40 @@ if gadgetHandler:IsSyncedCode() then SetGameRulesParam("scavBossesKilled", nKilledBosses) if nKilledBosses >= nTotalBosses then - Spring.SetGameRulesParam("BossFightStarted", 0) + SpringSynced.SetGameRulesParam("BossFightStarted", 0) - if Spring.GetModOptions().scav_endless then + if SpringShared.GetModOptions().scav_endless then updateDifficultyForSurvival() - Spring.SetGameRulesParam("scavBossAnger", 0) - Spring.SetGameRulesParam("scavBossHealth", 0) - Spring.SetGameRulesParam("scavTechAnger", 0) + SpringSynced.SetGameRulesParam("scavBossAnger", 0) + SpringSynced.SetGameRulesParam("scavBossHealth", 0) + SpringSynced.SetGameRulesParam("scavTechAnger", 0) else gameOver = GetGameFrame() + 200 - Spring.SetGameRulesParam("scavBossAnger", 0) - Spring.SetGameRulesParam("scavBossHealth", 0) - Spring.SetGameRulesParam("scavTechAnger", 0) + SpringSynced.SetGameRulesParam("scavBossAnger", 0) + SpringSynced.SetGameRulesParam("scavBossHealth", 0) + SpringSynced.SetGameRulesParam("scavTechAnger", 0) spawnQueue = {} if not killedScavsAllyTeam then killedScavsAllyTeam = true -- kill scav team - Spring.KillTeam(scavTeamID) + SpringSynced.KillTeam(scavTeamID) -- check if scavengers are in the same allyteam and alive local scavengersFoundAlive = false - for _, teamID in ipairs(Spring.GetTeamList(scavAllyTeamID)) do - local luaAI = Spring.GetTeamLuaAI(teamID) - if luaAI and luaAI:find("Scavengers") and not select(3, Spring.GetTeamInfo(teamID, false)) then + for _, teamID in ipairs(SpringShared.GetTeamList(scavAllyTeamID)) do + local luaAI = SpringShared.GetTeamLuaAI(teamID) + if luaAI and luaAI:find("Scavengers") and not select(3, SpringShared.GetTeamInfo(teamID, false)) then scavengersFoundAlive = true end end -- kill whole allyteam if not scavengersFoundAlive then - for _, teamID in ipairs(Spring.GetTeamList(scavAllyTeamID)) do - if not select(3, Spring.GetTeamInfo(teamID, false)) then - Spring.KillTeam(teamID) + for _, teamID in ipairs(SpringShared.GetTeamList(scavAllyTeamID)) do + if not select(3, SpringShared.GetTeamInfo(teamID, false)) then + SpringSynced.KillTeam(teamID) end end end @@ -2398,7 +2398,7 @@ if gadgetHandler:IsSyncedCode() then if burrows[unitID] and not gameOver then burrows[unitID] = nil - if attackerID and Spring.GetUnitTeam(attackerID) ~= scavTeamID then + if attackerID and SpringShared.GetUnitTeam(attackerID) ~= scavTeamID then playerAggression = playerAggression + (config.angerBonus / config.scavSpawnMultiplier) config.maxXP = config.maxXP * 1.01 end @@ -2436,11 +2436,9 @@ if gadgetHandler:IsSyncedCode() then --computerTeams[teamID] = nil end - function gadget:FeatureCreated(featureID, featureAllyTeamID) -end + function gadget:FeatureCreated(featureID, featureAllyTeamID) end - function gadget:FeatureDestroyed(featureID, featureAllyTeamID) -end + function gadget:FeatureDestroyed(featureID, featureAllyTeamID) end function gadget:GameOver() -- don't end game in survival mode diff --git a/luarules/gadgets/sfx_notifications.lua b/luarules/gadgets/sfx_notifications.lua index 2dfc5e78c80..67f6297f7bd 100644 --- a/luarules/gadgets/sfx_notifications.lua +++ b/luarules/gadgets/sfx_notifications.lua @@ -13,14 +13,14 @@ function gadget:GetInfo() } end -local spGetPlayerInfo = Spring.GetPlayerInfo +local spGetPlayerInfo = SpringShared.GetPlayerInfo local function GetAllyTeamID(teamID) - return select(6, Spring.GetTeamInfo(teamID, false)) + return select(6, SpringShared.GetTeamInfo(teamID, false)) end local function PlayersInAllyTeamID(allyTeamID) - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() local _, _, spec, _, allyTeam for ct, id in pairs(players) do _, _, spec, _, allyTeam = spGetPlayerInfo(id, false) @@ -32,7 +32,7 @@ local function PlayersInAllyTeamID(allyTeamID) end local function AllButAllyTeamID(allyTeamID) - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() local _, _, spec, _, allyTeam for ct, id in pairs(players) do _, _, spec, _, allyTeam = spGetPlayerInfo(id, false) @@ -70,7 +70,7 @@ if gadgetHandler:IsSyncedCode() then -- UNITS RECEIVED send to all in team function gadget:UnitGiven(unitID, unitDefID, newTeam, oldTeam) if not _G.transferredUnits or not _G.transferredUnits[unitID] then -- exclude upgraded units (t2 mex/geo) because allied players could have done this - local players = Spring.GetPlayerList(newTeam) + local players = SpringShared.GetPlayerList(newTeam) for ct, player in pairs(players) do if tostring(player) then if GetAllyTeamID(newTeam) == GetAllyTeamID(oldTeam) then -- We got it from a teammate @@ -85,15 +85,15 @@ if gadgetHandler:IsSyncedCode() then -- NUKE LAUNCH function gadget:ProjectileCreated(proID, proOwnerID, weaponDefID) - if nukeWeapons[Spring.GetProjectileDefID(proID)] then - local players = AllButAllyTeamID(GetAllyTeamID(Spring.GetUnitTeam(proOwnerID))) + if nukeWeapons[SpringShared.GetProjectileDefID(proID)] then + local players = AllButAllyTeamID(GetAllyTeamID(SpringShared.GetUnitTeam(proOwnerID))) for ct, player in pairs(players) do if tostring(player) then GG["notifications"].queueNotification("NukeLaunched", "playerID", tostring(player)) end end - local players = PlayersInAllyTeamID(GetAllyTeamID(Spring.GetUnitTeam(proOwnerID))) + local players = PlayersInAllyTeamID(GetAllyTeamID(SpringShared.GetUnitTeam(proOwnerID))) for ct, player in pairs(players) do if tostring(player) then GG["notifications"].queueNotification("AlliedNukeLaunched", "playerID", tostring(player)) @@ -104,8 +104,8 @@ if gadgetHandler:IsSyncedCode() then function gadget:UnitSeismicPing(x, y, z, strength, allyTeam, unitID, unitDefID) local event = "UnitDetected/StealthyUnitsDetected" - local players = Spring.GetPlayerList() - local unitAllyTeam = Spring.GetUnitAllyTeam(unitID) + local players = SpringShared.GetPlayerList() + local unitAllyTeam = SpringShared.GetUnitAllyTeam(unitID) local _, _, spec, _, playerAllyTeam for ct, playerID in pairs(players) do if tostring(playerID) then @@ -119,7 +119,7 @@ if gadgetHandler:IsSyncedCode() then else - local enableLastcomNotif = (Spring.GetModOptions().deathmode == "com") + local enableLastcomNotif = (SpringShared.GetModOptions().deathmode == "com") local isCommander = {} local isRadar = {} @@ -167,12 +167,12 @@ else end end - local isSpec = Spring.GetSpectatingState() + local isSpec = SpringUnsynced.GetSpectatingState() local myTeamID = Spring.GetMyTeamID() local myPlayerID = Spring.GetMyPlayerID() local myAllyTeamID = Spring.GetMyAllyTeamID() function gadget:PlayerChanged(playerID) - isSpec = Spring.GetSpectatingState() + isSpec = SpringUnsynced.GetSpectatingState() myTeamID = Spring.GetMyTeamID() myPlayerID = Spring.GetMyPlayerID() myAllyTeamID = Spring.GetMyAllyTeamID() @@ -180,11 +180,11 @@ else local numTeams = 0 local playingAsHorde = false - local myAllyTeamList = Spring.GetTeamList(myAllyTeamID) + local myAllyTeamList = SpringShared.GetTeamList(myAllyTeamID) for _, teamID in ipairs(myAllyTeamList) do numTeams = numTeams + 1 - if select(4, Spring.GetTeamInfo(teamID, false)) then -- is AI? - local luaAI = Spring.GetTeamLuaAI(teamID) + if select(4, SpringShared.GetTeamInfo(teamID, false)) then -- is AI? + local luaAI = SpringShared.GetTeamLuaAI(teamID) if luaAI and luaAI ~= "" then if string.find(luaAI, "Scavengers") or string.find(luaAI, "Raptors") then playingAsHorde = true @@ -200,11 +200,11 @@ else GG["notifications"].queueNotification("LrpcTargetUnits", "playerID", tostring(myPlayerID)) end if isCommander[unitDefID] then - commanderLastDamaged[unitID] = Spring.GetGameFrame() + commanderLastDamaged[unitID] = SpringShared.GetGameFrame() end if unitTeam == myTeamID and attackerTeam and GetAllyTeamID(attackerTeam) ~= myAllyTeamID and not isObjectified[unitDefID] then if isCommander[unitDefID] then - local health, maxhealth = Spring.GetUnitHealth(unitID) + local health, maxhealth = SpringShared.GetUnitHealth(unitID) local healthPercent = health / maxhealth if healthPercent < 0.2 then GG["notifications"].queueNotification("ComHeavyDamage", "playerID", tostring(myPlayerID)) @@ -223,8 +223,7 @@ else end end - function gadget:GameFrame(frame) -end + function gadget:GameFrame(frame) end function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam, weaponDefID) --local unitInView = Spring.IsUnitInView(unitID) @@ -246,10 +245,10 @@ end end end - if isCommander[unitDefID] and not select(3, Spring.GetTeamInfo(unitTeam)) and not Spring.GetUnitRulesParam(unitID, "muteDestructionNotification") then + if isCommander[unitDefID] and not select(3, SpringShared.GetTeamInfo(unitTeam)) and not SpringShared.GetUnitRulesParam(unitID, "muteDestructionNotification") then local myComCount = 0 local allyComCount = 0 - local myAllyTeamList = Spring.GetTeamList(myAllyTeamID) + local myAllyTeamList = SpringShared.GetTeamList(myAllyTeamID) for _, teamID in ipairs(myAllyTeamList) do if unitTeam == teamID then allyComCount = allyComCount - 1 -- current com death has not been subtracted from GetTeamUnitDefCount yet, so we do this manually @@ -258,7 +257,7 @@ end end end for unitDefID, _ in pairs(isCommander) do - local comCount = Spring.GetTeamUnitDefCount(teamID, unitDefID) + local comCount = SpringShared.GetTeamUnitDefCount(teamID, unitDefID) allyComCount = allyComCount + comCount if teamID == myTeamID and comCount > 0 then myComCount = myComCount + comCount @@ -267,13 +266,13 @@ end end if (not isSpec) and (unitTeam ~= myTeamID) then if numTeams > 1 and not playingAsHorde then - local players = PlayersInAllyTeamID(GetAllyTeamID(Spring.GetUnitTeam(unitID))) + local players = PlayersInAllyTeamID(GetAllyTeamID(SpringShared.GetUnitTeam(unitID))) for ct, player in pairs(players) do if tostring(player) then --if not unitInView then - if Spring.GetUnitRulesParam(unitID, "unit_evolved") then + if SpringShared.GetUnitRulesParam(unitID, "unit_evolved") then - elseif not attackerTeam and select(6, Spring.GetTeamInfo(unitTeam, false)) == myAllyTeamID and (not commanderLastDamaged[unitID] or commanderLastDamaged[unitID] + 150 < Spring.GetGameFrame()) then + elseif not attackerTeam and select(6, SpringShared.GetTeamInfo(unitTeam, false)) == myAllyTeamID and (not commanderLastDamaged[unitID] or commanderLastDamaged[unitID] + 150 < SpringShared.GetGameFrame()) then GG["notifications"].queueNotification("FriendlyCommanderSelfD", "playerID", tostring(player)) else GG["notifications"].queueNotification("FriendlyCommanderDied", "playerID", tostring(player)) @@ -290,30 +289,30 @@ end end end --if not unitInView then - local players = AllButAllyTeamID(GetAllyTeamID(Spring.GetUnitTeam(unitID))) + local players = AllButAllyTeamID(GetAllyTeamID(SpringShared.GetUnitTeam(unitID))) for ct, player in pairs(players) do - if tostring(player) and not Spring.GetUnitRulesParam(unitID, "unit_evolved") then + if tostring(player) and not SpringShared.GetUnitRulesParam(unitID, "unit_evolved") then GG["notifications"].queueNotification("EnemyCommanderDied", "playerID", tostring(player)) end end --end else - local players = PlayersInAllyTeamID(GetAllyTeamID(Spring.GetUnitTeam(unitID))) + local players = PlayersInAllyTeamID(GetAllyTeamID(SpringShared.GetUnitTeam(unitID))) for ct, player in pairs(players) do if tostring(player) then - if Spring.GetUnitRulesParam(unitID, "unit_evolved") then - elseif not attackerTeam and (not commanderLastDamaged[unitID] or commanderLastDamaged[unitID] + 150 < Spring.GetGameFrame()) then + if SpringShared.GetUnitRulesParam(unitID, "unit_evolved") then + elseif not attackerTeam and (not commanderLastDamaged[unitID] or commanderLastDamaged[unitID] + 150 < SpringShared.GetGameFrame()) then GG["notifications"].queueNotification("NeutralCommanderSelfD", "playerID", tostring(player), true) else GG["notifications"].queueNotification("NeutralCommanderDied", "playerID", tostring(player), true) end end end - local players = AllButAllyTeamID(GetAllyTeamID(Spring.GetUnitTeam(unitID))) + local players = AllButAllyTeamID(GetAllyTeamID(SpringShared.GetUnitTeam(unitID))) for ct, player in pairs(players) do if tostring(player) then - if Spring.GetUnitRulesParam(unitID, "unit_evolved") then - elseif not attackerTeam and (not commanderLastDamaged[unitID] or commanderLastDamaged[unitID] + 150 < Spring.GetGameFrame()) then + if SpringShared.GetUnitRulesParam(unitID, "unit_evolved") then + elseif not attackerTeam and (not commanderLastDamaged[unitID] or commanderLastDamaged[unitID] + 150 < SpringShared.GetGameFrame()) then GG["notifications"].queueNotification("NeutralCommanderSelfD", "playerID", tostring(player), true) else GG["notifications"].queueNotification("NeutralCommanderDied", "playerID", tostring(player), true) diff --git a/luarules/gadgets/sfx_notifications_broadcaster.lua b/luarules/gadgets/sfx_notifications_broadcaster.lua index 7a86bdbff97..a5d825549c3 100644 --- a/luarules/gadgets/sfx_notifications_broadcaster.lua +++ b/luarules/gadgets/sfx_notifications_broadcaster.lua @@ -18,7 +18,7 @@ if not gadgetHandler:IsSyncedCode() then end function BroadcastEvent(_, event, player, forceplay) - if Script.LuaUI("NotificationEvent") and (forceplay or (tonumber(player) and ((tonumber(player) == Spring.GetMyPlayerID()) or Spring.GetSpectatingState()))) then + if Script.LuaUI("NotificationEvent") and (forceplay or (tonumber(player) and ((tonumber(player) == Spring.GetMyPlayerID()) or SpringUnsynced.GetSpectatingState()))) then if forceplay then forceplay = " y" else @@ -41,14 +41,14 @@ GG["notifications"].queueNotification = function(event, idtype, id, forceplay) if idtype == "playerID" then playerIDs[#playerIDs + 1] = id elseif idtype == "teamID" then - local playerList = Spring.GetPlayerList(id) + local playerList = SpringShared.GetPlayerList(id) for i = 1, #playerList do playerIDs[#playerIDs + 1] = playerList[i] end elseif idtype == "allyTeamID" then - local teamList = Spring.GetTeamList(id) + local teamList = SpringShared.GetTeamList(id) for i = 1, #teamList do - local playerList = Spring.GetPlayerList(teamList[i]) + local playerList = SpringShared.GetPlayerList(teamList[i]) for j = 1, #playerList do playerIDs[#playerIDs + 1] = playerList[j] end diff --git a/luarules/gadgets/snd_battle_volume_controller.lua b/luarules/gadgets/snd_battle_volume_controller.lua index 86a7f9b1d13..0dd8ef81e28 100644 --- a/luarules/gadgets/snd_battle_volume_controller.lua +++ b/luarules/gadgets/snd_battle_volume_controller.lua @@ -16,11 +16,11 @@ end local math_clamp = math.clamp local math_sqrt = math.sqrt local math_round = math.round -local spIsUnitInView = Spring.IsUnitInView -local spGetCameraState = Spring.GetCameraState -local spGetConfigFloat = Spring.GetConfigFloat -local spGetConfigInt = Spring.GetConfigInt -local spSetConfigInt = Spring.SetConfigInt +local spIsUnitInView = SpringUnsynced.IsUnitInView +local spGetCameraState = SpringUnsynced.GetCameraState +local spGetConfigFloat = SpringUnsynced.GetConfigFloat +local spGetConfigInt = SpringUnsynced.GetConfigInt +local spSetConfigInt = SpringUnsynced.SetConfigInt local VolumeSetting = spGetConfigInt("snd_volbattle_options", 100) local VolumeTarget = 1 diff --git a/luarules/gadgets/system_info.lua b/luarules/gadgets/system_info.lua index 606a6f40393..b4375b326da 100644 --- a/luarules/gadgets/system_info.lua +++ b/luarules/gadgets/system_info.lua @@ -27,14 +27,14 @@ if gadgetHandler:IsSyncedCode() then else - local chobbyLoaded = (Spring.GetMenuName and string.find(string.lower(Spring.GetMenuName()), "chobby") ~= nil) + local chobbyLoaded = (SpringUnsynced.GetMenuName and string.find(string.lower(SpringUnsynced.GetMenuName()), "chobby") ~= nil) - local SendLuaRulesMsg = Spring.SendLuaRulesMsg + local SendLuaRulesMsg = SpringUnsynced.SendLuaRulesMsg local systems = {} local validation = SYNCED.validationSys local myPlayerID = Spring.GetMyPlayerID() - local myPlayerName = Spring.GetPlayerInfo(myPlayerID) + local myPlayerName = SpringShared.GetPlayerInfo(myPlayerID) local accountID = Spring.Utilities.GetAccountID(myPlayerID) local authorized = SYNCED.permissions.sysinfo[accountID] @@ -65,7 +65,7 @@ else function gadget:Initialize() gadgetHandler:AddSyncAction("systemBroadcast", handleSystemEvent) - Spring.Echo(string.format("infologVersionTags:engine=%s,game=%s,lobby=%s,map=%s", Engine.version or "", (Game.gameName or "") .. " " .. (Game.gameVersion or ""), (VFS and VFS.GetNameFromRapidTag and VFS.GetNameFromRapidTag("byar-chobby:test") or ""), Game.mapName or "")) + SpringShared.Echo(string.format("infologVersionTags:engine=%s,game=%s,lobby=%s,map=%s", Engine.version or "", (Game.gameName or "") .. " " .. (Game.gameVersion or ""), (VFS and VFS.GetNameFromRapidTag and VFS.GetNameFromRapidTag("byar-chobby:test") or ""), Game.mapName or "")) local myvalidation = validation @@ -245,7 +245,7 @@ else function gadget:MapDrawCmd(playerID, cmdType, px, py, pz, labelText) if playerID == myPlayerID and cmdType == "point" and string.len(labelText) > 2 then - local msg = string.format("m@pm@rk%s:%d:%d:%d:%d:%s:%s", validation, Spring.GetGameFrame(), playerID, px, pz, myPlayerName, labelText) + local msg = string.format("m@pm@rk%s:%d:%d:%d:%d:%s:%s", validation, SpringShared.GetGameFrame(), playerID, px, pz, myPlayerName, labelText) SendLuaRulesMsg(msg) end end diff --git a/luarules/gadgets/unit_aa_targeting_priority.lua b/luarules/gadgets/unit_aa_targeting_priority.lua index 640066ca467..16b1925d803 100644 --- a/luarules/gadgets/unit_aa_targeting_priority.lua +++ b/luarules/gadgets/unit_aa_targeting_priority.lua @@ -14,7 +14,7 @@ function gadget:GetInfo() end if gadgetHandler:IsSyncedCode() then - local spGetUnitDefID = Spring.GetUnitDefID + local spGetUnitDefID = SpringShared.GetUnitDefID local stringFind = string.find local targetPriority = { Bombers = 1, @@ -95,6 +95,6 @@ if gadgetHandler:IsSyncedCode() then resultStr = resultStr .. unitDef.name .. ": " .. tostring(count) .. ", " end end - Spring.Echo(resultStr) + SpringShared.Echo(resultStr) end end diff --git a/luarules/gadgets/unit_air_attacksafetydistance.lua b/luarules/gadgets/unit_air_attacksafetydistance.lua index bb4da658182..182881955ef 100644 --- a/luarules/gadgets/unit_air_attacksafetydistance.lua +++ b/luarules/gadgets/unit_air_attacksafetydistance.lua @@ -32,20 +32,20 @@ for udid, ud in pairs(UnitDefs) do end function gadget:Initialize() - for ct, unitID in pairs(Spring.GetAllUnits()) do - gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID)) + for ct, unitID in pairs(SpringShared.GetAllUnits()) do + gadget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID)) end end function gadget:UnitCreated(unitID, unitDefID) if attackSafetyDistance[unitDefID] then - local curMoveCtrl = Spring.MoveCtrl.IsEnabled(unitID) + local curMoveCtrl = SpringSynced.MoveCtrl.IsEnabled(unitID) if curMoveCtrl then - Spring.MoveCtrl.Disable(unitID) + SpringSynced.MoveCtrl.Disable(unitID) end - Spring.MoveCtrl.SetAirMoveTypeData(unitID, "attackSafetyDistance", attackSafetyDistance[unitDefID]) + SpringSynced.MoveCtrl.SetAirMoveTypeData(unitID, "attackSafetyDistance", attackSafetyDistance[unitDefID]) if curMoveCtrl then - Spring.MoveCtrl.Enable(unitID) + SpringSynced.MoveCtrl.Enable(unitID) end end end diff --git a/luarules/gadgets/unit_air_plants.lua b/luarules/gadgets/unit_air_plants.lua index b6142bc9e7c..fe83e4dc563 100644 --- a/luarules/gadgets/unit_air_plants.lua +++ b/luarules/gadgets/unit_air_plants.lua @@ -16,11 +16,11 @@ if not gadgetHandler:IsSyncedCode() then return end -local EditUnitCmdDesc = Spring.EditUnitCmdDesc -local FindUnitCmdDesc = Spring.FindUnitCmdDesc -local InsertUnitCmdDesc = Spring.InsertUnitCmdDesc -local GiveOrderToUnit = Spring.GiveOrderToUnit -local SetUnitNeutral = Spring.SetUnitNeutral +local EditUnitCmdDesc = SpringSynced.EditUnitCmdDesc +local FindUnitCmdDesc = SpringShared.FindUnitCmdDesc +local InsertUnitCmdDesc = SpringSynced.InsertUnitCmdDesc +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit +local SetUnitNeutral = SpringSynced.SetUnitNeutral local CMD_IDLEMODE = CMD.IDLEMODE local CMD_LAND_AT = GameCMD.LAND_AT diff --git a/luarules/gadgets/unit_airtransport_load_unload.lua b/luarules/gadgets/unit_airtransport_load_unload.lua index 55767ce1239..9084127d389 100644 --- a/luarules/gadgets/unit_airtransport_load_unload.lua +++ b/luarules/gadgets/unit_airtransport_load_unload.lua @@ -27,11 +27,11 @@ end if gadgetHandler:IsSyncedCode() then local mathSqrt = math.sqrt - local spGetUnitPosition = Spring.GetUnitPosition - local spAreTeamsAllied = Spring.AreTeamsAllied - local spGetUnitTeam = Spring.GetUnitTeam - local spGetUnitVelocity = Spring.GetUnitVelocity - local spSetUnitVelocity = Spring.SetUnitVelocity + local spGetUnitPosition = SpringShared.GetUnitPosition + local spAreTeamsAllied = SpringShared.AreTeamsAllied + local spGetUnitTeam = SpringShared.GetUnitTeam + local spGetUnitVelocity = SpringShared.GetUnitVelocity + local spSetUnitVelocity = SpringSynced.SetUnitVelocity function gadget:Distance(pos1, pos2) local difX = pos1[1] - pos2[1] diff --git a/luarules/gadgets/unit_airunitsturnradius.lua b/luarules/gadgets/unit_airunitsturnradius.lua index 9ef5ddb10c0..4bd7046037b 100644 --- a/luarules/gadgets/unit_airunitsturnradius.lua +++ b/luarules/gadgets/unit_airunitsturnradius.lua @@ -19,12 +19,12 @@ end local attackTurnRadius = 500 local CMD_ATTACK = CMD.ATTACK -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGetUnitMoveTypeData = Spring.GetUnitMoveTypeData -local spMoveCtrlEnable = Spring.MoveCtrl.Enable -local spMoveCtrlIsEnabled = Spring.MoveCtrl.IsEnabled -local spMoveCtrlDisable = Spring.MoveCtrl.Disable -local spMoveCtrlSetAirMoveTypeData = Spring.MoveCtrl.SetAirMoveTypeData +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGetUnitMoveTypeData = SpringShared.GetUnitMoveTypeData +local spMoveCtrlEnable = SpringSynced.MoveCtrl.Enable +local spMoveCtrlIsEnabled = SpringSynced.MoveCtrl.IsEnabled +local spMoveCtrlDisable = SpringSynced.MoveCtrl.Disable +local spMoveCtrlSetAirMoveTypeData = SpringSynced.MoveCtrl.SetAirMoveTypeData local Bombers = {} local bomberTurnRadius = {} @@ -44,8 +44,8 @@ end function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD.ANY) - for ct, unitID in pairs(Spring.GetAllUnits()) do - gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID)) + for ct, unitID in pairs(SpringShared.GetAllUnits()) do + gadget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID)) end end @@ -74,7 +74,7 @@ local function processNextCmd(unitID, unitDefID, cmdID) local radius = (not cmdID or cmdID == CMD_ATTACK) and attackTurnRadius or bomberTurnRadius[unitDefID] local success = pcall(spMoveCtrlSetAirMoveTypeData, unitID, "turnRadius", radius) if not success then - Spring.Echo("Error: unit_airunitsturnradius incompatible movetype for unitdef " .. UnitDefs[unitDefID].name) + SpringShared.Echo("Error: unit_airunitsturnradius incompatible movetype for unitdef " .. UnitDefs[unitDefID].name) end if curMoveCtrl then spMoveCtrlEnable(unitID) diff --git a/luarules/gadgets/unit_area_timed_damage.lua b/luarules/gadgets/unit_area_timed_damage.lua index ef123b2a1aa..2a0eb99796d 100644 --- a/luarules/gadgets/unit_area_timed_damage.lua +++ b/luarules/gadgets/unit_area_timed_damage.lua @@ -81,16 +81,16 @@ local stringLower = string.lower local tableInsert = table.insert local tableRemove = table.remove -local spAddUnitDamage = Spring.AddUnitDamage -local spAddFeatureDamage = Spring.AddFeatureDamage -local spGetFeaturePosition = Spring.GetFeaturePosition -local spGetFeaturesInCylinder = Spring.GetFeaturesInCylinder -local spGetGroundHeight = Spring.GetGroundHeight -local spGetGroundNormal = Spring.GetGroundNormal -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder -local spSpawnCEG = Spring.SpawnCEG +local spAddUnitDamage = SpringSynced.AddUnitDamage +local spAddFeatureDamage = SpringSynced.AddFeatureDamage +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spGetFeaturesInCylinder = SpringShared.GetFeaturesInCylinder +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetGroundNormal = SpringShared.GetGroundNormal +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local spSpawnCEG = SpringSynced.SpawnCEG local gameSpeed = Game.gameSpeed @@ -481,17 +481,17 @@ function gadget:Initialize() if params.ceg ~= ceg or params.range ~= range then params.ceg = ceg params.range = range - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Set " .. name .. " to range, ceg = " .. range .. ", " .. ceg) + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Set " .. name .. " to range, ceg = " .. range .. ", " .. ceg) end else timedDamageWeapons[weaponDefID] = nil - Spring.Log(gadget:GetInfo().name, LOG.WARN, "Removed " .. name .. " from area timed damage weapons.") + SpringShared.Log(gadget:GetInfo().name, LOG.WARN, "Removed " .. name .. " from area timed damage weapons.") end end end if not next(timedDamageWeapons) then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "No timed areas found. Removing gadget.") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "No timed areas found. Removing gadget.") gadgetHandler:RemoveGadget(self) return end @@ -546,18 +546,18 @@ function gadget:Initialize() aliveExplosions[ii] = {} end - frameNumber = Spring.GetGameFrame() + frameNumber = SpringShared.GetGameFrame() frameExplosions = aliveExplosions[1 + (frameNumber % frameInterval)] for frame = frameNumber - 1, frameNumber + gameSpeed do unitDamageReset[frame] = {} featDamageReset[frame] = {} end - for _, unitID in ipairs(Spring.GetAllUnits()) do + for _, unitID in ipairs(SpringShared.GetAllUnits()) do gadget:UnitCreated(unitID, spGetUnitDefID(unitID)) end - for _, featureID in ipairs(Spring.GetAllFeatures()) do + for _, featureID in ipairs(SpringShared.GetAllFeatures()) do gadget:FeatureCreated(featureID) end end @@ -593,7 +593,7 @@ function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerD end function gadget:FeatureCreated(featureID, allyTeam) - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) featureData[featureID] = { damageTaken = 0, damageImmune = featureDamageImmunity[featureDefID], diff --git a/luarules/gadgets/unit_areaattack.lua b/luarules/gadgets/unit_areaattack.lua index 60fbe799bc4..e10286402ed 100644 --- a/luarules/gadgets/unit_areaattack.lua +++ b/luarules/gadgets/unit_areaattack.lua @@ -50,12 +50,12 @@ if gadgetHandler:IsSyncedCode() then local phase = math_random(200 * math_pi) / 100.0 if o.radius > 0 then local amp = math_random(o.radius) - Spring.GiveOrderToUnit(o.unit, CMD.INSERT, { 0, CMD.ATTACK, 0, o.x + math_cos(phase) * amp, o.y, o.z + math_sin(phase) * amp }, { "alt" }) + SpringSynced.GiveOrderToUnit(o.unit, CMD.INSERT, { 0, CMD.ATTACK, 0, o.x + math_cos(phase) * amp, o.y, o.z + math_sin(phase) * amp }, { "alt" }) end end for i, o in pairs(closeList) do closeList[i] = nil - Spring.SetUnitMoveGoal(o.unit, o.x, o.y, o.z, o.radius) + SpringSynced.SetUnitMoveGoal(o.unit, o.x, o.y, o.z, o.radius) end end @@ -70,7 +70,7 @@ if gadgetHandler:IsSyncedCode() then function gadget:CommandFallback(u, ud, team, cmd, param, opt) if cmd == CMD_AREA_ATTACK_GROUND then - local x, _, z = Spring.GetUnitPosition(u) + local x, _, z = SpringShared.GetUnitPosition(u) if not x then return true, true end @@ -88,7 +88,7 @@ if gadgetHandler:IsSyncedCode() then function gadget:UnitCreated(u, ud, team) if canAreaAttack[ud] then range[ud] = canAreaAttack[ud] -- put the range inside canAreaAttack[ud] - Spring.InsertUnitCmdDesc(u, aadesc) + SpringSynced.InsertUnitCmdDesc(u, aadesc) end end @@ -100,7 +100,7 @@ if gadgetHandler:IsSyncedCode() then else -- UNSYNCED function gadget:Initialize() - Spring.SetCustomCommandDrawData(CMD_AREA_ATTACK_GROUND, CMDTYPE.ICON_UNIT_OR_AREA, { 1, 0, 0, 0.8 }, true) + SpringUnsynced.SetCustomCommandDrawData(CMD_AREA_ATTACK_GROUND, CMDTYPE.ICON_UNIT_OR_AREA, { 1, 0, 0, 0.8 }, true) end end diff --git a/luarules/gadgets/unit_areaattack_limiter.lua b/luarules/gadgets/unit_areaattack_limiter.lua index cc1a09d87ec..bff2e51b258 100644 --- a/luarules/gadgets/unit_areaattack_limiter.lua +++ b/luarules/gadgets/unit_areaattack_limiter.lua @@ -21,8 +21,8 @@ local CMD_AREA_ATTACK = CMD.AREA_ATTACK local CMD_FIGHT = CMD.FIGHT local CMD_STOP = CMD.STOP -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGiveOrderArrayToUnitArray = Spring.GiveOrderArrayToUnitArray +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGiveOrderArrayToUnitArray = SpringSynced.GiveOrderArrayToUnitArray -- Max units allowed to use the expensive engine-side area attack. -- Excess units receive a FIGHT command to the area center instead, diff --git a/luarules/gadgets/unit_attached_con_turret.lua b/luarules/gadgets/unit_attached_con_turret.lua index cce324f6553..a18257505e5 100644 --- a/luarules/gadgets/unit_attached_con_turret.lua +++ b/luarules/gadgets/unit_attached_con_turret.lua @@ -20,28 +20,28 @@ end local CMD_REPAIR = CMD.REPAIR local CMD_RECLAIM = CMD.RECLAIM local CMD_STOP = CMD.STOP -local SpGetUnitCommands = Spring.GetUnitCommands -local SpGiveOrderToUnit = Spring.GiveOrderToUnit -local SpGetUnitPosition = Spring.GetUnitPosition -local SpGetFeaturePosition = Spring.GetFeaturePosition -local SpGetUnitDefID = Spring.GetUnitDefID -local SpGetUnitsInCylinder = Spring.GetUnitsInCylinder -local SpGetUnitAllyTeam = Spring.GetUnitAllyTeam -local SpGetFeaturesInCylinder = Spring.GetFeaturesInCylinder -local SpGetFeatureDefID = Spring.GetFeatureDefID -local SpGetFeatureResurrect = Spring.GetFeatureResurrect -local SpGetUnitHealth = Spring.GetUnitHealth -local SpGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local SpGetUnitDefDimensions = Spring.GetUnitDefDimensions -local SpGetFeatureRadius = Spring.GetFeatureRadius -local SpGetUnitRadius = Spring.GetUnitRadius -local SpGetUnitFeatureSeparation = Spring.GetUnitFeatureSeparation -local SpGetUnitSeparation = Spring.GetUnitSeparation -local SpGetUnitTransporter = Spring.GetUnitTransporter - -local SpGetHeadingFromVector = Spring.GetHeadingFromVector -local SpGetUnitHeading = Spring.GetUnitHeading -local SpCallCOBScript = Spring.CallCOBScript +local SpGetUnitCommands = SpringShared.GetUnitCommands +local SpGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local SpGetUnitPosition = SpringShared.GetUnitPosition +local SpGetFeaturePosition = SpringShared.GetFeaturePosition +local SpGetUnitDefID = SpringShared.GetUnitDefID +local SpGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local SpGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local SpGetFeaturesInCylinder = SpringShared.GetFeaturesInCylinder +local SpGetFeatureDefID = SpringShared.GetFeatureDefID +local SpGetFeatureResurrect = SpringShared.GetFeatureResurrect +local SpGetUnitHealth = SpringShared.GetUnitHealth +local SpGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local SpGetUnitDefDimensions = SpringShared.GetUnitDefDimensions +local SpGetFeatureRadius = SpringShared.GetFeatureRadius +local SpGetUnitRadius = SpringShared.GetUnitRadius +local SpGetUnitFeatureSeparation = SpringShared.GetUnitFeatureSeparation +local SpGetUnitSeparation = SpringShared.GetUnitSeparation +local SpGetUnitTransporter = SpringShared.GetUnitTransporter + +local SpGetHeadingFromVector = SpringShared.GetHeadingFromVector +local SpGetUnitHeading = SpringShared.GetUnitHeading +local SpCallCOBScript = SpringSynced.CallCOBScript --repairs and reclaims start at the edge of the unit radius --so we need to increase our search radius by the maximum unit radius @@ -60,7 +60,7 @@ end local function auto_repair_routine(nanoID, unitDefID, baseUnitID) local transporterID = SpGetUnitTransporter(baseUnitID) if transporterID then - Spring.GiveOrderToUnit(nanoID, CMD_STOP, {}, 0) + SpringSynced.GiveOrderToUnit(nanoID, CMD_STOP, {}, 0) return end -- first, check command the body is performing @@ -208,29 +208,29 @@ function gadget:UnitFinished(unitID, unitDefID, unitTeam) -- for now, just corvac gets an attached con turret if unitDef.name == "corvac" then local xx, yy, zz = SpGetUnitPosition(unitID) - nanoID = Spring.CreateUnit("corvacct", xx, yy, zz, 0, Spring.GetUnitTeam(unitID)) + nanoID = SpringSynced.CreateUnit("corvacct", xx, yy, zz, 0, SpringShared.GetUnitTeam(unitID)) if not nanoID then -- unit limit hit or invalid spawn surface return end - Spring.UnitAttach(unitID, nanoID, 3) + SpringSynced.UnitAttach(unitID, nanoID, 3) -- makes the attached con turret as non-interacting as possible - Spring.SetUnitBlocking(nanoID, false, false, false) - Spring.SetUnitNoSelect(nanoID, true) + SpringSynced.SetUnitBlocking(nanoID, false, false, false) + SpringUnsynced.SetUnitNoSelect(nanoID, true) attached_builders[nanoID] = unitID attached_builder_def[nanoID] = SpGetUnitDefID(nanoID) end if unitDef.name == "legmohobp" then local xx, yy, zz = SpGetUnitPosition(unitID) - nanoID = Spring.CreateUnit("legmohobpct", xx, yy, zz, 0, Spring.GetUnitTeam(unitID)) + nanoID = SpringSynced.CreateUnit("legmohobpct", xx, yy, zz, 0, SpringShared.GetUnitTeam(unitID)) if not nanoID then -- unit limit hit or invalid spawn surface return end - Spring.UnitAttach(unitID, nanoID, 3) + SpringSynced.UnitAttach(unitID, nanoID, 3) -- makes the attached con turret as non-interacting as possible - Spring.SetUnitBlocking(nanoID, false, false, false) - Spring.SetUnitNoSelect(nanoID, false) + SpringSynced.SetUnitBlocking(nanoID, false, false, false) + SpringUnsynced.SetUnitNoSelect(nanoID, false) attached_builders[nanoID] = unitID attached_builder_def[nanoID] = SpGetUnitDefID(nanoID) end diff --git a/luarules/gadgets/unit_attached_con_turret_mex.lua b/luarules/gadgets/unit_attached_con_turret_mex.lua index 74e74284fdb..c21ba173c7a 100644 --- a/luarules/gadgets/unit_attached_con_turret_mex.lua +++ b/luarules/gadgets/unit_attached_con_turret_mex.lua @@ -17,8 +17,8 @@ if not gadgetHandler:IsSyncedCode() then return false end -local spGetUnitHealth = Spring.GetUnitHealth -local spGiveOrderToUnit = Spring.GiveOrderToUnit +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit -- TODO: do not use hardcoded unit names local unitDefData = { @@ -65,60 +65,60 @@ local pairedUnits = {} local setMexSpeed = {} local function setExtractionRate(conID, mexID) - local extractionRate = Spring.GetUnitMetalExtraction(mexID) - Spring.CallCOBScript(conID, "SetSpeed", 0, (extractionRate or 0) * 1000) -- COB is scaled for integer-only + local extractionRate = SpringShared.GetUnitMetalExtraction(mexID) + SpringSynced.CallCOBScript(conID, "SetSpeed", 0, (extractionRate or 0) * 1000) -- COB is scaled for integer-only end local function doSwapMex(unitID, unitTeam, unitData) local Spring = Spring - local isUnitNeutral = Spring.GetUnitNeutral(unitID) + local isUnitNeutral = SpringShared.GetUnitNeutral(unitID) local unitHealth = spGetUnitHealth(unitID) - Spring.DestroyUnit(unitID, false, true) -- clears unitID from mexesToSwap in g:UnitDestroyed + SpringSynced.DestroyUnit(unitID, false, true) -- clears unitID from mexesToSwap in g:UnitDestroyed local ux, uy, uz, unitFacing = unitData.x, unitData.y, unitData.z, unitData.facing - local mexID = Spring.CreateUnit(unitData.swapDefs.mex, ux, uy, uz, unitFacing, unitTeam) + local mexID = SpringSynced.CreateUnit(unitData.swapDefs.mex, ux, uy, uz, unitFacing, unitTeam) if not mexID then - Spring.AddTeamResource(unitTeam, "m", unitData.metal) - Spring.AddTeamResource(unitTeam, "e", unitData.energy) + SpringSynced.AddTeamResource(unitTeam, "m", unitData.metal) + SpringSynced.AddTeamResource(unitTeam, "e", unitData.energy) return end - Spring.SetUnitBlocking(mexID, true, true, false) - Spring.SetUnitNoSelect(mexID, true) - Spring.SetUnitStealth(mexID, true) + SpringSynced.SetUnitBlocking(mexID, true, true, false) + SpringUnsynced.SetUnitNoSelect(mexID, true) + SpringSynced.SetUnitStealth(mexID, true) - local conID = Spring.CreateUnit(unitData.swapDefs.con, ux, uy, uz, unitFacing, unitTeam) + local conID = SpringSynced.CreateUnit(unitData.swapDefs.con, ux, uy, uz, unitFacing, unitTeam) if not conID then - Spring.DestroyUnit(mexID, false, true) - Spring.AddTeamResource(unitTeam, "m", unitData.metal) - Spring.AddTeamResource(unitTeam, "e", unitData.energy) + SpringSynced.DestroyUnit(mexID, false, true) + SpringSynced.AddTeamResource(unitTeam, "m", unitData.metal) + SpringSynced.AddTeamResource(unitTeam, "e", unitData.energy) return end - Spring.SetUnitHealth(conID, unitHealth) + SpringSynced.SetUnitHealth(conID, unitHealth) -- TODO: Get attachment piece by customparam. - Spring.UnitAttach(mexID, conID, 6, true) - Spring.SetUnitRulesParam(conID, "pairedUnitID", mexID) - Spring.SetUnitRulesParam(mexID, "pairedUnitID", conID) + SpringSynced.UnitAttach(mexID, conID, 6, true) + SpringSynced.SetUnitRulesParam(conID, "pairedUnitID", mexID) + SpringSynced.SetUnitRulesParam(mexID, "pairedUnitID", conID) pairedUnits[conID] = mexID pairedUnits[mexID] = conID setMexSpeed[conID] = mexID if isUnitNeutral then - Spring.SetUnitNeutral(mexID, true) - Spring.SetUnitNeutral(conID, true) + SpringSynced.SetUnitNeutral(mexID, true) + SpringSynced.SetUnitNeutral(conID, true) end end local function trySwapMex(unitID, unitData) - if Spring.GetUnitIsDead(unitID) ~= false then + if SpringShared.GetUnitIsDead(unitID) ~= false then return end - local unitTeam = Spring.GetUnitTeam(unitID) - local unitMax, unitCount = Spring.GetTeamMaxUnits(unitTeam) + local unitTeam = SpringShared.GetUnitTeam(unitID) + local unitMax, unitCount = SpringShared.GetTeamMaxUnits(unitTeam) if not unitCount or unitMax < unitCount + 2 then return @@ -143,18 +143,18 @@ end function gadget:UnitFinished(unitID, unitDefID, unitTeam) if fakeBuildDefID[unitDefID] then local swapDefs = fakeBuildDefID[unitDefID] - local ux, uy, uz = Spring.GetUnitPosition(unitID) - local _, metalCost, energyCost = Spring.GetUnitCosts(unitID) + local ux, uy, uz = SpringShared.GetUnitPosition(unitID) + local _, metalCost, energyCost = SpringShared.GetUnitCosts(unitID) mexesToSwap[unitID] = { swapDefs = swapDefs, x = ux, y = uy, z = uz, - facing = Spring.GetUnitBuildFacing(unitID), + facing = SpringShared.GetUnitBuildFacing(unitID), metal = metalCost, energy = energyCost, - frame = Spring.GetGameFrame() + 1, + frame = SpringShared.GetGameFrame() + 1, } end end @@ -162,11 +162,11 @@ end function gadget:UnitGiven(unitID, unitDefID, newTeam, oldTeam) if mexTurretDefID[unitDefID] then local pairedID = pairedUnits[unitID] - if not pairedID and Spring.GetUnitRulesParam then - pairedID = Spring.GetUnitRulesParam(unitID, "pairedUnitID") + if not pairedID and SpringShared.GetUnitRulesParam then + pairedID = SpringShared.GetUnitRulesParam(unitID, "pairedUnitID") end if pairedID and pairedID ~= 0 then - Spring.TransferUnit(pairedID, newTeam) + SpringSynced.TransferUnit(pairedID, newTeam) end end end @@ -176,17 +176,17 @@ local function doUnitDamaged(unitID, unitDefID, unitTeam, damage) if health - damage < 0 and damage < maxHealth * 0.5 then local buildAsUnitName = mexTurretDefID[unitDefID] - local xx, yy, zz = Spring.GetUnitPosition(unitID) - local facing = Spring.GetUnitBuildFacing(unitID) + local xx, yy, zz = SpringShared.GetUnitPosition(unitID) + local facing = SpringShared.GetUnitBuildFacing(unitID) -- todo: "damage" is not "recent damage" is not "damage severity" if damage < maxHealth * 0.25 then - local featureID = Spring.CreateFeature(buildAsUnitName .. "_dead", xx, yy, zz, facing, unitTeam) + local featureID = SpringSynced.CreateFeature(buildAsUnitName .. "_dead", xx, yy, zz, facing, unitTeam) if featureID then - Spring.SetFeatureResurrect(featureID, buildAsUnitName, facing, 0) + SpringSynced.SetFeatureResurrect(featureID, buildAsUnitName, facing, 0) end else - Spring.CreateFeature(buildAsUnitName .. "_heap", xx, yy, zz, facing, unitTeam) + SpringSynced.CreateFeature(buildAsUnitName .. "_heap", xx, yy, zz, facing, unitTeam) end end end @@ -204,7 +204,7 @@ function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerD if pairedUnitID then pairedUnits[unitID] = nil pairedUnits[pairedUnitID] = nil - Spring.DestroyUnit(pairedUnitID, false, true) + SpringSynced.DestroyUnit(pairedUnitID, false, true) end end end @@ -224,13 +224,13 @@ end function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD.ONOFF) - for _, unitID in pairs(Spring.GetAllUnits()) do - if not Spring.GetUnitIsBeingBuilt(unitID) then - local unitDefID = Spring.GetUnitDefID(unitID) + for _, unitID in pairs(SpringShared.GetAllUnits()) do + if not SpringShared.GetUnitIsBeingBuilt(unitID) then + local unitDefID = SpringShared.GetUnitDefID(unitID) gadget:UnitFinished(unitID, unitDefID) if mexActualDefID[unitDefID] then - local pairedUnitID = Spring.GetUnitRulesParam(unitID, "pairedUnitID") + local pairedUnitID = SpringShared.GetUnitRulesParam(unitID, "pairedUnitID") if pairedUnitID then pairedUnits[unitID] = pairedUnitID pairedUnits[pairedUnitID] = unitID diff --git a/luarules/gadgets/unit_attributes.lua b/luarules/gadgets/unit_attributes.lua index ef8d3f8ddd2..11da51788e9 100644 --- a/luarules/gadgets/unit_attributes.lua +++ b/luarules/gadgets/unit_attributes.lua @@ -1,5 +1,5 @@ -if not Spring.GetModOptions().emprework then +if not SpringShared.GetModOptions().emprework then return end @@ -30,21 +30,21 @@ local UPDATE_PERIOD = 3 -------------------------------------------------------------------------------- local floor = math.floor -local spValidUnitID = Spring.ValidUnitID -local spGetUnitDefID = Spring.GetUnitDefID -local spGetGameFrame = Spring.GetGameFrame -local spGetUnitRulesParam = Spring.GetUnitRulesParam -local spSetUnitRulesParam = Spring.SetUnitRulesParam +local spValidUnitID = SpringShared.ValidUnitID +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetGameFrame = SpringShared.GetGameFrame +local spGetUnitRulesParam = SpringShared.GetUnitRulesParam +local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam -local spSetUnitBuildSpeed = Spring.SetUnitBuildSpeed -local spSetUnitWeaponState = Spring.SetUnitWeaponState -local spGetUnitWeaponState = Spring.GetUnitWeaponState +local spSetUnitBuildSpeed = SpringSynced.SetUnitBuildSpeed +local spSetUnitWeaponState = SpringSynced.SetUnitWeaponState +local spGetUnitWeaponState = SpringShared.GetUnitWeaponState -local spGetUnitMoveTypeData = Spring.GetUnitMoveTypeData -local spMoveCtrlGetTag = Spring.MoveCtrl.GetTag -local spSetAirMoveTypeData = Spring.MoveCtrl.SetAirMoveTypeData -local spSetGunshipMoveTypeData = Spring.MoveCtrl.SetGunshipMoveTypeData -local spSetGroundMoveTypeData = Spring.MoveCtrl.SetGroundMoveTypeData +local spGetUnitMoveTypeData = SpringShared.GetUnitMoveTypeData +local spMoveCtrlGetTag = SpringSynced.MoveCtrl.GetTag +local spSetAirMoveTypeData = SpringSynced.MoveCtrl.SetAirMoveTypeData +local spSetGunshipMoveTypeData = SpringSynced.MoveCtrl.SetGunshipMoveTypeData +local spSetGroundMoveTypeData = SpringSynced.MoveCtrl.SetGroundMoveTypeData local INLOS_ACCESS = { inlos = true } @@ -130,17 +130,17 @@ end local function UpdateSensorAndJamm(unitID, unitDefID, enabled, radarOverride, sonarOverride, jammerOverride, sightOverride) if radarUnitDef[unitDefID] or radarOverride then - Spring.SetUnitSensorRadius(unitID, "radar", (enabled and (radarOverride or radarUnitDef[unitDefID])) or 0) + SpringSynced.SetUnitSensorRadius(unitID, "radar", (enabled and (radarOverride or radarUnitDef[unitDefID])) or 0) end if sonarUnitDef[unitDefID] or sonarOverride then - Spring.SetUnitSensorRadius(unitID, "sonar", (enabled and (sonarOverride or sonarUnitDef[unitDefID])) or 0) + SpringSynced.SetUnitSensorRadius(unitID, "sonar", (enabled and (sonarOverride or sonarUnitDef[unitDefID])) or 0) end if jammerUnitDef[unitDefID] or jammerOverride then - Spring.SetUnitSensorRadius(unitID, "radarJammer", (enabled and (jammerOverride or jammerUnitDef[unitDefID])) or 0) + SpringSynced.SetUnitSensorRadius(unitID, "radarJammer", (enabled and (jammerOverride or jammerUnitDef[unitDefID])) or 0) end if sightOverride then - Spring.SetUnitSensorRadius(unitID, "los", sightOverride) - Spring.SetUnitSensorRadius(unitID, "airLos", sightOverride) + SpringSynced.SetUnitSensorRadius(unitID, "los", sightOverride) + SpringSynced.SetUnitSensorRadius(unitID, "airLos", sightOverride) end end @@ -312,11 +312,11 @@ local function UpdateMovementSpeed(unitID, unitDefID, speedFactor, turnAccelFact speedFactor = 0 -- Set the units velocity to zero if it is attached to the ground. - local x, y, z = Spring.GetUnitPosition(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) if x then - local h = Spring.GetGroundHeight(x, z) + local h = SpringShared.GetGroundHeight(x, z) if h and h >= y then - Spring.SetUnitVelocity(unitID, 0, 0, 0) + SpringSynced.SetUnitVelocity(unitID, 0, 0, 0) -- Perhaps attributes should do this: --local env = Spring.UnitScript.GetScriptEnv(unitID) @@ -565,13 +565,13 @@ function UpdateUnitAttributes(unitID, frame) if shieldWeaponDef[unitDefID] and shieldDisabled ~= unitShieldDisabled[unitID] then spSetUnitRulesParam(unitID, "att_shieldDisabled", shieldDisabled and 1 or 0) if shieldDisabled then - Spring.SetUnitShieldState(unitID, -1, 0) + SpringSynced.SetUnitShieldState(unitID, -1, 0) end if spGetUnitRulesParam(unitID, "comm_shield_max") ~= 0 then if shieldDisabled then - Spring.SetUnitShieldState(unitID, spGetUnitRulesParam(unitID, "comm_shield_num") or -1, false) + SpringSynced.SetUnitShieldState(unitID, spGetUnitRulesParam(unitID, "comm_shield_num") or -1, false) else - Spring.SetUnitShieldState(unitID, spGetUnitRulesParam(unitID, "comm_shield_num") or -1, true) + SpringSynced.SetUnitShieldState(unitID, spGetUnitRulesParam(unitID, "comm_shield_num") or -1, true) end end changedAtt = true diff --git a/luarules/gadgets/unit_block_fake_geo.lua b/luarules/gadgets/unit_block_fake_geo.lua index 79eec29b6aa..1d976ca525f 100644 --- a/luarules/gadgets/unit_block_fake_geo.lua +++ b/luarules/gadgets/unit_block_fake_geo.lua @@ -19,9 +19,9 @@ end local function isNearGeo(x, z) -- modded geos can be bigger than 40 elmo but w/e, this gadget only lives -- until next engine anyway, plus centered placement still works - local features = Spring.GetFeaturesInCylinder(x, z, 40 * math.sqrt(2)) + local features = SpringShared.GetFeaturesInCylinder(x, z, 40 * math.sqrt(2)) for i = 1, #features do - if FeatureDefs[Spring.GetFeatureDefID(features[i])].geoThermal then + if FeatureDefs[SpringShared.GetFeatureDefID(features[i])].geoThermal then return true end end diff --git a/luarules/gadgets/unit_bomber_no_air_target.lua b/luarules/gadgets/unit_bomber_no_air_target.lua index b5ba003cb50..5365bb27f2c 100644 --- a/luarules/gadgets/unit_bomber_no_air_target.lua +++ b/luarules/gadgets/unit_bomber_no_air_target.lua @@ -40,7 +40,7 @@ function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOpt -- accepts: CMD.ATTACK -- Block bombers from attacking air units (single-target only, not ground attack) if isBomber[unitDefID] and cmdParams[2] == nil and type(cmdParams[1]) == "number" then - local targetDefID = Spring.GetUnitDefID(cmdParams[1]) + local targetDefID = SpringShared.GetUnitDefID(cmdParams[1]) if targetDefID and isAir[targetDefID] then return false end diff --git a/luarules/gadgets/unit_builder_priority.lua b/luarules/gadgets/unit_builder_priority.lua index cb1772e7799..70731cea29a 100644 --- a/luarules/gadgets/unit_builder_priority.lua +++ b/luarules/gadgets/unit_builder_priority.lua @@ -61,21 +61,21 @@ local cmdPassiveDesc = { params = { 1, "Low Prio", "High Prio" }, } -local spInsertUnitCmdDesc = Spring.InsertUnitCmdDesc -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc -local spGetUnitCmdDescs = Spring.GetUnitCmdDescs -local spEditUnitCmdDesc = Spring.EditUnitCmdDesc -local spGetTeamResources = Spring.GetTeamResources -local spGetTeamList = Spring.GetTeamList -local spSetUnitRulesParam = Spring.SetUnitRulesParam -local spGetUnitRulesParam = Spring.GetUnitRulesParam -local spGetTeamRulesParam = Spring.GetTeamRulesParam -local spSetUnitBuildSpeed = Spring.SetUnitBuildSpeed -local spGetUnitIsBuilding = Spring.GetUnitIsBuilding -local spValidUnitID = Spring.ValidUnitID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetAllUnits = Spring.GetAllUnits -local spGetUnitDefID = Spring.GetUnitDefID +local spInsertUnitCmdDesc = SpringSynced.InsertUnitCmdDesc +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc +local spGetUnitCmdDescs = SpringShared.GetUnitCmdDescs +local spEditUnitCmdDesc = SpringSynced.EditUnitCmdDesc +local spGetTeamResources = SpringShared.GetTeamResources +local spGetTeamList = SpringShared.GetTeamList +local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam +local spGetUnitRulesParam = SpringShared.GetUnitRulesParam +local spGetTeamRulesParam = SpringShared.GetTeamRulesParam +local spSetUnitBuildSpeed = SpringSynced.SetUnitBuildSpeed +local spGetUnitIsBuilding = SpringShared.GetUnitIsBuilding +local spValidUnitID = SpringShared.ValidUnitID +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetAllUnits = SpringShared.GetAllUnits +local spGetUnitDefID = SpringShared.GetUnitDefID local simSpeed = Game.gameSpeed local mathMax = math.max @@ -124,7 +124,7 @@ function gadget:Initialize() for i = 1, #teamList do local teamID = teamList[i] -- Distribute initial update frames. They will drift on their own afterward. - local gameFrame = Spring.GetGameFrame() + local gameFrame = SpringShared.GetGameFrame() if not updateFrame[teamID] then updateFrame[teamID] = gameFrame + (teamID % 6) end @@ -133,7 +133,7 @@ function gadget:Initialize() passiveCons[teamID] = passiveCons[teamID] or {} passiveConsCount[teamID] = passiveConsCount[teamID] or 0 buildTargetOwnersByTeam[teamID] = buildTargetOwnersByTeam[teamID] or {} - Spring.SetTeamRulesParam(teamID, "suspendbuilderpriority", 0) + SpringSynced.SetTeamRulesParam(teamID, "suspendbuilderpriority", 0) end local allUnits = spGetAllUnits() diff --git a/luarules/gadgets/unit_cancel_orders_on_share.lua b/luarules/gadgets/unit_cancel_orders_on_share.lua index b6adf6596fd..d4c02975ce0 100644 --- a/luarules/gadgets/unit_cancel_orders_on_share.lua +++ b/luarules/gadgets/unit_cancel_orders_on_share.lua @@ -16,14 +16,14 @@ if not gadgetHandler:IsSyncedCode() then function gadget:UnitGiven(unitID, unitDefID, unitTeam, oldTeam) -- give all shared units a stop command - Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) -- remove their build queue - local buildQ = Spring.GetFullBuildQueue(unitID) or {} + local buildQ = SpringShared.GetFullBuildQueue(unitID) or {} for _, buildOrder in pairs(buildQ) do for uDID, count in pairs(buildOrder) do for i = 1, count do - Spring.GiveOrderToUnit(unitID, -uDID, {}, { "right" }) + SpringSynced.GiveOrderToUnit(unitID, -uDID, {}, { "right" }) end end end @@ -43,8 +43,8 @@ else -- SYNCED function gadget:GameFrame(n) if n % 37 == 0 and #recievedMexes > 0 then for i, unitID in ipairs(recievedMexes) do - if Spring.ValidUnitID(unitID) then - Spring.GiveOrderToUnit(unitID, CMD.ONOFF, { 1 }, 0) + if SpringShared.ValidUnitID(unitID) then + SpringSynced.GiveOrderToUnit(unitID, CMD.ONOFF, { 1 }, 0) end end recievedMexes = {} diff --git a/luarules/gadgets/unit_capture_decay.lua b/luarules/gadgets/unit_capture_decay.lua index 172107cffa3..4af64d997e3 100644 --- a/luarules/gadgets/unit_capture_decay.lua +++ b/luarules/gadgets/unit_capture_decay.lua @@ -25,7 +25,7 @@ end function gadget:GameFrame(frame) for unitID, data in pairs(unitsWithCaptureProgress) do if unitID % 30 == frame % 30 then - local captureLevel = select(4, Spring.GetUnitHealth(unitID)) + local captureLevel = select(4, SpringShared.GetUnitHealth(unitID)) if captureLevel and captureLevel > 0 then if captureLevel <= data.previousCaptureProgress then unitsWithCaptureProgress[unitID].ticksFromLastCapture = unitsWithCaptureProgress[unitID].ticksFromLastCapture + 1 @@ -35,7 +35,7 @@ function gadget:GameFrame(frame) end unitsWithCaptureProgress[unitID].previousCaptureProgress = captureLevel if unitsWithCaptureProgress[unitID].ticksFromLastCapture >= 10 then -- with how things are set up, that will be about 10 seconds - Spring.SetUnitHealth(unitID, { capture = math.max(captureLevel - ((unitsWithCaptureProgress[unitID].ticksFromLastCapture - 10) * 0.001), 0) }) + SpringSynced.SetUnitHealth(unitID, { capture = math.max(captureLevel - ((unitsWithCaptureProgress[unitID].ticksFromLastCapture - 10) * 0.001), 0) }) end else unitsWithCaptureProgress[unitID] = nil diff --git a/luarules/gadgets/unit_capture_only_enemy.lua b/luarules/gadgets/unit_capture_only_enemy.lua index ac640cecf58..e2cec010ec9 100644 --- a/luarules/gadgets/unit_capture_only_enemy.lua +++ b/luarules/gadgets/unit_capture_only_enemy.lua @@ -16,9 +16,9 @@ if not gadgetHandler:IsSyncedCode() then return end -local spGetUnitTeam = Spring.GetUnitTeam -local spGetTeamInfo = Spring.GetTeamInfo -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam local reissueOrder = Game.Commands.ReissueOrder diff --git a/luarules/gadgets/unit_carrier_spawner.lua b/luarules/gadgets/unit_carrier_spawner.lua index 8b1e957bc81..46ab47fc2fa 100644 --- a/luarules/gadgets/unit_carrier_spawner.lua +++ b/luarules/gadgets/unit_carrier_spawner.lua @@ -17,52 +17,52 @@ function gadget:GetInfo() } end -local spCreateUnit = Spring.CreateUnit -local spDestroyUnit = Spring.DestroyUnit -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spSetUnitRulesParam = Spring.SetUnitRulesParam -local spGetUnitPosition = Spring.GetUnitPosition -local SetUnitNoSelect = Spring.SetUnitNoSelect -local spGetUnitRulesParam = Spring.GetUnitRulesParam -local spUseTeamResource = Spring.UseTeamResource -local spGetTeamResources = Spring.GetTeamResources -local GetUnitCommands = Spring.GetUnitCommands -local spSetUnitArmored = Spring.SetUnitArmored -local spGetUnitStates = Spring.GetUnitStates -local spGetUnitDefID = Spring.GetUnitDefID -local spSetUnitVelocity = Spring.SetUnitVelocity -local spUnitAttach = Spring.UnitAttach -local spUnitDetach = Spring.UnitDetach -local spSetUnitHealth = Spring.SetUnitHealth -local spSetUnitMaxHealth = Spring.SetUnitMaxHealth -local spSetUnitUseAirLos = Spring.SetUnitUseAirLos -local spGetGroundHeight = Spring.GetGroundHeight -local spGetUnitNearestEnemy = Spring.GetUnitNearestEnemy -local spTransferUnit = Spring.TransferUnit -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitHealth = Spring.GetUnitHealth -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGetUnitWeaponTarget = Spring.GetUnitWeaponTarget -local EditUnitCmdDesc = Spring.EditUnitCmdDesc -local FindUnitCmdDesc = Spring.FindUnitCmdDesc -local InsertUnitCmdDesc = Spring.InsertUnitCmdDesc -local spGetGameSeconds = Spring.GetGameSeconds -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetUnitStockpile = Spring.GetUnitStockpile -local spSetUnitStockpile = Spring.SetUnitStockpile -local spCallCOBScript = Spring.CallCOBScript +local spCreateUnit = SpringSynced.CreateUnit +local spDestroyUnit = SpringSynced.DestroyUnit +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam +local spGetUnitPosition = SpringShared.GetUnitPosition +local SetUnitNoSelect = SpringUnsynced.SetUnitNoSelect +local spGetUnitRulesParam = SpringShared.GetUnitRulesParam +local spUseTeamResource = SpringSynced.UseTeamResource +local spGetTeamResources = SpringShared.GetTeamResources +local GetUnitCommands = SpringShared.GetUnitCommands +local spSetUnitArmored = SpringSynced.SetUnitArmored +local spGetUnitStates = SpringShared.GetUnitStates +local spGetUnitDefID = SpringShared.GetUnitDefID +local spSetUnitVelocity = SpringSynced.SetUnitVelocity +local spUnitAttach = SpringSynced.UnitAttach +local spUnitDetach = SpringSynced.UnitDetach +local spSetUnitHealth = SpringSynced.SetUnitHealth +local spSetUnitMaxHealth = SpringSynced.SetUnitMaxHealth +local spSetUnitUseAirLos = SpringSynced.SetUnitUseAirLos +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetUnitNearestEnemy = SpringShared.GetUnitNearestEnemy +local spTransferUnit = SpringSynced.TransferUnit +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGetUnitWeaponTarget = SpringShared.GetUnitWeaponTarget +local EditUnitCmdDesc = SpringSynced.EditUnitCmdDesc +local FindUnitCmdDesc = SpringShared.FindUnitCmdDesc +local InsertUnitCmdDesc = SpringSynced.InsertUnitCmdDesc +local spGetGameSeconds = SpringShared.GetGameSeconds +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetUnitStockpile = SpringShared.GetUnitStockpile +local spSetUnitStockpile = SpringSynced.SetUnitStockpile +local spCallCOBScript = SpringSynced.CallCOBScript local spSetUnitCOBValue = Spring.SetUnitCOBValue -local spGetUnitPiecePosDir = Spring.GetUnitPiecePosDir -local spGetUnitPiecePosition = Spring.GetUnitPiecePosition -local spGetGameFrame = Spring.GetGameFrame +local spGetUnitPiecePosDir = SpringShared.GetUnitPiecePosDir +local spGetUnitPiecePosition = SpringShared.GetUnitPiecePosition +local spGetGameFrame = SpringShared.GetGameFrame -local mcEnable = Spring.MoveCtrl.Enable -local mcDisable = Spring.MoveCtrl.Disable -local mcSetPosition = Spring.MoveCtrl.SetPosition -local mcSetRotation = Spring.MoveCtrl.SetRotation -local mcSetAirMoveTypeData = Spring.MoveCtrl.SetAirMoveTypeData +local mcEnable = SpringSynced.MoveCtrl.Enable +local mcDisable = SpringSynced.MoveCtrl.Disable +local mcSetPosition = SpringSynced.MoveCtrl.SetPosition +local mcSetRotation = SpringSynced.MoveCtrl.SetRotation +local mcSetAirMoveTypeData = SpringSynced.MoveCtrl.SetAirMoveTypeData local mapsizeX = Game.mapSizeX local mapsizeZ = Game.mapSizeZ @@ -683,7 +683,7 @@ local function attachToNewCarrier(newCarrier, subUnitID) carrierMetaList[newCarrier].subUnitsList[subUnitID] = droneData totalDroneCount = totalDroneCount + 1 else - local oldCarrierID = Spring.GetUnitRulesParam(subUnitID, "carrier_host_unit_id") + local oldCarrierID = SpringShared.GetUnitRulesParam(subUnitID, "carrier_host_unit_id") if oldCarrierID and carrierMetaList[oldCarrierID] then carrierMetaList[newCarrier] = carrierMetaList[oldCarrierID] carrierMetaList[newCarrier].docking = nil @@ -728,7 +728,7 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam) local availableSections = {} - local f = Spring.GetGameFrame() + local f = SpringShared.GetGameFrame() for sectionIndex, dockingpieces in pairs(dockingsections) do local availableSectionsData = { @@ -899,7 +899,7 @@ function gadget:ProjectileCreated(proID, proOwnerID, proWeaponDefID) if droneMetaData.dronetype == "bomber" and bomberStage > 0 then local currentTime = spGetGameSeconds() if (currentTime - lastBombing) >= 4 then - Spring.MoveCtrl.SetAirMoveTypeData(proOwnerID, "maxRudder", droneMetaData.originalmaxrudder) + SpringSynced.MoveCtrl.SetAirMoveTypeData(proOwnerID, "maxRudder", droneMetaData.originalmaxrudder) bomberStage = bomberStage + 1 lastBombing = spGetGameSeconds() end @@ -1155,7 +1155,7 @@ local function updateCarrier(carrierID, carrierMetaData, frame) idleRadius = carrierMetaData.droneminimumidleradius end - local weapontargettype, _, weapontarget = Spring.GetUnitWeaponTarget(carrierID, carrierMetaData.weaponNr) + local weapontargettype, _, weapontarget = SpringShared.GetUnitWeaponTarget(carrierID, carrierMetaData.weaponNr) --Handles an attack order given to the carrier. if not recallDrones and cmdID == CMD.ATTACK or weapontarget then @@ -1309,7 +1309,7 @@ local function updateCarrier(carrierID, carrierMetaData, frame) elseif carrierMetaData.dronebombingside == 1 then carrierMetaData.dronebombingside = -1 end - Spring.MoveCtrl.SetAirMoveTypeData(subUnitID, "maxRudder", 0.05) + SpringSynced.MoveCtrl.SetAirMoveTypeData(subUnitID, "maxRudder", 0.05) carrierMetaData.dronebombertimer = spGetGameSeconds() bomberStage = 1 end @@ -1384,11 +1384,11 @@ local function updateCarrier(carrierID, carrierMetaData, frame) end else if droneType == "abductor" then - local transportedUnit = Spring.GetUnitIsTransporting(subUnitID) + local transportedUnit = SpringShared.GetUnitIsTransporting(subUnitID) if transportedUnit[1] then dockUnitQueue(carrierID, subUnitID) else - local targetMoveTypeData = Spring.GetUnitMoveTypeData(target) + local targetMoveTypeData = SpringShared.GetUnitMoveTypeData(target) if targetMoveTypeData and targetMoveTypeData.maxSpeed and targetMoveTypeData.maxSpeed > 0 then spGiveOrderToUnit(subUnitID, CMD.LOAD_UNITS, target) end @@ -1507,7 +1507,7 @@ function gadget:UnitCommand(unitID, unitDefID, unitTeamID, cmdID, cmdParams, cmd end elseif carrierMetaList[unitID] and (cmdID ~= CMD.MOVE and cmdID ~= CMD.FIRE_STATE and cmdID ~= CMD.STOCKPILE) then carrierMetaList[unitID].activeRecall = false - local f = Spring.GetGameFrame() + local f = SpringShared.GetGameFrame() updateCarrier(unitID, carrierMetaList[unitID], f) end inUnitCommand = false @@ -1564,9 +1564,9 @@ local function dockUnits(dockingqueue, queuestart, queueend) end local vx, vy, vz = px - subx, py - suby, pz - subz vx, vy, vz = landingspeed * vx / magnitude, landingspeed * vy / magnitude, landingspeed * vz / magnitude - Spring.MoveCtrl.Enable(subUnitID) + SpringSynced.MoveCtrl.Enable(subUnitID) mcSetPosition(subUnitID, subx + vx, suby, subz + vz) - Spring.MoveCtrl.Disable(subUnitID) + SpringSynced.MoveCtrl.Disable(subUnitID) spSetUnitVelocity(subUnitID, vx, 0, vz) heightDifference = 0 @@ -1590,7 +1590,7 @@ local function dockUnits(dockingqueue, queuestart, queueend) spUnitAttach(unitID, subUnitID, pieceNumber) spGiveOrderToUnit(subUnitID, CMD.STOP, {}, 0) spGiveOrderToUnit(subUnitID, CMD.FIRE_STATE, 0, 0) - Spring.MoveCtrl.Disable(subUnitID) + SpringSynced.MoveCtrl.Disable(subUnitID) spSetUnitVelocity(subUnitID, 0, 0, 0) if not carrierMetaList[unitID].manualDrones then SetUnitNoSelect(subUnitID, true) @@ -1607,9 +1607,9 @@ local function dockUnits(dockingqueue, queuestart, queueend) spCallCOBScript(subUnitID, "Docked", 0, carrierMetaList[unitID].cobdockparam, pieceNumber, pieceAngle) if dronetype == "abductor" then - local transportedUnit = Spring.GetUnitIsTransporting(subUnitID) + local transportedUnit = SpringShared.GetUnitIsTransporting(subUnitID) if transportedUnit[1] then - local transportedUnitDefID = Spring.GetUnitDefID(transportedUnit[1]) + local transportedUnitDefID = SpringShared.GetUnitDefID(transportedUnit[1]) if transportedUnitDefID then for dronetypeIndex, dronename in pairs(carrierMetaList[unitID].dronenames) do if carrierMetaList[unitID].dronetypes[dronetypeIndex] == "printer" then @@ -1737,13 +1737,13 @@ end function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD_CARRIER_SPAWN_ONOFF) - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() local unitCount = #allUnits for i = 1, unitCount do local unitID = allUnits[i] gadget:UnitCreated(unitID, spGetUnitDefID(unitID), spGetUnitTeam(unitID)) end - gaiaTeam = Spring.GetGaiaTeamID() + gaiaTeam = SpringShared.GetGaiaTeamID() gadgetHandler:RegisterGlobal("CobUndockSequenceFinished", CobUndockSequenceFinished) gadgetHandler:RegisterGlobal("CobDroneSpawnSequenceFinished", CobDroneSpawnSequenceFinished) diff --git a/luarules/gadgets/unit_cheat_no_waste.lua b/luarules/gadgets/unit_cheat_no_waste.lua index 56539ef9aae..052efa3bdf5 100644 --- a/luarules/gadgets/unit_cheat_no_waste.lua +++ b/luarules/gadgets/unit_cheat_no_waste.lua @@ -17,7 +17,7 @@ if not gadgetHandler:IsSyncedCode() then return false end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() if modOptions.nowasting == "default" or modOptions.nowasting == "disabled" then return false @@ -51,8 +51,8 @@ local isAllyTeamWinning local averageAlliedTechGuesstimate --localized functions -local spGetTeamResources = Spring.GetTeamResources -local spSetUnitBuildSpeed = Spring.SetUnitBuildSpeed +local spGetTeamResources = SpringShared.GetTeamResources +local spSetUnitBuildSpeed = SpringSynced.SetUnitBuildSpeed for id, def in pairs(UnitDefs) do if def.buildSpeed and def.buildSpeed > 0 and def.speed and def.speed == 0 then --we only want base factories and construction turrets to get boosted @@ -135,11 +135,11 @@ function gadget:GameFrame(frame) end if newBuildPowerMultiplier == 1 then for teamID, _ in pairs(boostableAllies[allyID]) do - Spring.SetTeamRulesParam(teamID, "suspendbuilderpriority", 0) + SpringSynced.SetTeamRulesParam(teamID, "suspendbuilderpriority", 0) end else for teamID, _ in pairs(boostableAllies[allyID]) do - Spring.SetTeamRulesParam(teamID, "suspendbuilderpriority", 1) + SpringSynced.SetTeamRulesParam(teamID, "suspendbuilderpriority", 1) end end end @@ -159,7 +159,7 @@ function gadget:Initialize() end for teamID, _ in pairs(boostableTeams) do - local allyID = select(6, Spring.GetTeamInfo(teamID)) + local allyID = select(6, SpringShared.GetTeamInfo(teamID)) boostableAllies[allyID] = boostableAllies[allyID] or {} boostableAllies[allyID][teamID] = true overflowingAllies[allyID] = 1 diff --git a/luarules/gadgets/unit_cloak.lua b/luarules/gadgets/unit_cloak.lua index 426dd811264..a59271631d6 100644 --- a/luarules/gadgets/unit_cloak.lua +++ b/luarules/gadgets/unit_cloak.lua @@ -33,19 +33,19 @@ local unitWantCloakCommandDesc = { local alliedTrueTable = { allied = true } -local spGetUnitIsStunned = Spring.GetUnitIsStunned -local spAreTeamsAllied = Spring.AreTeamsAllied -local spInsertUnitCmdDesc = Spring.InsertUnitCmdDesc -local spRemoveUnitCmdDesc = Spring.RemoveUnitCmdDesc -local spSetUnitCloak = Spring.SetUnitCloak -local spSetUnitRulesParam = Spring.SetUnitRulesParam -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetUnitRulesParam = Spring.GetUnitRulesParam -local spGetUnitVelocity = Spring.GetUnitVelocity -local spUseUnitResource = Spring.UseUnitResource -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc -local spEditUnitCmdDesc = Spring.EditUnitCmdDesc +local spGetUnitIsStunned = SpringShared.GetUnitIsStunned +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spInsertUnitCmdDesc = SpringSynced.InsertUnitCmdDesc +local spRemoveUnitCmdDesc = SpringSynced.RemoveUnitCmdDesc +local spSetUnitCloak = SpringSynced.SetUnitCloak +local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetUnitRulesParam = SpringShared.GetUnitRulesParam +local spGetUnitVelocity = SpringShared.GetUnitVelocity +local spUseUnitResource = SpringSynced.UseUnitResource +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc +local spEditUnitCmdDesc = SpringSynced.EditUnitCmdDesc local CMD_CLOAK = CMD.CLOAK local DEFAULT_DECLOAK_TIME = 128 @@ -225,7 +225,7 @@ end function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD_CLOAK) gadgetHandler:RegisterAllowCommand(CMD_WANT_CLOAK) - for _, unitID in ipairs(Spring.GetAllUnits()) do + for _, unitID in ipairs(SpringShared.GetAllUnits()) do gadget:UnitCreated(unitID, spGetUnitDefID(unitID)) end end diff --git a/luarules/gadgets/unit_collision_damage_behavior.lua b/luarules/gadgets/unit_collision_damage_behavior.lua index d228d5d1ca3..6ae4b69cd69 100644 --- a/luarules/gadgets/unit_collision_damage_behavior.lua +++ b/luarules/gadgets/unit_collision_damage_behavior.lua @@ -47,11 +47,11 @@ local minImpulseToDamageRatio = 0.2 local groundCollisionDefID = Game.envDamageTypes.GroundCollision local objectCollisionDefID = Game.envDamageTypes.ObjectCollision -local spGetUnitHealth = Spring.GetUnitHealth -local spGetUnitVelocity = Spring.GetUnitVelocity -local spSetUnitVelocity = Spring.SetUnitVelocity -local spGetUnitIsDead = Spring.GetUnitIsDead -local spDestroyUnit = Spring.DestroyUnit +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetUnitVelocity = SpringShared.GetUnitVelocity +local spSetUnitVelocity = SpringSynced.SetUnitVelocity +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spDestroyUnit = SpringSynced.DestroyUnit local mathMin = math.min local mathMax = math.max local mathAbs = math.abs @@ -266,7 +266,7 @@ local function setVelocityControl(unitID, enabled) elseif not unitInertiaCheckFlags[unitID] then unitInertiaCheckFlags[unitID] = { expirationFrame = gameFrame + velocityWatchFrames, - velocityCap = unitDefData[Spring.GetUnitDefID(unitID)].velocityCap, + velocityCap = unitDefData[SpringShared.GetUnitDefID(unitID)].velocityCap, } end end diff --git a/luarules/gadgets/unit_combomb_full_damage.lua b/luarules/gadgets/unit_combomb_full_damage.lua index 7f1db984236..0676371f2f1 100644 --- a/luarules/gadgets/unit_combomb_full_damage.lua +++ b/luarules/gadgets/unit_combomb_full_damage.lua @@ -26,13 +26,13 @@ function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, w --Spring.Echo("UnitPreDamaged called with unitID " .. unitID .. " and attackerID ", attackerID) - if weaponDefID == COM_BLAST and attackerID ~= nil and Spring.ValidUnitID(attackerID) then -- we control the damage inflicted on units by the COM_BLAST. Very rarely an invalid attackerID is returned with weaponID=COM_BLAST, I have no idea why/how. + if weaponDefID == COM_BLAST and attackerID ~= nil and SpringShared.ValidUnitID(attackerID) then -- we control the damage inflicted on units by the COM_BLAST. Very rarely an invalid attackerID is returned with weaponID=COM_BLAST, I have no idea why/how. --Spring.Echo("weapon is comblast from unloaded com " .. attackerID) - local x, y, z = Spring.GetUnitBasePosition(attackerID) - local h = Spring.GetGroundHeight(x, z) + local x, y, z = SpringShared.GetUnitBasePosition(attackerID) + local h = SpringShared.GetGroundHeight(x, z) --Spring.Echo(x .. " " .. y .. " " .. z .. " " .. h) if y - h > 10 then - local newdamage = select(2, Spring.GetUnitHealth(unitID)) * 0.6 + local newdamage = select(2, SpringShared.GetUnitHealth(unitID)) * 0.6 if newdamage < 400 then newdamage = 400 end diff --git a/luarules/gadgets/unit_commando_watch.lua b/luarules/gadgets/unit_commando_watch.lua index e9556ee58f9..b789aefff10 100644 --- a/luarules/gadgets/unit_commando_watch.lua +++ b/luarules/gadgets/unit_commando_watch.lua @@ -42,13 +42,13 @@ end function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponID, projectileID, attackerID, attackerDefID, attackerTeam) if isCommando[unitDefID] then if weaponID < 0 then - local x, y, z = Spring.GetUnitPosition(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) if x < 0 or z < 0 or x > MAPSIZEX or z > MAPSIZEZ then - Spring.DestroyUnit(unitID) + SpringSynced.DestroyUnit(unitID) return damage, 1 end - x, y, z = Spring.GetUnitVelocity(unitID) - Spring.AddUnitImpulse(unitID, x * -0.66, y * -0.66, z * -0.66) + x, y, z = SpringShared.GetUnitVelocity(unitID) + SpringSynced.AddUnitImpulse(unitID, x * -0.66, y * -0.66, z * -0.66) return damage * 0.12, 0 elseif MINE_BLAST[weaponID] then return damage * 0.12, 0.24 @@ -60,7 +60,7 @@ function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, w end function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) - if builderID and unitDefID == MINE2 and isCommando[Spring.GetUnitDefID(builderID)] then + if builderID and unitDefID == MINE2 and isCommando[SpringShared.GetUnitDefID(builderID)] then mines[unitID] = builderID end end @@ -75,12 +75,12 @@ end function gadget:UnitLoaded(unitID, unitDefID, unitTeam, transportID, transportTeam) if isCommando[unitDefID] then - Spring.SetUnitStealth(transportID, true) + SpringSynced.SetUnitStealth(transportID, true) end end function gadget:UnitUnloaded(unitID, unitDefID, teamID, transportID) if isCommando[unitDefID] then - Spring.SetUnitStealth(transportID, false) + SpringSynced.SetUnitStealth(transportID, false) end end diff --git a/luarules/gadgets/unit_continuous_aim.lua b/luarules/gadgets/unit_continuous_aim.lua index a637e4be5d8..33d9dc2101e 100644 --- a/luarules/gadgets/unit_continuous_aim.lua +++ b/luarules/gadgets/unit_continuous_aim.lua @@ -16,7 +16,7 @@ if not gadgetHandler:IsSyncedCode() then return end -local spSetUnitWeaponState = Spring.SetUnitWeaponState +local spSetUnitWeaponState = SpringSynced.SetUnitWeaponState local tableCopy = table.copy local convertedUnitsNames = { diff --git a/luarules/gadgets/unit_corpse_link.lua b/luarules/gadgets/unit_corpse_link.lua index 059e35b5045..6e0e56600b2 100644 --- a/luarules/gadgets/unit_corpse_link.lua +++ b/luarules/gadgets/unit_corpse_link.lua @@ -27,7 +27,7 @@ local function getPositionHash(x, z) end local function GetFeatureResurrectDefID(featureID) - local resurrectUnitName = Spring.GetFeatureResurrect(featureID) + local resurrectUnitName = SpringShared.GetFeatureResurrect(featureID) if not resurrectUnitName then return end @@ -50,7 +50,7 @@ local function GetCorpsePriorUnitID(featureID) return end - local x, y, z = Spring.GetFeaturePosition(featureID) + local x, y, z = SpringShared.GetFeaturePosition(featureID) local positionHash = getPositionHash(x, z) local corpseLink = unitDefLink[positionHash] if not corpseLink then @@ -67,7 +67,7 @@ function gadget:UnitDestroyed(unitID, unitDefID) unitDefLink = {} corpseRegistryByDefID[unitDefID] = unitDefLink end - local x, y, z = Spring.GetUnitPosition(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) if not x then return end @@ -75,7 +75,7 @@ function gadget:UnitDestroyed(unitID, unitDefID) local positionHash = getPositionHash(x, z) unitDefLink[positionHash] = { unitID = unitID, - timeout = Spring.GetGameFrame() + CORPSE_LINK_TIMEOUT, + timeout = SpringShared.GetGameFrame() + CORPSE_LINK_TIMEOUT, } end diff --git a/luarules/gadgets/unit_crashing_aircraft.lua b/luarules/gadgets/unit_crashing_aircraft.lua index 21d488d4bf0..e0d2ee72858 100644 --- a/luarules/gadgets/unit_crashing_aircraft.lua +++ b/luarules/gadgets/unit_crashing_aircraft.lua @@ -16,18 +16,18 @@ if gadgetHandler:IsSyncedCode() then local gravityMult = 1.7 - local SetUnitSensorRadius = Spring.SetUnitSensorRadius - local SetUnitWeaponState = Spring.SetUnitWeaponState - local GetUnitHealth = Spring.GetUnitHealth - local GetGameFrame = Spring.GetGameFrame - local GetUnitMoveTypeData = Spring.GetUnitMoveTypeData - local SetAirMoveTypeData = Spring.MoveCtrl.SetAirMoveTypeData + local SetUnitSensorRadius = SpringSynced.SetUnitSensorRadius + local SetUnitWeaponState = SpringSynced.SetUnitWeaponState + local GetUnitHealth = SpringShared.GetUnitHealth + local GetGameFrame = SpringShared.GetGameFrame + local GetUnitMoveTypeData = SpringShared.GetUnitMoveTypeData + local SetAirMoveTypeData = SpringSynced.MoveCtrl.SetAirMoveTypeData local SetUnitCOBValue = Spring.SetUnitCOBValue - local GiveOrderToUnit = Spring.GiveOrderToUnit - local DestroyUnit = Spring.DestroyUnit + local GiveOrderToUnit = SpringSynced.GiveOrderToUnit + local DestroyUnit = SpringSynced.DestroyUnit local SendToUnsynced = SendToUnsynced - local GetUnitRulesParam = Spring.GetUnitRulesParam - local SetUnitRulesParam = Spring.SetUnitRulesParam + local GetUnitRulesParam = SpringShared.GetUnitRulesParam + local SetUnitRulesParam = SpringSynced.SetUnitRulesParam local COB_CRASHING = COB.CRASHING local COM_BLAST = WeaponDefNames["commanderexplosion"].id -- used to prevent them being boosted and flying far away @@ -69,14 +69,14 @@ if gadgetHandler:IsSyncedCode() then crashingCount = crashingCount + 1 crashing[unitID] = GetGameFrame() + 450 SetUnitCOBValue(unitID, COB_CRASHING, 1) - Spring.SetUnitNoSelect(unitID, true) - Spring.SetUnitNoMinimap(unitID, true) - Spring.SetUnitIconDraw(unitID, false) - Spring.SetUnitStealth(unitID, true) - Spring.SetUnitAlwaysVisible(unitID, false) - Spring.SetUnitNeutral(unitID, true) - Spring.SetUnitBlocking(unitID, false) - Spring.SetUnitCrashing(unitID, true) + SpringUnsynced.SetUnitNoSelect(unitID, true) + SpringUnsynced.SetUnitNoMinimap(unitID, true) + SpringUnsynced.SetUnitIconDraw(unitID, false) + SpringSynced.SetUnitStealth(unitID, true) + SpringSynced.SetUnitAlwaysVisible(unitID, false) + SpringSynced.SetUnitNeutral(unitID, true) + SpringSynced.SetUnitBlocking(unitID, false) + SpringSynced.SetUnitCrashing(unitID, true) if unitWeapons[unitDefID] then local weapons = unitWeapons[unitDefID] for i = 1, #weapons do @@ -129,10 +129,10 @@ if gadgetHandler:IsSyncedCode() then else -- UNSYNCED - local IsUnitVisible = Spring.IsUnitVisible + local IsUnitVisible = SpringUnsynced.IsUnitVisible local function crashingAircraft(_, unitID, unitDefID, unitTeam) - if select(2, Spring.GetSpectatingState()) or CallAsTeam(Spring.GetMyTeamID(), IsUnitVisible, unitID, 99999999, true) then + if select(2, SpringUnsynced.GetSpectatingState()) or CallAsTeam(Spring.GetMyTeamID(), IsUnitVisible, unitID, 99999999, true) then if Script.LuaUI("CrashingAircraft") then Script.LuaUI.CrashingAircraft(unitID, unitDefID, unitTeam) end diff --git a/luarules/gadgets/unit_cursors.lua b/luarules/gadgets/unit_cursors.lua index a9df3798d88..8e320d9c49c 100644 --- a/luarules/gadgets/unit_cursors.lua +++ b/luarules/gadgets/unit_cursors.lua @@ -26,6 +26,6 @@ local cursors = { function gadget:Initialize() for k, cursor in pairs(cursors) do - Spring.AssignMouseCursor(cursor, cursor, false) + SpringUnsynced.AssignMouseCursor(cursor, cursor, false) end end diff --git a/luarules/gadgets/unit_custom_weapons_behaviours.lua b/luarules/gadgets/unit_custom_weapons_behaviours.lua index 668f471f7c1..43b74764b7a 100644 --- a/luarules/gadgets/unit_custom_weapons_behaviours.lua +++ b/luarules/gadgets/unit_custom_weapons_behaviours.lua @@ -30,26 +30,26 @@ local distance3dSquared = math.distance3dSquared local CallAsTeam = CallAsTeam -local spDeleteProjectile = Spring.DeleteProjectile -local spGetGroundHeight = Spring.GetGroundHeight -local spGetGroundNormal = Spring.GetGroundNormal -local spGetProjectileDefID = Spring.GetProjectileDefID -local spGetProjectileOwnerID = Spring.GetProjectileOwnerID -local spGetProjectilePosition = Spring.GetProjectilePosition -local spGetProjectileTarget = Spring.GetProjectileTarget -local spGetProjectileTeamID = Spring.GetProjectileTeamID -local spGetProjectileTimeToLive = Spring.GetProjectileTimeToLive -local spGetProjectileVelocity = Spring.GetProjectileVelocity -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitWeaponState = Spring.GetUnitWeaponState -local spGetUnitWeaponTarget = Spring.GetUnitWeaponTarget -local spSetProjectilePosition = Spring.SetProjectilePosition -local spSetProjectileTarget = Spring.SetProjectileTarget -local spSetProjectileVelocity = Spring.SetProjectileVelocity -local spSpawnCEG = Spring.SpawnCEG -local spSpawnProjectile = Spring.SpawnProjectile +local spDeleteProjectile = SpringSynced.DeleteProjectile +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetGroundNormal = SpringShared.GetGroundNormal +local spGetProjectileDefID = SpringShared.GetProjectileDefID +local spGetProjectileOwnerID = SpringShared.GetProjectileOwnerID +local spGetProjectilePosition = SpringShared.GetProjectilePosition +local spGetProjectileTarget = SpringShared.GetProjectileTarget +local spGetProjectileTeamID = SpringShared.GetProjectileTeamID +local spGetProjectileTimeToLive = SpringShared.GetProjectileTimeToLive +local spGetProjectileVelocity = SpringShared.GetProjectileVelocity +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitWeaponState = SpringShared.GetUnitWeaponState +local spGetUnitWeaponTarget = SpringShared.GetUnitWeaponTarget +local spSetProjectilePosition = SpringSynced.SetProjectilePosition +local spSetProjectileTarget = SpringSynced.SetProjectileTarget +local spSetProjectileVelocity = SpringSynced.SetProjectileVelocity +local spSpawnCEG = SpringSynced.SpawnCEG +local spSpawnProjectile = SpringSynced.SpawnProjectile local gravityPerFrame = -Game.gravity / (Game.gameSpeed * Game.gameSpeed) @@ -79,7 +79,7 @@ local function parseCustomParams(weaponDef) if not specialEffectFunction[effectName] then local message = weaponDef.name .. " has bad speceffect: " .. tostring(effectName) - Spring.Log(gadget:GetInfo().name, LOG.ERROR, message) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, message) success = false end @@ -94,7 +94,7 @@ local function parseCustomParams(weaponDef) effectParams[key] = value else local message = weaponDef.name .. " has bad customparam: " .. tostring(key) - Spring.Log(gadget:GetInfo().name, LOG.ERROR, message) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, message) success = false end @@ -105,7 +105,7 @@ local function parseCustomParams(weaponDef) -- Modders/tweakdefs are likely to use these values for a while: if weaponDef.customParams.def or weaponDef.customParams.when then local message = weaponDef.name .. " uses old customparams (def/when)" - Spring.Log(gadget:GetInfo().name, LOG.DEPRECATED, message) + SpringShared.Log(gadget:GetInfo().name, LOG.DEPRECATED, message) end if success then @@ -651,9 +651,9 @@ function gadget:Initialize() for weaponDefID in pairs(weaponDefEffect) do Script.SetWatchProjectile(weaponDefID, true) end - gameFrame = Spring.GetGameFrame() + gameFrame = SpringShared.GetGameFrame() else - Spring.Log(gadget:GetInfo().name, LOG.INFO, "No custom weapons found.") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "No custom weapons found.") gadgetHandler:RemoveGadget(self) end end diff --git a/luarules/gadgets/unit_custom_weapons_cluster.lua b/luarules/gadgets/unit_custom_weapons_cluster.lua index 436c7b6028f..748f465abea 100644 --- a/luarules/gadgets/unit_custom_weapons_cluster.lua +++ b/luarules/gadgets/unit_custom_weapons_cluster.lua @@ -63,19 +63,19 @@ local sin = math.sin local atan2 = math.atan2 local distsq = math.distance3dSquared -local spGetGroundHeight = Spring.GetGroundHeight -local spGetGroundNormal = Spring.GetGroundNormal -local spGetProjectileDefID = Spring.GetProjectileDefID -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitRadius = Spring.GetUnitRadius -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitsInSphere = Spring.GetUnitsInSphere -local spGetProjectileTeamID = Spring.GetProjectileTeamID -local spGetProjectileVelocity = Spring.GetProjectileVelocity -local spAreTeamsAllied = Spring.AreTeamsAllied -local spSpawnProjectile = Spring.SpawnProjectile -local spDeleteProjectile = Spring.DeleteProjectile +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetGroundNormal = SpringShared.GetGroundNormal +local spGetProjectileDefID = SpringShared.GetProjectileDefID +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitRadius = SpringShared.GetUnitRadius +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitsInSphere = SpringShared.GetUnitsInSphere +local spGetProjectileTeamID = SpringShared.GetProjectileTeamID +local spGetProjectileVelocity = SpringShared.GetProjectileVelocity +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spSpawnProjectile = SpringSynced.SpawnProjectile +local spDeleteProjectile = SpringSynced.DeleteProjectile local gameSpeed = Game.gameSpeed local mapGravity = Game.gravity / (gameSpeed * gameSpeed) * -1 @@ -109,7 +109,7 @@ for unitDefID, unitDef in ipairs(UnitDefs) do local clusterCount = tonumber(weaponDef.customParams.cluster_number) if clusterCount < minSpawnNumber or clusterCount > maxSpawnNumber then - Spring.Log(gadget:GetInfo().name, LOG.WARNING, weaponDef.name .. ": cluster_count of " .. clusterCount .. ", clamping to " .. minSpawnNumber .. "-" .. maxSpawnNumber) + SpringShared.Log(gadget:GetInfo().name, LOG.WARNING, weaponDef.name .. ": cluster_count of " .. clusterCount .. ", clamping to " .. minSpawnNumber .. "-" .. maxSpawnNumber) clusterCount = clamp(clusterCount, minSpawnNumber, maxSpawnNumber) end @@ -130,10 +130,10 @@ for unitDefID, unitDef in ipairs(UnitDefs) do weaponTtl = clusterDef.flighttime or defaultSpawnTtl, } else - Spring.Log(gadget:GetInfo().name, LOG.ERROR, "Invalid weapon spawn type: " .. clusterDef.type) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, "Invalid weapon spawn type: " .. clusterDef.type) end else - Spring.Log(gadget:GetInfo().name, LOG.ERROR, "Could not find weapon def matching cluster_def: " .. clusterDefName) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, "Could not find weapon def matching cluster_def: " .. clusterDefName) end end end @@ -146,7 +146,7 @@ for weaponDefID, weaponData in pairs(clusterWeaponDefs) do end end for weaponDefID in pairs(removeIDs) do - Spring.Log(gadget:GetInfo().name, LOG.ERROR, "Preventing nested explosions: " .. WeaponDefs[weaponDefID].name) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, "Preventing nested explosions: " .. WeaponDefs[weaponDefID].name) clusterWeaponDefs[weaponDefID] = nil end @@ -251,7 +251,7 @@ end DirectionsUtil.ProvisionDirections(maxDataNum) -- When not using the engine's shield bounce, clusters add their own deflection. -local customShieldDeflect = table.contains({ "unchanged", "absorbeverything" }, Spring.GetModOptions().experimentalshields) +local customShieldDeflect = table.contains({ "unchanged", "absorbeverything" }, SpringShared.GetModOptions().experimentalshields) local projectileHitShield = {} -------------------------------------------------------------------------------- @@ -539,7 +539,7 @@ end function gadget:Initialize() if not next(clusterWeaponDefs) then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "Removing gadget. No weapons found.") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "Removing gadget. No weapons found.") gadgetHandler:RemoveGadget(self) return end @@ -549,7 +549,7 @@ function gadget:Initialize() end if not GG.Shields then - Spring.Log("ScriptedWeapons", LOG.ERROR, "Shields API unavailable (cluster)") + SpringShared.Log("ScriptedWeapons", LOG.ERROR, "Shields API unavailable (cluster)") return end diff --git a/luarules/gadgets/unit_custom_weapons_overpen.lua b/luarules/gadgets/unit_custom_weapons_overpen.lua index 573d5fd3971..c167cf6e5ba 100644 --- a/luarules/gadgets/unit_custom_weapons_overpen.lua +++ b/luarules/gadgets/unit_custom_weapons_overpen.lua @@ -71,28 +71,28 @@ local max = math.max local min = math.min local sqrt = math.sqrt -local spGetFeatureHealth = Spring.GetFeatureHealth -local spGetFeaturePosition = Spring.GetFeaturePosition -local spGetFeatureRadius = Spring.GetFeatureRadius -local spGetGroundHeight = Spring.GetGroundHeight -local spGetProjectileDirection = Spring.GetProjectileDirection -local spGetProjectilePosition = Spring.GetProjectilePosition -local spGetProjectileVelocity = Spring.GetProjectileVelocity -local spGetUnitHealth = Spring.GetUnitHealth -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitRadius = Spring.GetUnitRadius -local spGetWaterLevel = Spring.GetWaterLevel - -local spSetProjectilePosition = Spring.SetProjectilePosition -local spSetProjectileVelocity = Spring.SetProjectileVelocity -local spSetProjectileMoveCtrl = Spring.SetProjectileMoveControl - -local spAddUnitDamage = Spring.AddUnitDamage -local spAddFeatureDamage = Spring.AddFeatureDamage -local spDeleteProjectile = Spring.DeleteProjectile -local spValidFeatureID = Spring.ValidFeatureID -local spValidUnitID = Spring.ValidUnitID +local spGetFeatureHealth = SpringShared.GetFeatureHealth +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spGetFeatureRadius = SpringShared.GetFeatureRadius +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetProjectileDirection = SpringShared.GetProjectileDirection +local spGetProjectilePosition = SpringShared.GetProjectilePosition +local spGetProjectileVelocity = SpringShared.GetProjectileVelocity +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitRadius = SpringShared.GetUnitRadius +local spGetWaterLevel = SpringShared.GetWaterLevel + +local spSetProjectilePosition = SpringSynced.SetProjectilePosition +local spSetProjectileVelocity = SpringSynced.SetProjectileVelocity +local spSetProjectileMoveCtrl = SpringSynced.SetProjectileMoveControl + +local spAddUnitDamage = SpringSynced.AddUnitDamage +local spAddFeatureDamage = SpringSynced.AddFeatureDamage +local spDeleteProjectile = SpringSynced.DeleteProjectile +local spValidFeatureID = SpringShared.ValidFeatureID +local spValidUnitID = SpringShared.ValidUnitID local armorDefault = Game.armorTypes.default local armorShields = Game.armorTypes.shields @@ -526,7 +526,7 @@ end function gadget:Initialize() if not loadPenetratorWeaponDefs() then - Spring.Log(gadget:GetInfo().name, LOG.INFO, "No weapons with over-penetration found. Removing.") + SpringShared.Log(gadget:GetInfo().name, LOG.INFO, "No weapons with over-penetration found. Removing.") gadgetHandler:RemoveGadget(self) return end @@ -542,7 +542,7 @@ function gadget:Initialize() setVelocityControl = GG.SetVelocityControl if not GG.Shields then - Spring.Log("ScriptedWeapons", LOG.ERROR, "Shields API unavailable (overpen)") + SpringShared.Log("ScriptedWeapons", LOG.ERROR, "Shields API unavailable (overpen)") return end diff --git a/luarules/gadgets/unit_custommaxranges.lua b/luarules/gadgets/unit_custommaxranges.lua index 3e9ad7cfaab..0a6dc1060a7 100644 --- a/luarules/gadgets/unit_custommaxranges.lua +++ b/luarules/gadgets/unit_custommaxranges.lua @@ -23,9 +23,9 @@ end ------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------- -local spGetAllUnits = Spring.GetAllUnits -local spGetUnitDefID = Spring.GetUnitDefID -local spSetUnitMaxRange = Spring.SetUnitMaxRange +local spGetAllUnits = SpringShared.GetAllUnits +local spGetUnitDefID = SpringShared.GetUnitDefID +local spSetUnitMaxRange = SpringSynced.SetUnitMaxRange local unitMaxRange = {} for unitDefID, unitDef in pairs(UnitDefs) do diff --git a/luarules/gadgets/unit_dead.lua b/luarules/gadgets/unit_dead.lua index 337587fffb8..2b2f1e1b617 100644 --- a/luarules/gadgets/unit_dead.lua +++ b/luarules/gadgets/unit_dead.lua @@ -15,10 +15,10 @@ if gadgetHandler:IsSyncedCode() then end function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam, weaponDefID) - Spring.SetUnitNoSelect(unitID, true) - if Spring.SetUnitNoGroup then - Spring.SetUnitNoGroup(unitID, true) + SpringUnsynced.SetUnitNoSelect(unitID, true) + if SpringUnsynced.SetUnitNoGroup then + SpringUnsynced.SetUnitNoGroup(unitID, true) else - Spring.SetUnitGroup(unitID, -1) + SpringUnsynced.SetUnitGroup(unitID, -1) end end diff --git a/luarules/gadgets/unit_death_animations.lua b/luarules/gadgets/unit_death_animations.lua index 3ca6836f210..dc38cc34462 100644 --- a/luarules/gadgets/unit_death_animations.lua +++ b/luarules/gadgets/unit_death_animations.lua @@ -16,12 +16,12 @@ if not gadgetHandler:IsSyncedCode() then return end -local spSetUnitBlocking = Spring.SetUnitBlocking -local spSetUnitIconDraw = Spring.SetUnitIconDraw -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spMoveCtrlEnable = Spring.MoveCtrl.Enable -local spMoveCtrlDisable = Spring.MoveCtrl.Disable -local spMoveCtrlSetVelocity = Spring.MoveCtrl.SetVelocity +local spSetUnitBlocking = SpringSynced.SetUnitBlocking +local spSetUnitIconDraw = SpringUnsynced.SetUnitIconDraw +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spMoveCtrlEnable = SpringSynced.MoveCtrl.Enable +local spMoveCtrlDisable = SpringSynced.MoveCtrl.Disable +local spMoveCtrlSetVelocity = SpringSynced.MoveCtrl.SetVelocity local stringFind = string.find local tableCopy = table.copy diff --git a/luarules/gadgets/unit_dgun_behaviour.lua b/luarules/gadgets/unit_dgun_behaviour.lua index 080265caf8b..9eeb3616bcb 100644 --- a/luarules/gadgets/unit_dgun_behaviour.lua +++ b/luarules/gadgets/unit_dgun_behaviour.lua @@ -14,17 +14,17 @@ if not gadgetHandler:IsSyncedCode() then return end -local spSetProjectilePosition = Spring.SetProjectilePosition -local spSetProjectileVelocity = Spring.SetProjectileVelocity -local spGetProjectilePosition = Spring.GetProjectilePosition -local spGetProjectileDirection = Spring.GetProjectileDirection -local spGetProjectileVelocity = Spring.GetProjectileVelocity -local spGetGroundHeight = Spring.GetGroundHeight -local spDeleteProjectile = Spring.DeleteProjectile -local spSetProjectileCollision = Spring.SetProjectileCollision -local spGetUnitPosition = Spring.GetUnitPosition -local spSpawnCEG = Spring.SpawnCEG -local spGetGameFrame = Spring.GetGameFrame +local spSetProjectilePosition = SpringSynced.SetProjectilePosition +local spSetProjectileVelocity = SpringSynced.SetProjectileVelocity +local spGetProjectilePosition = SpringShared.GetProjectilePosition +local spGetProjectileDirection = SpringShared.GetProjectileDirection +local spGetProjectileVelocity = SpringShared.GetProjectileVelocity +local spGetGroundHeight = SpringShared.GetGroundHeight +local spDeleteProjectile = SpringSynced.DeleteProjectile +local spSetProjectileCollision = SpringSynced.SetProjectileCollision +local spGetUnitPosition = SpringShared.GetUnitPosition +local spSpawnCEG = SpringSynced.SpawnCEG +local spGetGameFrame = SpringShared.GetGameFrame local mathSqrt = math.sqrt local mathMax = math.max @@ -204,7 +204,7 @@ end function gadget:Initialize() if not GG.Shields then - Spring.Log("ScriptedWeapons", LOG.ERROR, "Shields API unavailable (dgun)") + SpringShared.Log("ScriptedWeapons", LOG.ERROR, "Shields API unavailable (dgun)") return end diff --git a/luarules/gadgets/unit_dgun_cmdtype_fix.lua b/luarules/gadgets/unit_dgun_cmdtype_fix.lua index 970d10eb1be..d400c5d8ab6 100644 --- a/luarules/gadgets/unit_dgun_cmdtype_fix.lua +++ b/luarules/gadgets/unit_dgun_cmdtype_fix.lua @@ -23,9 +23,9 @@ for uDefID, uDef in pairs(UnitDefs) do end end -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc -local spGetUnitCmdDescs = Spring.GetUnitCmdDescs -local spEditUnitCmdDesc = Spring.EditUnitCmdDesc +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc +local spGetUnitCmdDescs = SpringShared.GetUnitCmdDescs +local spEditUnitCmdDesc = SpringSynced.EditUnitCmdDesc local CMD_DGUN = CMD.MANUALFIRE local CMDTYPE_ICON_UNIT_OR_MAP = CMDTYPE.ICON_UNIT_OR_MAP diff --git a/luarules/gadgets/unit_disallow_underwater_load.lua b/luarules/gadgets/unit_disallow_underwater_load.lua index 405db26fd99..ba9027b4416 100644 --- a/luarules/gadgets/unit_disallow_underwater_load.lua +++ b/luarules/gadgets/unit_disallow_underwater_load.lua @@ -15,8 +15,8 @@ end if gadgetHandler:IsSyncedCode() then function gadget:AllowUnitTransport(transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam) - local _, y, _ = Spring.GetUnitPosition(transporteeID) - local height = Spring.GetUnitHeight(transporteeID) + local _, y, _ = SpringShared.GetUnitPosition(transporteeID) + local height = SpringShared.GetUnitHeight(transporteeID) if not height or y + height < 0 then return false else @@ -25,7 +25,7 @@ if gadgetHandler:IsSyncedCode() then end function gadget:AllowUnitTransportUnload(transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam, x, y, z) -- disallow unloading underwater - local height = Spring.GetUnitHeight(transporteeID) + local height = SpringShared.GetUnitHeight(transporteeID) if not height or y + height < 0 then return false else @@ -34,7 +34,7 @@ if gadgetHandler:IsSyncedCode() then end function gadget:AllowUnitTransportLoad(transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam, x, y, z) -- disallow unloading underwater - local height = Spring.GetUnitHeight(transporteeID) + local height = SpringShared.GetUnitHeight(transporteeID) if not height or y + height < 0 then return false else diff --git a/luarules/gadgets/unit_dragons_disguise.lua b/luarules/gadgets/unit_dragons_disguise.lua index d911b3b5793..f27460ca958 100644 --- a/luarules/gadgets/unit_dragons_disguise.lua +++ b/luarules/gadgets/unit_dragons_disguise.lua @@ -17,8 +17,8 @@ if not gadgetHandler:IsSyncedCode() then end local GetUnitCOBValue = Spring.GetUnitCOBValue -local SetUnitNeutral = Spring.SetUnitNeutral -local ValidUnitID = Spring.ValidUnitID +local SetUnitNeutral = SpringSynced.SetUnitNeutral +local ValidUnitID = SpringShared.ValidUnitID local neutralUnits = {} local armourTurrets = {} for udid, ud in ipairs(UnitDefs) do @@ -32,10 +32,10 @@ local UPDATE = 30 local timeCounter = 15 function gadget:Initialize() - for _, unitID in ipairs(Spring.GetAllUnits()) do - if not Spring.GetUnitIsBeingBuilt(unitID) then + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + if not SpringShared.GetUnitIsBeingBuilt(unitID) then ---@diagnostic disable-next-line: missing-parameter, param-type-mismatch -- OK - gadget:UnitFinished(unitID, Spring.GetUnitDefID(unitID)) + gadget:UnitFinished(unitID, SpringShared.GetUnitDefID(unitID)) end end end diff --git a/luarules/gadgets/unit_dynamic_collision_volume.lua b/luarules/gadgets/unit_dynamic_collision_volume.lua index fcda1a92771..0dbfc03955b 100644 --- a/luarules/gadgets/unit_dynamic_collision_volume.lua +++ b/luarules/gadgets/unit_dynamic_collision_volume.lua @@ -19,22 +19,22 @@ if gadgetHandler:IsSyncedCode() then local unitCollisionVolume, pieceCollisionVolume, dynamicPieceCollisionVolume -- Localization and speedups - local spSetPieceCollisionData = Spring.SetUnitPieceCollisionVolumeData - local spGetPieceList = Spring.GetUnitPieceList - local spGetUnitDefID = Spring.GetUnitDefID - local spGetUnitCollisionData = Spring.GetUnitCollisionVolumeData - local spSetUnitCollisionData = Spring.SetUnitCollisionVolumeData - local spSetUnitRadiusAndHeight = Spring.SetUnitRadiusAndHeight - local spGetUnitRadius = Spring.GetUnitRadius - local spGetUnitHeight = Spring.GetUnitHeight - local spSetUnitMidAndAimPos = Spring.SetUnitMidAndAimPos - local spGetFeatureCollisionData = Spring.GetFeatureCollisionVolumeData - local spSetFeatureCollisionData = Spring.SetFeatureCollisionVolumeData - local spSetFeatureRadiusAndHeight = Spring.SetFeatureRadiusAndHeight - local spGetFeatureRadius = Spring.GetFeatureRadius - local spGetFeatureHeight = Spring.GetFeatureHeight + local spSetPieceCollisionData = SpringSynced.SetUnitPieceCollisionVolumeData + local spGetPieceList = SpringShared.GetUnitPieceList + local spGetUnitDefID = SpringShared.GetUnitDefID + local spGetUnitCollisionData = SpringShared.GetUnitCollisionVolumeData + local spSetUnitCollisionData = SpringSynced.SetUnitCollisionVolumeData + local spSetUnitRadiusAndHeight = SpringSynced.SetUnitRadiusAndHeight + local spGetUnitRadius = SpringShared.GetUnitRadius + local spGetUnitHeight = SpringShared.GetUnitHeight + local spSetUnitMidAndAimPos = SpringSynced.SetUnitMidAndAimPos + local spGetFeatureCollisionData = SpringShared.GetFeatureCollisionVolumeData + local spSetFeatureCollisionData = SpringSynced.SetFeatureCollisionVolumeData + local spSetFeatureRadiusAndHeight = SpringSynced.SetFeatureRadiusAndHeight + local spGetFeatureRadius = SpringShared.GetFeatureRadius + local spGetFeatureHeight = SpringShared.GetFeatureHeight - local spArmor = Spring.GetUnitArmored + local spArmor = SpringShared.GetUnitArmored local pairs = pairs local pieceIndexStr = {} for i = 0, 99 do @@ -94,12 +94,12 @@ if gadgetHandler:IsSyncedCode() then unitCollisionVolume, pieceCollisionVolume, dynamicPieceCollisionVolume = include("LuaRules/Configs/CollisionVolumes.lua") local mapConfig = "LuaRules/Configs/DynCVmapCFG/" .. Game.mapName .. ".lua" - local allFeatures = Spring.GetAllFeatures() + local allFeatures = SpringShared.GetAllFeatures() if VFS.FileExists(mapConfig) then local mapFeatures = VFS.Include(mapConfig) for i = 1, #allFeatures do local featID = allFeatures[i] - local modelpath = FeatureDefs[Spring.GetFeatureDefID(featID)].modelpath + local modelpath = FeatureDefs[SpringShared.GetFeatureDefID(featID)].modelpath local featureModel = modelpath:lower() if featureModel:len() > 4 then local featureModelTrim = featureModel:sub(1, -5) -- featureModel:match("/.*%."):sub(2,-2) @@ -119,7 +119,7 @@ if gadgetHandler:IsSyncedCode() then else for i = 1, #allFeatures do local featID = allFeatures[i] - local modelpath = FeatureDefs[Spring.GetFeatureDefID(featID)].modelpath + local modelpath = FeatureDefs[SpringShared.GetFeatureDefID(featID)].modelpath local featureModel = modelpath:lower() if featureModel:find(".3do") then local rs, hs @@ -141,7 +141,7 @@ if gadgetHandler:IsSyncedCode() then end end end - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for i = 1, #allUnits do local unitID = allUnits[i] gadget:UnitCreated(unitID, spGetUnitDefID(unitID)) @@ -159,7 +159,7 @@ if gadgetHandler:IsSyncedCode() then function gadget:UnitCreated(unitID, unitDefID, unitTeam) if unitDefMidAndAimPos[unitDefID] then local midAndAimPos = unitDefMidAndAimPos[unitDefID] - Spring.SetUnitMidAndAimPos( + SpringSynced.SetUnitMidAndAimPos( unitID, midAndAimPos["midx"] or 0, midAndAimPos["midy"] or 0, @@ -262,7 +262,7 @@ if gadgetHandler:IsSyncedCode() then if featureDefMidAndAimPos[featureDefID] then --Spring.SetFeatureMidAndAimPos ( number featureID, number mpX, number mpY, number mpZ, number apX, number apY, number apZ [, bool relative ) local midAndAimPos = featureDefMidAndAimPos[featureDefID] - Spring.SetFeatureMidAndAimPos( + SpringSynced.SetFeatureMidAndAimPos( featureID, midAndAimPos["midx"] or 0, midAndAimPos["midy"] or 0, @@ -272,7 +272,7 @@ if gadgetHandler:IsSyncedCode() then midAndAimPos["aimz"] or 0 -- relative? ) end - if is3doFeature[Spring.GetFeatureDefID(featureID)] then + if is3doFeature[SpringShared.GetFeatureDefID(featureID)] then local rs, hs if spGetFeatureRadius(featureID) > 47 then rs, hs = 0.68, 0.60 diff --git a/luarules/gadgets/unit_evolution.lua b/luarules/gadgets/unit_evolution.lua index 30ddeefe211..47ba1ab2d08 100644 --- a/luarules/gadgets/unit_evolution.lua +++ b/luarules/gadgets/unit_evolution.lua @@ -14,28 +14,28 @@ end if gadgetHandler:IsSyncedCode() then - local spCreateUnit = Spring.CreateUnit - local spDestroyUnit = Spring.DestroyUnit - local spGiveOrderToUnit = Spring.GiveOrderToUnit - local spSetUnitRulesParam = Spring.SetUnitRulesParam - local spGetUnitPosition = Spring.GetUnitPosition - local spGetUnitStates = Spring.GetUnitStates - local spGetUnitHealth = Spring.GetUnitHealth - local spGetUnitTransporter = Spring.GetUnitTransporter - - local spGetTeamList = Spring.GetTeamList - local spGetUnitExperience = Spring.GetUnitExperience - local spGetUnitTeam = Spring.GetUnitTeam - local spGetUnitDirection = Spring.GetUnitDirection - local spGetUnitStockpile = Spring.GetUnitStockpile - local spEcho = Spring.Echo - local spSetUnitHealth = Spring.SetUnitHealth - - local spSetUnitExperience = Spring.SetUnitExperience - local spSetUnitStockpile = Spring.SetUnitStockpile - local spSetUnitDirection = Spring.SetUnitDirection - local spGetGameSeconds = Spring.GetGameSeconds - local spGetUnitNearestEnemy = Spring.GetUnitNearestEnemy + local spCreateUnit = SpringSynced.CreateUnit + local spDestroyUnit = SpringSynced.DestroyUnit + local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit + local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam + local spGetUnitPosition = SpringShared.GetUnitPosition + local spGetUnitStates = SpringShared.GetUnitStates + local spGetUnitHealth = SpringShared.GetUnitHealth + local spGetUnitTransporter = SpringShared.GetUnitTransporter + + local spGetTeamList = SpringShared.GetTeamList + local spGetUnitExperience = SpringShared.GetUnitExperience + local spGetUnitTeam = SpringShared.GetUnitTeam + local spGetUnitDirection = SpringShared.GetUnitDirection + local spGetUnitStockpile = SpringShared.GetUnitStockpile + local spEcho = SpringShared.Echo + local spSetUnitHealth = SpringSynced.SetUnitHealth + + local spSetUnitExperience = SpringSynced.SetUnitExperience + local spSetUnitStockpile = SpringSynced.SetUnitStockpile + local spSetUnitDirection = SpringSynced.SetUnitDirection + local spGetGameSeconds = SpringShared.GetGameSeconds + local spGetUnitNearestEnemy = SpringShared.GetUnitNearestEnemy local GAME_SPEED = Game.gameSpeed local PRIVATE = { private = true } @@ -87,22 +87,22 @@ if gadgetHandler:IsSyncedCode() then } local function reAssignAssists(newUnit, oldUnit) - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for _, unitID in pairs(allUnits) do if GG.GetUnitTarget and GG.GetUnitTarget(unitID) == oldUnit and newUnit then -- GG.SetUnitTarget(unitID, newUnit) -- FIXME: unit_target_on_the_move provides only GetUnitTarget - Spring.SetUnitTarget(unitID, newUnit) + SpringSynced.SetUnitTarget(unitID, newUnit) end - local cmds = Spring.GetUnitCommands(unitID, -1) + local cmds = SpringShared.GetUnitCommands(unitID, -1) for j = 1, #cmds do local cmd = cmds[j] local params = cmd.params if (unitTargetCommand[cmd.id] or (singleParamUnitTargetCommand[cmd.id] and #params == 1)) and (params[1] == oldUnit) then params[1] = newUnit local opts = (cmd.options.meta and CMD.OPT_META or 0) + (cmd.options.ctrl and CMD.OPT_CTRL or 0) + (cmd.options.alt and CMD.OPT_ALT or 0) - Spring.GiveOrderToUnit(unitID, CMD.INSERT, { cmd.tag, cmd.id, opts, params[1], params[2], params[3] }, 0) - Spring.GiveOrderToUnit(unitID, CMD.REMOVE, cmd.tag, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.INSERT, { cmd.tag, cmd.id, opts, params[1], params[2], params[3] }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.REMOVE, cmd.tag, 0) end end end @@ -162,11 +162,11 @@ if gadgetHandler:IsSyncedCode() then local team = spGetUnitTeam(unitID) local states = spGetUnitStates(unitID) local dx, dy, dz = spGetUnitDirection(unitID) - local heading = Spring.GetUnitHeading(unitID) - local face = Spring.GetFacingFromHeading(heading) + local heading = SpringShared.GetUnitHeading(unitID) + local face = SpringShared.GetFacingFromHeading(heading) local stockpile, stockpilequeued, stockpilebuildpercent = spGetUnitStockpile(unitID) - local commandQueue = Spring.GetUnitCommands(unitID, -1) - local transporter = Spring.GetUnitTransporter(unitID) + local commandQueue = SpringShared.GetUnitCommands(unitID, -1) + local transporter = SpringShared.GetUnitTransporter(unitID) local toUnitNameSkipped, delayedSeconds = skipEvolutions(evolution) if not UnitDefNames[toUnitNameSkipped] then @@ -223,25 +223,25 @@ if gadgetHandler:IsSyncedCode() then reAssignAssists(newUnitID, unitID) if commandQueue[1] then - local teamID = Spring.GetUnitTeam(unitID) + local teamID = SpringShared.GetUnitTeam(unitID) for _, command in pairs(commandQueue) do local coded = command.options.coded + (command.options.shift and 0 or CMD.OPT_SHIFT) -- orders without SHIFT can appear at positions other than the 1st due to CMD.INSERT; they'd cancel any previous commands if added raw if command.id < 0 then -- repair case for construction - local units = CallAsTeam(teamID, Spring.GetUnitsInRectangle, command.params[1] - 16, command.params[3] - 16, command.params[1] + 16, command.params[3] + 16, -3) + local units = CallAsTeam(teamID, SpringShared.GetUnitsInRectangle, command.params[1] - 16, command.params[3] - 16, command.params[1] + 16, command.params[3] + 16, -3) local notFound = true for j = 1, #units do local areaUnitID = units[j] - if Spring.GetUnitDefID(areaUnitID) == -command.id then - Spring.GiveOrderToUnit(newUnitID, CMD.REPAIR, areaUnitID, coded) + if SpringShared.GetUnitDefID(areaUnitID) == -command.id then + SpringSynced.GiveOrderToUnit(newUnitID, CMD.REPAIR, areaUnitID, coded) notFound = false break end end if notFound then - Spring.GiveOrderToUnit(newUnitID, command.id, command.params, coded) + SpringSynced.GiveOrderToUnit(newUnitID, command.id, command.params, coded) end else - Spring.GiveOrderToUnit(newUnitID, command.id, command.params, coded) + SpringSynced.GiveOrderToUnit(newUnitID, command.id, command.params, coded) end end end @@ -341,8 +341,8 @@ if gadgetHandler:IsSyncedCode() then local function getTotalUnitCount() local totalUnits = 0 - for _, teamID in ipairs(Spring.GetTeamList()) do - totalUnits = totalUnits + Spring.GetTeamUnitCount(teamID) + for _, teamID in ipairs(SpringShared.GetTeamList()) do + totalUnits = totalUnits + SpringShared.GetTeamUnitCount(teamID) end return totalUnits end @@ -425,9 +425,9 @@ if gadgetHandler:IsSyncedCode() then else - local spSelectUnitArray = Spring.SelectUnitArray - local spGetSelectedUnits = Spring.GetSelectedUnits - local spGetGameSeconds = Spring.GetGameSeconds + local spSelectUnitArray = SpringUnsynced.SelectUnitArray + local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits + local spGetGameSeconds = SpringShared.GetGameSeconds local announcementStart = 0 local announcementEnabled = false @@ -436,8 +436,8 @@ else local displayList - local fontfile = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") - local vsx, vsy = Spring.GetViewGeometry() + local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") + local vsx, vsy = SpringUnsynced.GetViewGeometry() local fontfileScale = (0.5 + (vsx * vsy / 6200000)) local fontfileSize = 50 local fontfileOutlineSize = 10 @@ -445,7 +445,7 @@ else local font = gl.LoadFont(fontfile, fontfileSize * fontfileScale, fontfileOutlineSize * fontfileScale, fontfileOutlineStrength) local function draw(newAnnouncement, newAnnouncementSize) - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() local uiScale = (0.7 + (vsx * vsy / 6500000)) displayList = gl.CreateList(function() font:Begin() @@ -459,9 +459,9 @@ else local function evolveFinished(cmd, oldID, newID, newAnnouncement, newAnnouncementSize) local selUnits = spGetSelectedUnits() - local unitGroup = Spring.GetUnitGroup(oldID) + local unitGroup = SpringUnsynced.GetUnitGroup(oldID) if unitGroup then - Spring.SetUnitGroup(newID, unitGroup) + SpringUnsynced.SetUnitGroup(newID, unitGroup) end for i = 1, #selUnits do local unitID = selUnits[i] @@ -480,7 +480,7 @@ else end function gadget:DrawScreen() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if announcementEnabled then diff --git a/luarules/gadgets/unit_explosion_spawner.lua b/luarules/gadgets/unit_explosion_spawner.lua index 2b75cae9687..f68136a49cf 100644 --- a/luarules/gadgets/unit_explosion_spawner.lua +++ b/luarules/gadgets/unit_explosion_spawner.lua @@ -25,25 +25,25 @@ end -- spawns_ceg = use to spawn an arbitrary ceg in addition to the explosion effect used in the weapondefs. uses Spring.SpawnCEG() -- spawns_stun = a number, use it to define how long a unit will be stunned for after landing. -local spCreateFeature = Spring.CreateFeature -local spCreateUnit = Spring.CreateUnit -local spDestroyUnit = Spring.DestroyUnit -local spGetGameFrame = Spring.GetGameFrame -local spGetProjectileDefID = Spring.GetProjectileDefID -local spGetProjectileTeamID = Spring.GetProjectileTeamID -local spGetUnitShieldState = Spring.GetUnitShieldState -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spSetFeatureDirection = Spring.SetFeatureDirection -local spSetUnitRulesParam = Spring.SetUnitRulesParam -local spSpawnCEG = Spring.SpawnCEG -local spGetUnitHealth = Spring.GetUnitHealth -local spSetUnitHealth = Spring.SetUnitHealth -local spGetUnitPosition = Spring.GetUnitPosition -local spGetGroundHeight = Spring.GetGroundHeight -local spGetUnitTeam = Spring.GetUnitTeam -local spSetUnitDirection = Spring.SetUnitDirection -local spAddUnitImpulse = Spring.AddUnitImpulse -local spEcho = Spring.Echo +local spCreateFeature = SpringSynced.CreateFeature +local spCreateUnit = SpringSynced.CreateUnit +local spDestroyUnit = SpringSynced.DestroyUnit +local spGetGameFrame = SpringShared.GetGameFrame +local spGetProjectileDefID = SpringShared.GetProjectileDefID +local spGetProjectileTeamID = SpringShared.GetProjectileTeamID +local spGetUnitShieldState = SpringShared.GetUnitShieldState +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spSetFeatureDirection = SpringSynced.SetFeatureDirection +local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam +local spSpawnCEG = SpringSynced.SpawnCEG +local spGetUnitHealth = SpringShared.GetUnitHealth +local spSetUnitHealth = SpringSynced.SetUnitHealth +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetUnitTeam = SpringShared.GetUnitTeam +local spSetUnitDirection = SpringSynced.SetUnitDirection +local spAddUnitImpulse = SpringSynced.AddUnitImpulse +local spEcho = SpringShared.Echo local mapsizeX = Game.mapSizeX local mapsizeZ = Game.mapSizeZ @@ -101,9 +101,9 @@ for weaponDefID = 1, #WeaponDefs do end local scavengerAITeamID = 999 -local teams = Spring.GetTeamList() +local teams = SpringShared.GetTeamList() for i = 1, #teams do - local luaAI = Spring.GetTeamLuaAI(teams[i]) + local luaAI = SpringShared.GetTeamLuaAI(teams[i]) if luaAI and luaAI ~= "" and string.sub(luaAI, 1, 12) == "ScavengersAI" then scavengerAITeamID = i - 1 break @@ -242,9 +242,9 @@ function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, w local health = spGetUnitHealth(unitID) if health and damage and damage > health then if attackerID then - Spring.DestroyUnit(unitID, true, false, attackerID) + SpringSynced.DestroyUnit(unitID, true, false, attackerID) else - Spring.DestroyUnit(unitID, true) + SpringSynced.DestroyUnit(unitID, true) end end end diff --git a/luarules/gadgets/unit_factory_guard.lua b/luarules/gadgets/unit_factory_guard.lua index 726b1d6cac0..e38b1468acc 100644 --- a/luarules/gadgets/unit_factory_guard.lua +++ b/luarules/gadgets/unit_factory_guard.lua @@ -17,14 +17,14 @@ function gadget:GetInfo() } end -local spGetUnitBuildFacing = Spring.GetUnitBuildFacing -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitRadius = Spring.GetUnitRadius -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spInsertUnitCmdDesc = Spring.InsertUnitCmdDesc -local spEditUnitCmdDesc = Spring.EditUnitCmdDesc -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc -local spTestMoveOrder = Spring.TestMoveOrder +local spGetUnitBuildFacing = SpringShared.GetUnitBuildFacing +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitRadius = SpringShared.GetUnitRadius +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spInsertUnitCmdDesc = SpringSynced.InsertUnitCmdDesc +local spEditUnitCmdDesc = SpringSynced.EditUnitCmdDesc +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc +local spTestMoveOrder = SpringShared.TestMoveOrder local CMD_FACTORY_GUARD = GameCMD.FACTORY_GUARD local CMD_GUARD = CMD.GUARD @@ -147,8 +147,8 @@ function gadget:UnitFromFactory(unitID, unitDefID, unitTeam, factID, factDefID, return -- already has user assigned orders end - local factoryGuardCmdDescID = Spring.FindUnitCmdDesc(factID, CMD_FACTORY_GUARD) -- get CmdDescID - local cmdDesc = Spring.GetUnitCmdDescs(factID, factoryGuardCmdDescID)[1] -- use CmdDescID to get state of that cmd (comes back as a table, we get the first element) + local factoryGuardCmdDescID = SpringShared.FindUnitCmdDesc(factID, CMD_FACTORY_GUARD) -- get CmdDescID + local cmdDesc = SpringShared.GetUnitCmdDescs(factID, factoryGuardCmdDescID)[1] -- use CmdDescID to get state of that cmd (comes back as a table, we get the first element) local factoryGuardEnabled = cmdDesc.params[1] == "1" if not cmdDesc or not factoryGuardEnabled then -- if state is missing or false, do nothing return @@ -169,9 +169,9 @@ end function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD_FACTORY_GUARD) - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for i = 1, #allUnits do - gadget:UnitCreated(allUnits[i], Spring.GetUnitDefID(allUnits[i])) + gadget:UnitCreated(allUnits[i], SpringShared.GetUnitDefID(allUnits[i])) end end -------------------------------------------------------------------------------- diff --git a/luarules/gadgets/unit_factory_quota.lua b/luarules/gadgets/unit_factory_quota.lua index e108658ebc3..fe63b9ea42a 100644 --- a/luarules/gadgets/unit_factory_quota.lua +++ b/luarules/gadgets/unit_factory_quota.lua @@ -16,11 +16,11 @@ function gadget:GetInfo() } end -local SpringFindUnitCmdDesc = Spring.FindUnitCmdDesc -local SpringEditUnitCmdDesc = Spring.EditUnitCmdDesc -local SpringInsertUnitCmdDesc = Spring.InsertUnitCmdDesc -local SpringGetAllUnits = Spring.GetAllUnits -local SpringGetUnitDefID = Spring.GetUnitDefID +local SpringFindUnitCmdDesc = SpringShared.FindUnitCmdDesc +local SpringEditUnitCmdDesc = SpringSynced.EditUnitCmdDesc +local SpringInsertUnitCmdDesc = SpringSynced.InsertUnitCmdDesc +local SpringGetAllUnits = SpringShared.GetAllUnits +local SpringGetUnitDefID = SpringShared.GetUnitDefID local CMD_QUOTA_BUILD_TOGGLE = GameCMD.QUOTA_BUILD_TOGGLE diff --git a/luarules/gadgets/unit_factory_unblocking.lua b/luarules/gadgets/unit_factory_unblocking.lua index 2b6263dcab5..ab259f86ff3 100644 --- a/luarules/gadgets/unit_factory_unblocking.lua +++ b/luarules/gadgets/unit_factory_unblocking.lua @@ -41,9 +41,9 @@ function gadget:UnitFinished(unitID, unitDefID, unitTeam) -- also the second false is to clear CSTATE_BIT_SOLIDOBJECTS, so landing aircraft do not claim dumb spots as blocking -- TODO, engine fix to prevent this nonsense - Spring.SetUnitBlocking(unitID, false, false) + SpringSynced.SetUnitBlocking(unitID, false, false) else - Spring.SetUnitBlocking(unitID, true) + SpringSynced.SetUnitBlocking(unitID, true) end setBlockingOnFinished[unitID] = nil end @@ -52,7 +52,7 @@ end function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) if factoryUnits[builderID] then -- first false is to set blocking on ground - Spring.SetUnitBlocking(unitID, false) + SpringSynced.SetUnitBlocking(unitID, false) setBlockingOnFinished[unitID] = true end end @@ -63,10 +63,10 @@ function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerD end function gadget:Initialize() - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for _, unitID in ipairs(allUnits) do - local unitDefID = Spring.GetUnitDefID(unitID) - local unitTeamID = Spring.GetUnitTeam(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) + local unitTeamID = SpringShared.GetUnitTeam(unitID) gadget:UnitFinished(unitID, unitDefID, unitTeamID) end end diff --git a/luarules/gadgets/unit_footprint_clearance.lua b/luarules/gadgets/unit_footprint_clearance.lua index 5296aad8526..75f7b311de2 100644 --- a/luarules/gadgets/unit_footprint_clearance.lua +++ b/luarules/gadgets/unit_footprint_clearance.lua @@ -37,20 +37,20 @@ function gadget:UnitCreated(uID, uDefID, uTeam, bID) --Instagibb any features that are unlucky enough to be in the build radius of new construction projects if unitXsize5[uDefID] then -- buildings/factories local xr, zr - if Spring.GetUnitBuildFacing(uID) % 2 == 0 then + if SpringShared.GetUnitBuildFacing(uID) % 2 == 0 then xr, zr = unitXsize5[uDefID], unitZsize5[uDefID] else xr, zr = unitZsize5[uDefID], unitXsize5[uDefID] end - local ux, _, uz = Spring.GetUnitPosition(uID) - local features = Spring.GetFeaturesInRectangle(ux - xr, uz - zr, ux + xr, uz + zr) + local ux, _, uz = SpringShared.GetUnitPosition(uID) + local features = SpringShared.GetFeaturesInRectangle(ux - xr, uz - zr, ux + xr, uz + zr) for i = 1, #features do - if gibFeatureDefs[Spring.GetFeatureDefID(features[i])] then - local fx, fy, fz = Spring.GetFeaturePosition(features[i]) - Spring.DestroyFeature(features[i]) - Spring.SpawnCEG("sparklegreen", fx, fy, fz) - Spring.PlaySoundFile("reclaimate", 1, fx, fy, fz, "sfx") + if gibFeatureDefs[SpringShared.GetFeatureDefID(features[i])] then + local fx, fy, fz = SpringShared.GetFeaturePosition(features[i]) + SpringSynced.DestroyFeature(features[i]) + SpringSynced.SpawnCEG("sparklegreen", fx, fy, fz) + SpringUnsynced.PlaySoundFile("reclaimate", 1, fx, fy, fz, "sfx") end end end diff --git a/luarules/gadgets/unit_geo_upgrade_reclaimer.lua b/luarules/gadgets/unit_geo_upgrade_reclaimer.lua index 1bd828d427b..2e1547e574c 100644 --- a/luarules/gadgets/unit_geo_upgrade_reclaimer.lua +++ b/luarules/gadgets/unit_geo_upgrade_reclaimer.lua @@ -28,10 +28,10 @@ for unitDefID, unitDef in pairs(UnitDefs) do end local function hasGeoUnderneat(unitID) - local x, _, z = Spring.GetUnitPosition(unitID) - local units = Spring.GetUnitsInCylinder(x, z, 10) + local x, _, z = SpringShared.GetUnitPosition(unitID) + local units = SpringShared.GetUnitsInCylinder(x, z, 10) for k, uID in ipairs(units) do - if isGeo[Spring.GetUnitDefID(uID)] and Spring.GetUnitIsDead(uID) == false then + if isGeo[SpringShared.GetUnitDefID(uID)] and SpringShared.GetUnitIsDead(uID) == false then if unitID ~= uID then return uID end @@ -45,12 +45,12 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam) if isGeo[unitDefID] then local geo = hasGeoUnderneat(unitID) if geo then - Spring.SetUnitNoSelect(geo, true) + SpringUnsynced.SetUnitNoSelect(geo, true) if transferInstantly then - local mexTeamID = Spring.GetUnitTeam(geo) - if mexTeamID ~= unitTeam and not select(3, Spring.GetTeamInfo(mexTeamID, false)) then - _G.transferredUnits[unitID] = Spring.GetGameFrame() - Spring.TransferUnit(unitID, mexTeamID) + local mexTeamID = SpringShared.GetUnitTeam(geo) + if mexTeamID ~= unitTeam and not select(3, SpringShared.GetTeamInfo(mexTeamID, false)) then + _G.transferredUnits[unitID] = SpringShared.GetGameFrame() + SpringSynced.TransferUnit(unitID, mexTeamID) end end end @@ -62,7 +62,7 @@ function gadget:UnitDestroyed(unitID, unitDefID, teamID, attackerID, attackerDef if isGeo[unitDefID] then local geo = hasGeoUnderneat(unitID) if geo then - Spring.SetUnitNoSelect(geo, false) + SpringUnsynced.SetUnitNoSelect(geo, false) end end end @@ -72,12 +72,12 @@ function gadget:UnitFinished(unitID, unitDefID, unitTeam) Spring.SetUnitCOBValue(unitID, COB.YARD_OPEN, 1) local geo = hasGeoUnderneat(unitID) if geo then - local geoTeamID = Spring.GetUnitTeam(geo) - Spring.DestroyUnit(geo, false, true) - Spring.AddTeamResource(unitTeam, "metal", isGeo[Spring.GetUnitDefID(geo)]) - if not transferInstantly and geoTeamID ~= unitTeam and not select(3, Spring.GetTeamInfo(geoTeamID, false)) then - _G.transferredUnits[unitID] = Spring.GetGameFrame() - Spring.TransferUnit(unitID, geoTeamID) + local geoTeamID = SpringShared.GetUnitTeam(geo) + SpringSynced.DestroyUnit(geo, false, true) + SpringSynced.AddTeamResource(unitTeam, "metal", isGeo[SpringShared.GetUnitDefID(geo)]) + if not transferInstantly and geoTeamID ~= unitTeam and not select(3, SpringShared.GetTeamInfo(geoTeamID, false)) then + _G.transferredUnits[unitID] = SpringShared.GetGameFrame() + SpringSynced.TransferUnit(unitID, geoTeamID) end end end diff --git a/luarules/gadgets/unit_hats.lua b/luarules/gadgets/unit_hats.lua index a4adb15bf14..460183586e7 100644 --- a/luarules/gadgets/unit_hats.lua +++ b/luarules/gadgets/unit_hats.lua @@ -1,5 +1,5 @@ -if Spring.GetModOptions().teamcolors_anonymous_mode ~= "disabled" then +if SpringShared.GetModOptions().teamcolors_anonymous_mode ~= "disabled" then return end @@ -64,7 +64,7 @@ local unitDefCanWearHats = { [UnitDefNames.armdecom.id] = true, } -if Spring.GetModOptions().experimentallegionfaction then +if SpringShared.GetModOptions().experimentallegionfaction then unitDefCanWearHats[UnitDefNames.legcom.id] = true unitDefCanWearHats[UnitDefNames.legcomlvl2.id] = true unitDefCanWearHats[UnitDefNames.legcomlvl3.id] = true @@ -148,81 +148,81 @@ local spawnWarpInFrame = Game.spawnWarpInFrame function gadget:GameFrame(gf) if gf == spawnWarpInFrame then - for _, playerID in ipairs(Spring.GetPlayerList()) do + for _, playerID in ipairs(SpringShared.GetPlayerList()) do local accountID = false - local playerName, _, spec, teamID, _, _, _, _, _, _, accountInfo = Spring.GetPlayerInfo(playerID) + local playerName, _, spec, teamID, _, _, _, _, _, _, accountInfo = SpringShared.GetPlayerInfo(playerID) if accountInfo and accountInfo.accountid then accountID = tonumber(accountInfo.accountid) end if not spec then - local units = Spring.GetTeamUnits(teamID) + local units = SpringShared.GetTeamUnits(teamID) for k = 1, #units do local unitID = units[k] - local unitDefID = Spring.GetUnitDefID(unitID) - local unitPosX, unitPosY, unitPosZ = Spring.GetUnitPosition(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) + local unitPosX, unitPosY, unitPosZ = SpringShared.GetUnitPosition(unitID) if unitDefCanWearHats[unitDefID] then if MatchPlayer(halloween, playerName, accountID) and UnitDefNames["cor_hat_hw"] then local hatDefID = UnitDefNames["cor_hat_hw"].id - local unitID = Spring.CreateUnit(hatDefID, unitPosX, unitPosY, unitPosZ, 0, teamID) + local unitID = SpringSynced.CreateUnit(hatDefID, unitPosX, unitPosY, unitPosZ, 0, teamID) gadget:UnitGiven(unitID, hatDefID, teamID) end if MatchPlayer(legchamps, playerName, accountID) and UnitDefNames["cor_hat_legfn"] then local hatDefID = UnitDefNames["cor_hat_legfn"].id - local unitID = Spring.CreateUnit(hatDefID, unitPosX, unitPosY, unitPosZ, 0, teamID) + local unitID = SpringSynced.CreateUnit(hatDefID, unitPosX, unitPosY, unitPosZ, 0, teamID) gadget:UnitGiven(unitID, hatDefID, teamID) end if MatchPlayer(champion, playerName, accountID) and UnitDefNames["cor_hat_fightnight"] then local hatDefID = UnitDefNames["cor_hat_fightnight"].id - local unitID = Spring.CreateUnit(hatDefID, unitPosX, unitPosY, unitPosZ, 0, teamID) + local unitID = SpringSynced.CreateUnit(hatDefID, unitPosX, unitPosY, unitPosZ, 0, teamID) gadget:UnitGiven(unitID, hatDefID, teamID) end if MatchPlayer(vikings, playerName, accountID) and UnitDefNames["cor_hat_viking"] then local hatDefID = UnitDefNames["cor_hat_viking"].id - local unitID = Spring.CreateUnit(hatDefID, unitPosX, unitPosY, unitPosZ, 0, teamID) + local unitID = SpringSynced.CreateUnit(hatDefID, unitPosX, unitPosY, unitPosZ, 0, teamID) gadget:UnitGiven(unitID, hatDefID, teamID) end if (uniques[playerName] ~= nil) and (UnitDefNames["cor_hat_" .. uniques[playerName]] ~= nil) then local hatDefID = UnitDefNames["cor_hat_" .. uniques[playerName]].id - local unitID = Spring.CreateUnit(hatDefID, unitPosX, unitPosY, unitPosZ, 0, teamID) + local unitID = SpringSynced.CreateUnit(hatDefID, unitPosX, unitPosY, unitPosZ, 0, teamID) gadget:UnitGiven(unitID, hatDefID, teamID) end if string.sub(UnitDefs[unitDefID].name, 1, 3) == "arm" then - local scriptEnv = Spring.UnitScript.GetScriptEnv(unitID) + local scriptEnv = SpringSynced.UnitScript.GetScriptEnv(unitID) if scriptEnv then if MatchPlayer(kings, playerName, accountID) and scriptEnv["ShowCrown"] then - Spring.UnitScript.CallAsUnit(unitID, scriptEnv["ShowCrown"], true) + SpringSynced.UnitScript.CallAsUnit(unitID, scriptEnv["ShowCrown"], true) end if MatchPlayer(goldMedals, playerName, accountID) and scriptEnv["ShowMedalGold"] then - Spring.UnitScript.CallAsUnit(unitID, scriptEnv["ShowMedalGold"], true) + SpringSynced.UnitScript.CallAsUnit(unitID, scriptEnv["ShowMedalGold"], true) end if MatchPlayer(silverMedals, playerName, accountID) and scriptEnv["ShowMedalSilver"] then - Spring.UnitScript.CallAsUnit(unitID, scriptEnv["ShowMedalSilver"], true) + SpringSynced.UnitScript.CallAsUnit(unitID, scriptEnv["ShowMedalSilver"], true) end if MatchPlayer(bronzeMedals, playerName, accountID) and scriptEnv["ShowMedalBronze"] then - Spring.UnitScript.CallAsUnit(unitID, scriptEnv["ShowMedalBronze"], true) + SpringSynced.UnitScript.CallAsUnit(unitID, scriptEnv["ShowMedalBronze"], true) end end else - if MatchPlayer(kings, playerName, accountID) and Spring.GetCOBScriptID(unitID, "ShowCrown") then - Spring.CallCOBScript(unitID, "ShowCrown", 0) + if MatchPlayer(kings, playerName, accountID) and SpringSynced.GetCOBScriptID(unitID, "ShowCrown") then + SpringSynced.CallCOBScript(unitID, "ShowCrown", 0) end - if MatchPlayer(goldMedals, playerName, accountID) and Spring.GetCOBScriptID(unitID, "ShowMedalGold") then - Spring.CallCOBScript(unitID, "ShowMedalGold", 0) + if MatchPlayer(goldMedals, playerName, accountID) and SpringSynced.GetCOBScriptID(unitID, "ShowMedalGold") then + SpringSynced.CallCOBScript(unitID, "ShowMedalGold", 0) end - if MatchPlayer(silverMedals, playerName, accountID) and Spring.GetCOBScriptID(unitID, "ShowMedalSilver") then - Spring.CallCOBScript(unitID, "ShowMedalSilver", 0) + if MatchPlayer(silverMedals, playerName, accountID) and SpringSynced.GetCOBScriptID(unitID, "ShowMedalSilver") then + SpringSynced.CallCOBScript(unitID, "ShowMedalSilver", 0) end - if MatchPlayer(bronzeMedals, playerName, accountID) and Spring.GetCOBScriptID(unitID, "ShowMedalBronze") then - Spring.CallCOBScript(unitID, "ShowMedalBronze", 0) + if MatchPlayer(bronzeMedals, playerName, accountID) and SpringSynced.GetCOBScriptID(unitID, "ShowMedalBronze") then + SpringSynced.CallCOBScript(unitID, "ShowMedalBronze", 0) end end end @@ -234,10 +234,10 @@ function gadget:GameFrame(gf) -- periodically update hat health (damage gets applied instantly at gadget:UnitDamaged anyway) if gf % 61 == 1 then for unitID, hatUnitID in pairs(unitsWearingHats) do - local health, maxHealth = Spring.GetUnitHealth(unitID) - local hatHealth, hatMaxHealth = Spring.GetUnitHealth(hatUnitID) + local health, maxHealth = SpringShared.GetUnitHealth(unitID) + local hatHealth, hatMaxHealth = SpringShared.GetUnitHealth(hatUnitID) if hatMaxHealth then - Spring.SetUnitHealth(hatUnitID, (health / maxHealth) * hatMaxHealth) + SpringSynced.SetUnitHealth(hatUnitID, (health / maxHealth) * hatMaxHealth) else unitsWearingHats[hatUnitID] = nil end @@ -257,71 +257,71 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) if unitDefHat[unitDefID] then if DEBUG then - Spring.Echo("hat created", unitID, unitDefID, unitTeam, builderID) + SpringShared.Echo("hat created", unitID, unitDefID, unitTeam, builderID) end Hats[unitID] = -1 - Spring.SetUnitNeutral(unitID, true) - Spring.SetUnitBlocking(unitID, false, false, false, false) -- non blocking while dying - Spring.SetUnitNoMinimap(unitID, true) + SpringSynced.SetUnitNeutral(unitID, true) + SpringSynced.SetUnitBlocking(unitID, false, false, false, false) -- non blocking while dying + SpringUnsynced.SetUnitNoMinimap(unitID, true) end end function gadget:UnitDestroyed(unitID, unitDefID, teamID, attackerID, attackerDefID, attackerTeamID) if Hats[unitID] ~= nil then if DEBUG then - Spring.Echo("A hat was destroyed", unitID, unitDefID, teamID, attackerID, attackerDefID, attackerTeamID) + SpringShared.Echo("A hat was destroyed", unitID, unitDefID, teamID, attackerID, attackerDefID, attackerTeamID) end Hats[unitID] = nil end if unitsWearingHats[unitID] ~= nil then local hatID = unitsWearingHats[unitID] if DEBUG then - Spring.Echo("A hat wearing unit was destroyed, freeing hat", unitID, unitDefID, teamID, attackerID, attackerDefID, attackerTeamID) + SpringShared.Echo("A hat wearing unit was destroyed, freeing hat", unitID, unitDefID, teamID, attackerID, attackerDefID, attackerTeamID) end - Spring.UnitDetachFromAir(hatID) - Spring.UnitDetach(hatID) + SpringSynced.UnitDetachFromAir(hatID) + SpringSynced.UnitDetach(hatID) unitsWearingHats[unitID] = nil Hats[hatID] = -1 - Spring.SetUnitNoSelect(hatID, false) - Spring.TransferUnit(hatID, Spring.GetGaiaTeamID()) -- ( number unitID, numer newTeamID [, boolean given = true ] ) -> nil if given=false, the unit is captured - local px, py, pz = Spring.GetUnitPosition(unitID) - Spring.SetUnitPosition(hatID, px + 32, pz + 32) + SpringUnsynced.SetUnitNoSelect(hatID, false) + SpringSynced.TransferUnit(hatID, SpringShared.GetGaiaTeamID()) -- ( number unitID, numer newTeamID [, boolean given = true ] ) -> nil if given=false, the unit is captured + local px, py, pz = SpringShared.GetUnitPosition(unitID) + SpringSynced.SetUnitPosition(hatID, px + 32, pz + 32) end end function gadget:UnitGiven(unitID, unitDefID, unitTeam) if unitsWearingHats[unitID] then if DEBUG then - Spring.Echo("A hat wearing unit was given, destroying hat", unitID, unitDefID, unitTeam, unitsWearingHats[unitID]) + SpringShared.Echo("A hat wearing unit was given, destroying hat", unitID, unitDefID, unitTeam, unitsWearingHats[unitID]) end - Spring.DestroyUnit(unitsWearingHats[unitID]) + SpringSynced.DestroyUnit(unitsWearingHats[unitID]) unitsWearingHats[unitID] = nil end if Hats[unitID] then local hatID = unitID - if unitTeam == Spring.GetGaiaTeamID() then + if unitTeam == SpringShared.GetGaiaTeamID() then if DEBUG then - Spring.Echo("A hat was given back to gaia", hatID, unitDefID, unitTeam, Spring.GetGaiaTeamID()) + SpringShared.Echo("A hat was given back to gaia", hatID, unitDefID, unitTeam, SpringShared.GetGaiaTeamID()) end return end if DEBUG then - Spring.Echo("A hat was given, finding a wearer", hatID, unitDefID, unitTeam) + SpringShared.Echo("A hat was given, finding a wearer", hatID, unitDefID, unitTeam) end -- find nearest commander and attach hat onto him? - local hx, hy, hz = Spring.GetUnitPosition(hatID) + local hx, hy, hz = SpringShared.GetUnitPosition(hatID) if hx then - for ct, nearunitID in pairs(Spring.GetUnitsInCylinder(hx, hz, 200, unitTeam)) do - local neardefID = Spring.GetUnitDefID(nearunitID) + for ct, nearunitID in pairs(SpringShared.GetUnitsInCylinder(hx, hz, 200, unitTeam)) do + local neardefID = SpringShared.GetUnitDefID(nearunitID) if unitDefCanWearHats[neardefID] then if DEBUG then - Spring.Echo("Found a wearer", nearunitID, hatID, unitDefID, unitTeam) + SpringShared.Echo("Found a wearer", nearunitID, hatID, unitDefID, unitTeam) end - local pieceMap = Spring.GetUnitPieceMap(nearunitID) + local pieceMap = SpringShared.GetUnitPieceMap(nearunitID) local hatPoint = nil for pieceName, pieceNum in pairs(pieceMap) do if pieceName:find("hatpoint", nil, true) then @@ -331,13 +331,13 @@ function gadget:UnitGiven(unitID, unitDefID, unitTeam) end if DEBUG then - Spring.Echo("Found a point", nearunitID, hatPoint) + SpringShared.Echo("Found a point", nearunitID, hatPoint) end --Spring.MoveCtrl.Enable(unitID) - Spring.UnitAttach(nearunitID, hatID, hatPoint) - Spring.SetUnitNoDraw(hatID, false) - Spring.SetUnitNoSelect(hatID, true) + SpringSynced.UnitAttach(nearunitID, hatID, hatPoint) + SpringUnsynced.SetUnitNoDraw(hatID, false) + SpringUnsynced.SetUnitNoSelect(hatID, true) --Spring.MoveCtrl.Disable(unitID) --Spring.SetUnitLoadingTransport(unitID, nearunitID) unitsWearingHats[nearunitID] = hatID @@ -347,9 +347,9 @@ function gadget:UnitGiven(unitID, unitDefID, unitTeam) end end if DEBUG then - Spring.Echo("Hat was given, but found noone to put it onto, destroying", hatID) + SpringShared.Echo("Hat was given, but found noone to put it onto, destroying", hatID) end - Spring.DestroyUnit(hatID) + SpringSynced.DestroyUnit(hatID) end end @@ -364,10 +364,10 @@ end -- also damage the hat function gadget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer) if unitsWearingHats[unitID] then - local health, maxHealth = Spring.GetUnitHealth(unitID) - local hatHealth, hatMaxHealth = Spring.GetUnitHealth(unitsWearingHats[unitID]) + local health, maxHealth = SpringShared.GetUnitHealth(unitID) + local hatHealth, hatMaxHealth = SpringShared.GetUnitHealth(unitsWearingHats[unitID]) if hatHealth then - Spring.SetUnitHealth(unitsWearingHats[unitID], (health / maxHealth) * hatMaxHealth) + SpringSynced.SetUnitHealth(unitsWearingHats[unitID], (health / maxHealth) * hatMaxHealth) end end end @@ -375,12 +375,12 @@ end -- also cloak hat function gadget:UnitCloaked(unitID, unitDefID, unitTeam) if unitsWearingHats[unitID] then - Spring.SetUnitCloak(unitsWearingHats[unitID], 1) + SpringSynced.SetUnitCloak(unitsWearingHats[unitID], 1) end end function gadget:UnitDecloaked(unitID, unitDefID, unitTeam) if unitsWearingHats[unitID] then - Spring.SetUnitCloak(unitsWearingHats[unitID], 0) + SpringSynced.SetUnitCloak(unitsWearingHats[unitID], 0) end end diff --git a/luarules/gadgets/unit_healthbars_widget_forwarding.lua b/luarules/gadgets/unit_healthbars_widget_forwarding.lua index 9654299bf99..2d7450ddfec 100644 --- a/luarules/gadgets/unit_healthbars_widget_forwarding.lua +++ b/luarules/gadgets/unit_healthbars_widget_forwarding.lua @@ -15,8 +15,8 @@ end if gadgetHandler:IsSyncedCode() then local SendToUnsynced = SendToUnsynced - local spGetGameFrame = Spring.GetGameFrame - local spGetUnitWeaponState = Spring.GetUnitWeaponState + local spGetGameFrame = SpringShared.GetGameFrame + local spGetUnitWeaponState = SpringShared.GetUnitWeaponState local forwardedFeatureIDs = {} -- so we only forward the start event once local forwardedCaptureUnitIDs = {} @@ -103,23 +103,23 @@ if gadgetHandler:IsSyncedCode() then else local glSetFeatureBufferUniforms = gl.SetFeatureBufferUniforms - local GetFeatureResources = Spring.GetFeatureResources - local GetFeaturePosition = Spring.GetFeaturePosition - local IsPosInLos = Spring.IsPosInLos + local GetFeatureResources = SpringShared.GetFeatureResources + local GetFeaturePosition = SpringShared.GetFeaturePosition + local IsPosInLos = SpringShared.IsPosInLos local rezreclaim = { 0.0, 1.0 } -- this is just a small table cache, so we dont allocate a new table for every update local forwardedFeatureIDsResurrect = {} -- so we only forward the start event once local forwardedFeatureIDsReclaim = {} -- so we only forward the start event once local myTeamID = Spring.GetMyTeamID() local myAllyTeamID = Spring.GetMyAllyTeamID() - local _, fullview = Spring.GetSpectatingState() - local IsUnitInLos = Spring.IsUnitInLos - local GetFeatureHealth = Spring.GetFeatureHealth + local _, fullview = SpringUnsynced.GetSpectatingState() + local IsUnitInLos = SpringShared.IsUnitInLos + local GetFeatureHealth = SpringShared.GetFeatureHealth local headless = false function gadget:PlayerChanged(playerID) myTeamID = Spring.GetMyTeamID() myAllyTeamID = Spring.GetMyAllyTeamID() - _, fullview = Spring.GetSpectatingState() + _, fullview = SpringUnsynced.GetSpectatingState() end function featureReclaimFrame(cmd, featureID, step) @@ -165,7 +165,7 @@ else function projetileCreatedReload(cmd, projectileID, ownerID, weaponID) --Spring.Echo("unsynced projetileCreatedReload", projectileID, ownerID, weaponID, fullview, Spring.GetUnitTeam(ownerID)) - if fullview or Spring.GetUnitTeam(ownerID) == myTeamID then + if fullview or SpringShared.GetUnitTeam(ownerID) == myTeamID then if Script.LuaUI("ProjectileCreatedReloadHB") then --Spring.Echo("G:ProjectileCreatedReloadHB", projectileID, ownerID, weaponID) Script.LuaUI.ProjectileCreatedReloadHB(projectileID, ownerID, weaponID) @@ -199,7 +199,7 @@ else end function gadget:Initialize() - headless = Spring.GetConfigInt("Headless", 0) > 0 + headless = SpringUnsynced.GetConfigInt("Headless", 0) > 0 gadgetHandler:AddSyncAction("featureReclaimFrame", featureReclaimFrame) gadgetHandler:AddSyncAction("unitCaptureFrame", unitCaptureFrame) gadgetHandler:AddSyncAction("projetileCreatedReload", projetileCreatedReload) diff --git a/luarules/gadgets/unit_icongenerator.lua b/luarules/gadgets/unit_icongenerator.lua index d69669ba183..40b565eebf5 100644 --- a/luarules/gadgets/unit_icongenerator.lua +++ b/luarules/gadgets/unit_icongenerator.lua @@ -50,7 +50,7 @@ if gadgetHandler:IsSyncedCode() then local new = {} for i = 1, #units do if (units[i].frame + 5) == n then - Spring.DestroyUnit(units[i].id, false, true) + SpringSynced.DestroyUnit(units[i].id, false, true) elseif units[i].frame == n then SendToUnsynced("buildicon_unitcreated", units[i].id, units[i].defname) new[#new + 1] = units[i] @@ -78,53 +78,53 @@ if gadgetHandler:IsSyncedCode() then if nextUnitX >= Game.mapSizeX then nextUnitX, nextUnitZ = 100, nextUnitZ + 200 end - local y = Spring.GetGroundHeight(0, 0) - Spring.LevelHeightMap(x - 50, z - 50, x + 50, z + 50, y) + local y = SpringShared.GetGroundHeight(0, 0) + SpringSynced.LevelHeightMap(x - 50, z - 50, x + 50, z + 50, y) - local uid = Spring.CreateUnit(cunit.defname, x, y, z, "south", 0) -- FIXME needs to be a non-gaia team if gaia doesn't have its unitlimit assigned + local uid = SpringSynced.CreateUnit(cunit.defname, x, y, z, "south", 0) -- FIXME needs to be a non-gaia team if gaia doesn't have its unitlimit assigned if uid then units[#units + 1] = { id = uid, defname = cunit.defname, frame = n + cunit.time } curTeam = cunit.team - Spring.SetUnitNeutral(uid, true) - Spring.GiveOrderToUnit(uid, CMD.FIRE_STATE, { 0 }, 0) - Spring.GiveOrderToUnit(uid, CMD.STOP, {}, 0) + SpringSynced.SetUnitNeutral(uid, true) + SpringSynced.GiveOrderToUnit(uid, CMD.FIRE_STATE, { 0 }, 0) + SpringSynced.GiveOrderToUnit(uid, CMD.STOP, {}, 0) - local env = Spring.UnitScript.GetScriptEnv(uid) + local env = SpringSynced.UnitScript.GetScriptEnv(uid) if env then lus = true end if lus then if env.Activate then - Spring.UnitScript.CallAsUnit(uid, env.Activate) + SpringSynced.UnitScript.CallAsUnit(uid, env.Activate) end else - Spring.CallCOBScript(uid, "Activate", 0) + SpringSynced.CallCOBScript(uid, "Activate", 0) end if cunit.move then if lus then if env.StartMoving then - Spring.UnitScript.CallAsUnit(uid, env.StartMoving) + SpringSynced.UnitScript.CallAsUnit(uid, env.StartMoving) end else - Spring.CallCOBScript(uid, "StartMoving", 0) + SpringSynced.CallCOBScript(uid, "StartMoving", 0) end end if cunit.attack and not lus then local angle = (cunit.shotAngle / 180) * 32768 - Spring.CallCOBScript(uid, "AimPrimary", 0, Spring.GetHeadingFromVector(0, 1), angle) - Spring.CallCOBScript(uid, "AimWeapon1", 0, Spring.GetHeadingFromVector(0, 1), angle) + SpringSynced.CallCOBScript(uid, "AimPrimary", 0, SpringShared.GetHeadingFromVector(0, 1), angle) + SpringSynced.CallCOBScript(uid, "AimWeapon1", 0, SpringShared.GetHeadingFromVector(0, 1), angle) - Spring.CallCOBScript(uid, "AimSecondary", 0, Spring.GetHeadingFromVector(0, 1), angle) - Spring.CallCOBScript(uid, "AimWeapon2", 0, Spring.GetHeadingFromVector(0, 1), angle) + SpringSynced.CallCOBScript(uid, "AimSecondary", 0, SpringShared.GetHeadingFromVector(0, 1), angle) + SpringSynced.CallCOBScript(uid, "AimWeapon2", 0, SpringShared.GetHeadingFromVector(0, 1), angle) - Spring.CallCOBScript(uid, "AimTertiary", 0, Spring.GetHeadingFromVector(0, 1), angle) - Spring.CallCOBScript(uid, "AimWeapon3", 0, Spring.GetHeadingFromVector(0, 1), angle) + SpringSynced.CallCOBScript(uid, "AimTertiary", 0, SpringShared.GetHeadingFromVector(0, 1), angle) + SpringSynced.CallCOBScript(uid, "AimWeapon3", 0, SpringShared.GetHeadingFromVector(0, 1), angle) end end @@ -142,8 +142,8 @@ if gadgetHandler:IsSyncedCode() then function gadget:RecvLuaMsg(msg, playerID) if msg:sub(1, 9) == "buildicon" then - if not Spring.IsCheatingEnabled() then - Spring.SendMessageToPlayer(playerID, "Cheating must be enabled") + if not SpringShared.IsCheatingEnabled() then + SpringUnsynced.SendMessageToPlayer(playerID, "Cheating must be enabled") return true end @@ -343,7 +343,7 @@ else }) if not pre_shader then - Spring.Log(gadget:GetInfo().name, LOG.ERROR, gl.GetShaderLog()) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, gl.GetShaderLog()) end post_shader = gl.CreateShader({ @@ -462,7 +462,7 @@ else }) if not post_shader then - Spring.Log(gadget:GetInfo().name, LOG.ERROR, gl.GetShaderLog()) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, gl.GetShaderLog()) end halo_shader = gl.CreateShader({ @@ -526,7 +526,7 @@ else }) if not halo_shader then - Spring.Log(gadget:GetInfo().name, LOG.ERROR, gl.GetShaderLog()) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, gl.GetShaderLog()) end clear_shader = gl.CreateShader({ @@ -540,7 +540,7 @@ else }) if not clear_shader then - Spring.Log(gadget:GetInfo().name, LOG.ERROR, gl.GetShaderLog()) + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, gl.GetShaderLog()) end end @@ -639,7 +639,7 @@ else -------------------------------------------------------------------------------- local function GetUnitDefDims(udid) - local dims = Spring.GetUnitDefDimensions(udid) + local dims = SpringShared.GetUnitDefDimensions(udid) local midx, midy, midz = (dims.maxx + dims.minx) * 0.5, (math.max(0, dims.maxy) + math.max(0, dims.miny)) * 0.5, (dims.maxz + dims.minz) * 0.5 local ax = math.max(math.abs(dims.maxx - midx), math.abs(dims.minx - midx)) local ay = math.max(math.abs(dims.maxy - midy), math.abs(dims.miny - midy)) @@ -906,11 +906,11 @@ else if bottom_ + height_ > renderY or left_ < 0 or bottom_ < 0 or left_ + width_ > renderX then local offX, offY = CheckOutsideBoundings(left_, bottom_, width_, height_, wantedSpace) if offX then - Spring.Echo(i, UnitDefs[udid].name .. ": Boundings outside of the texture", offX, offY) + SpringShared.Echo(i, UnitDefs[udid].name .. ": Boundings outside of the texture", offX, offY) autoConfigs[udid].offset = { autoConfigs[udid].offset[1] + offX, autoConfigs[udid].offset[2] + offY, 0 } return false, left_, bottom_, width_, height_ else - Spring.Echo(i, UnitDefs[udid].name .. ": Render Context too small (you have to increase renderX&renderY)") + SpringShared.Echo(i, UnitDefs[udid].name .. ": Render Context too small (you have to increase renderX&renderY)") end end @@ -1070,7 +1070,7 @@ else end) if not result and not cfg.empty then - Spring.Log(gadget:GetInfo().name, LOG.ERROR, "icongen: " .. UnitDefs[udid].name .. ": give up :<") + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, "icongen: " .. UnitDefs[udid].name .. ": give up :<") end end @@ -1100,7 +1100,7 @@ else local msg = "buildicon " .. UnitDefs[udid].name .. ";" .. ((cfg.attack and "1") or "0") .. ";" .. ((cfg.move and "1") or "0") .. ";" .. factionTeam .. ";" .. cfg.wait .. ";" .. (cfg.shotangle or "0") .. ";" - Spring.SendLuaRulesMsg(msg) + SpringUnsynced.SendLuaRulesMsg(msg) return end @@ -1121,8 +1121,8 @@ else local schemes, resolutions, ratios = {}, {}, {} local function BuildIcon(cmd, line, words, playerID) - if not Spring.IsCheatingEnabled() then - Spring.Echo("Cheating must be enabled") + if not SpringShared.IsCheatingEnabled() then + SpringShared.Echo("Cheating must be enabled") return false end --if (not Spring.GetModUICtrl()) then @@ -1130,12 +1130,12 @@ else -- return false --end if final_tex or #jobs > 0 then - Spring.Echo("Wait until current process is finished") + SpringShared.Echo("Wait until current process is finished") return false end if words[1] and words[1] ~= "all" and not UnitDefNames[words[1]] then - Spring.Echo("No such unit found") + SpringShared.Echo("No such unit found") return false end @@ -1151,7 +1151,7 @@ else AddJob(function() AddUnitJob(UnitDefNames[words[1]].id, words[2], words[3]) end) - Spring.Echo("buildicon: " .. words[1] .. " " .. (words[3] or "")) + SpringShared.Echo("buildicon: " .. words[1] .. " " .. (words[3] or "")) else for udid = #UnitDefs, 1, -1 do AddJob(function() @@ -1168,12 +1168,12 @@ else iconX, iconY = res[1], res[2] outdir = "buildicons/" .. scheme .. "_" .. ratio_name .. "_" .. iconX .. "x" .. iconY - Spring.CreateDir(outdir) + SpringUnsynced.CreateDir(outdir) if words[3] then -- if animation outdir = "buildicons/" .. scheme .. "_" .. ratio_name .. "_" .. iconX .. "x" .. iconY .. "/" .. words[1] - Spring.CreateDir(outdir) + SpringUnsynced.CreateDir(outdir) end LoadScheme() diff --git a/luarules/gadgets/unit_infestor_spawn.lua b/luarules/gadgets/unit_infestor_spawn.lua index c10123b0705..2aad73c7bc7 100644 --- a/luarules/gadgets/unit_infestor_spawn.lua +++ b/luarules/gadgets/unit_infestor_spawn.lua @@ -38,8 +38,8 @@ end function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) if builderID then - if infestor[unitDefID] and infestor[Spring.GetUnitDefID(builderID)] then - Spring.GiveOrderToUnit(unitID, CMD.GUARD, { builderID }, { "shift" }) + if infestor[unitDefID] and infestor[SpringShared.GetUnitDefID(builderID)] then + SpringSynced.GiveOrderToUnit(unitID, CMD.GUARD, { builderID }, { "shift" }) end end end diff --git a/luarules/gadgets/unit_inherit_creation_xp.lua b/luarules/gadgets/unit_inherit_creation_xp.lua index a1e98be233d..b337052a397 100644 --- a/luarules/gadgets/unit_inherit_creation_xp.lua +++ b/luarules/gadgets/unit_inherit_creation_xp.lua @@ -22,10 +22,10 @@ end -- childreninheritxp = "TURRET MOBILEBUILT DRONE BOTCANNON", -- determines what kinds of units linked to parent inherit XP -- parentsinheritxp = "TURRET MOBILEBUILT DRONE BOTCANNON", -- determines what kinds of units linked to the parent will give the parent XP -local spGetUnitExperience = Spring.GetUnitExperience -local spSetUnitExperience = Spring.SetUnitExperience -local spGetUnitRulesParam = Spring.GetUnitRulesParam -local spGetUnitDefID = Spring.GetUnitDefID +local spGetUnitExperience = SpringShared.GetUnitExperience +local spSetUnitExperience = SpringSynced.SetUnitExperience +local spGetUnitRulesParam = SpringShared.GetUnitRulesParam +local spGetUnitDefID = SpringShared.GetUnitDefID local inheritChildrenXP = {} -- stores the value of XP rate to be derived from unitdef local inheritCreationXP = {} -- multiplier of XP to inherit to newly created units, indexed by unitID @@ -183,7 +183,7 @@ end function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam, weaponDefID) - local evoID = Spring.GetUnitRulesParam(unitID, "unit_evolved") + local evoID = SpringShared.GetUnitRulesParam(unitID, "unit_evolved") if evoID then for id, data in pairs(childrenWithParents) do if data.parentunitid == unitID then diff --git a/luarules/gadgets/unit_instant_self_destruct.lua b/luarules/gadgets/unit_instant_self_destruct.lua index da0e90690cf..a884328ca06 100644 --- a/luarules/gadgets/unit_instant_self_destruct.lua +++ b/luarules/gadgets/unit_instant_self_destruct.lua @@ -29,8 +29,8 @@ for i = 1, #UnitDefs do end local CMD_SELFD = CMD.SELFD -local spGetUnitIsStunned = Spring.GetUnitIsStunned -local spDestroyUnit = Spring.DestroyUnit +local spGetUnitIsStunned = SpringShared.GetUnitIsStunned +local spDestroyUnit = SpringSynced.DestroyUnit function gadget:AllowCommand_GetWantedCommand() return { [CMD_SELFD] = true } diff --git a/luarules/gadgets/unit_interceptors.lua b/luarules/gadgets/unit_interceptors.lua index 8509a08ad43..9a844699d98 100644 --- a/luarules/gadgets/unit_interceptors.lua +++ b/luarules/gadgets/unit_interceptors.lua @@ -17,11 +17,11 @@ if not gadgetHandler:IsSyncedCode() then end -- Localize and pre-compute things -local spGetUnitDefID = Spring.GetUnitDefID -local spGetProjectileTarget = Spring.GetProjectileTarget -local spGetUnitPosition = Spring.GetUnitPosition -local spGetFeaturePosition = Spring.GetFeaturePosition -local spGetProjectilePosition = Spring.GetProjectilePosition +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetProjectileTarget = SpringShared.GetProjectileTarget +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spGetProjectilePosition = SpringShared.GetProjectilePosition local unitTargetType = string.byte("u") local featureTargetType = string.byte("f") diff --git a/luarules/gadgets/unit_intergrated_hats.lua b/luarules/gadgets/unit_intergrated_hats.lua index f1b9871efd8..951ca46ab40 100644 --- a/luarules/gadgets/unit_intergrated_hats.lua +++ b/luarules/gadgets/unit_intergrated_hats.lua @@ -93,16 +93,16 @@ function gadget:UnitCreated(unitID, unitDefID, teamID, builderID) -- hide all but the choosen hat local numberOfHats = hatCounts[unitDefID] if numberOfHats then - local unitPieceList = Spring.GetUnitPieceMap(unitID) + local unitPieceList = SpringShared.GetUnitPieceMap(unitID) -- @NOTE: current formula means all units will have a hat local hatRoll = unitCount % numberOfHats + 1 for i = 1, numberOfHats do if i ~= hatRoll then - Spring.SetUnitPieceVisible(unitID, unitPieceList["h" .. i], false) + SpringSynced.SetUnitPieceVisible(unitID, unitPieceList["h" .. i], false) else -- hats should be zeroed so that when on 0,0,0 they are where they should be, otherwise buried in the ground -- (the 16 numbers is a matrix that positions them at 0,0,0, of scale 1,1,1, unrotated (rotation gets baked in, in upspring)) - Spring.SetUnitPieceMatrix(unitID, unitPieceList["h" .. i], { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }) + SpringSynced.SetUnitPieceMatrix(unitID, unitPieceList["h" .. i], { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }) end end end diff --git a/luarules/gadgets/unit_juno_damage.lua b/luarules/gadgets/unit_juno_damage.lua index 123efd612e0..e0415240e1e 100644 --- a/luarules/gadgets/unit_juno_damage.lua +++ b/luarules/gadgets/unit_juno_damage.lua @@ -9,7 +9,7 @@ function gadget:GetInfo() date = "05/2013", license = "GNU GPL, v2 or later", layer = 0, - enabled = not Spring.GetModOptions().junorework, + enabled = not SpringShared.GetModOptions().junorework, } end @@ -138,13 +138,13 @@ if gadgetHandler:IsSyncedCode() then local fadetime = 2 --how long fade in/out effect lasts, in seconds --locals - local SpGetGameSeconds = Spring.GetGameSeconds - local SpGetUnitsInCylinder = Spring.GetUnitsInCylinder - local SpDestroyUnit = Spring.DestroyUnit - local SpGetUnitDefID = Spring.GetUnitDefID - local SpValidUnitID = Spring.ValidUnitID - local SpGetUnitPosition = Spring.GetUnitPosition - local SpSpawnCEG = Spring.SpawnCEG + local SpGetGameSeconds = SpringShared.GetGameSeconds + local SpGetUnitsInCylinder = SpringShared.GetUnitsInCylinder + local SpDestroyUnit = SpringSynced.DestroyUnit + local SpGetUnitDefID = SpringShared.GetUnitDefID + local SpValidUnitID = SpringShared.ValidUnitID + local SpGetUnitPosition = SpringShared.GetUnitPosition + local SpSpawnCEG = SpringSynced.SpawnCEG local Mmin = math.min -- kill appropriate things from initial juno blast -- diff --git a/luarules/gadgets/unit_juno_damage_mini.lua b/luarules/gadgets/unit_juno_damage_mini.lua index 4e16a592367..198f4bc98cc 100644 --- a/luarules/gadgets/unit_juno_damage_mini.lua +++ b/luarules/gadgets/unit_juno_damage_mini.lua @@ -142,11 +142,11 @@ if gadgetHandler:IsSyncedCode() then local fadetime = 2 --how long fade in/out effect lasts, in seconds --locals - local SpGetGameSeconds = Spring.GetGameSeconds - local SpGetUnitsInCylinder = Spring.GetUnitsInCylinder - local SpDestroyUnit = Spring.DestroyUnit - local SpGetUnitDefID = Spring.GetUnitDefID - local SpValidUnitID = Spring.ValidUnitID + local SpGetGameSeconds = SpringShared.GetGameSeconds + local SpGetUnitsInCylinder = SpringShared.GetUnitsInCylinder + local SpDestroyUnit = SpringSynced.DestroyUnit + local SpGetUnitDefID = SpringShared.GetUnitDefID + local SpValidUnitID = SpringShared.ValidUnitID local Mmin = math.min -- kill appropriate things from initial juno blast -- @@ -166,9 +166,9 @@ if gadgetHandler:IsSyncedCode() then function gadget:UnitDamaged(uID, uDefID, uTeam, damage, paralyzer, weaponID, projID, aID, aDefID, aTeam) if junoWeapons[weaponID] and tokillUnits[uDefID] then if uID and SpValidUnitID(uID) then - local px, py, pz = Spring.GetUnitPosition(uID) + local px, py, pz = SpringShared.GetUnitPosition(uID) if px then - Spring.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) + SpringSynced.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) end if aID and SpValidUnitID(aID) then SpDestroyUnit(uID, false, false, aID) @@ -226,12 +226,12 @@ if gadgetHandler:IsSyncedCode() then local unitID = unitIDsBig[i] local unitDefID = SpGetUnitDefID(unitID) if todenyUnits[unitDefID] then - local px, py, pz = Spring.GetUnitPosition(unitID) + local px, py, pz = SpringShared.GetUnitPosition(unitID) local dx = expl.x - px local dz = expl.z - pz if (dx * dx + dz * dz) > (q * (radius - width)) * (q * (radius - width)) then -- linear and not O(n^2) - Spring.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) + SpringSynced.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) SpDestroyUnit(unitID, true, false) end end diff --git a/luarules/gadgets/unit_juno_rework_damage.lua b/luarules/gadgets/unit_juno_rework_damage.lua index 3d6147edc20..581e284f7db 100644 --- a/luarules/gadgets/unit_juno_rework_damage.lua +++ b/luarules/gadgets/unit_juno_rework_damage.lua @@ -9,7 +9,7 @@ function gadget:GetInfo() date = "05/2024", --original 05/2013 license = "GNU GPL, v2 or later", layer = 0, - enabled = Spring.GetModOptions().junorework, + enabled = SpringShared.GetModOptions().junorework, } end @@ -81,7 +81,7 @@ if gadgetHandler:IsSyncedCode() then } - local stunDuration = Spring.GetModOptions().emprework and 32 or 30 + local stunDuration = SpringShared.GetModOptions().emprework and 32 or 30 --hornet todo, might leave this to be decided by EMP settings and just max it out? local toTarpitUnitsNames = { @@ -165,11 +165,11 @@ if gadgetHandler:IsSyncedCode() then local fadetime = 2 --how long fade in/out effect lasts, in seconds --locals - local SpGetGameSeconds = Spring.GetGameSeconds - local SpGetUnitsInCylinder = Spring.GetUnitsInCylinder - local SpDestroyUnit = Spring.DestroyUnit - local SpGetUnitDefID = Spring.GetUnitDefID - local SpValidUnitID = Spring.ValidUnitID + local SpGetGameSeconds = SpringShared.GetGameSeconds + local SpGetUnitsInCylinder = SpringShared.GetUnitsInCylinder + local SpDestroyUnit = SpringSynced.DestroyUnit + local SpGetUnitDefID = SpringShared.GetUnitDefID + local SpValidUnitID = SpringShared.ValidUnitID local Mmin = math.min -- kill appropriate things from initial juno blast -- @@ -209,13 +209,13 @@ if gadgetHandler:IsSyncedCode() then if junoWeapons[weaponID] and toStunUnits[uDefID] and aID ~= 99 and (paralyzer == false) then --needed to stop possible loops if uID and SpValidUnitID(uID) then - local px, py, pz = Spring.GetUnitPosition(uID) + local px, py, pz = SpringShared.GetUnitPosition(uID) if px then - Spring.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) + SpringSynced.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) end - local health, maxHealth, paralyzeDamage, capture, build = Spring.GetUnitHealth(uID) - Spring.AddUnitDamage(uID, maxHealth * 3, stunDuration, 99, weaponID) --no weapon ID, no stun. with weapon ID, infinite loops, even with the 99 exclusion. -1 does not work. + local health, maxHealth, paralyzeDamage, capture, build = SpringShared.GetUnitHealth(uID) + SpringSynced.AddUnitDamage(uID, maxHealth * 3, stunDuration, 99, weaponID) --no weapon ID, no stun. with weapon ID, infinite loops, even with the 99 exclusion. -1 does not work. --aID check removed as -probably- only useful for kill crediting? end @@ -223,9 +223,9 @@ if gadgetHandler:IsSyncedCode() then if junoWeapons[weaponID] and tokillUnits[uDefID] then if uID and SpValidUnitID(uID) then - local px, py, pz = Spring.GetUnitPosition(uID) + local px, py, pz = SpringShared.GetUnitPosition(uID) if px then - Spring.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) + SpringSynced.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) end if aID and SpValidUnitID(aID) then SpDestroyUnit(uID, false, false, aID) @@ -275,7 +275,7 @@ if gadgetHandler:IsSyncedCode() then local curtime = SpGetGameSeconds() - if Spring.GetGameFrame() % 15 == 0 then + if SpringShared.GetGameFrame() % 15 == 0 then for counter, expl in pairs(centers) do if expl.t >= curtime - effectlength then @@ -291,29 +291,29 @@ if gadgetHandler:IsSyncedCode() then local unitID = unitIDsBig[i] local unitDefID = SpGetUnitDefID(unitID) if todenyUnits[unitDefID] then - local px, py, pz = Spring.GetUnitPosition(unitID) + local px, py, pz = SpringShared.GetUnitPosition(unitID) local dx = expl.x - px local dz = expl.z - pz if (dx * dx + dz * dz) > (q * (radius - width)) * (q * (radius - width)) then -- linear and not O(n^2) - Spring.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) + SpringSynced.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) SpDestroyUnit(unitID, true, false) end end if toStunUnits[unitDefID] then - local px, py, pz = Spring.GetUnitPosition(unitID) + local px, py, pz = SpringShared.GetUnitPosition(unitID) local dx = expl.x - px local dz = expl.z - pz --does the cyl search above not already do this...? if (dx * dx + dz * dz) > (q * (radius - width)) * (q * (radius - width)) then -- linear and not O(n^2) - local health, maxHealth, paralyzeDamage, capture, build = Spring.GetUnitHealth(unitID) + local health, maxHealth, paralyzeDamage, capture, build = SpringShared.GetUnitHealth(unitID) --Spring.Echo(paralyzeDamage, maxHealth*1.2) if paralyzeDamage < maxHealth * 1.2 then --try to prevent excessive stun times, also needless restuns - Spring.AddUnitDamage(unitID, maxHealth * 2, 5, 99, WeaponDefNames["corjuno_juno_pulse_ghost"].id) ---...close enough? - Spring.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) + SpringSynced.AddUnitDamage(unitID, maxHealth * 2, 5, 99, WeaponDefNames["corjuno_juno_pulse_ghost"].id) ---...close enough? + SpringSynced.SpawnCEG("juno-damage", px, py + 8, pz, 0, 1, 0) end --SpDestroyUnit(unitID, true, false) diff --git a/luarules/gadgets/unit_kill_count.lua b/luarules/gadgets/unit_kill_count.lua index efc13c2e053..a9f477c9466 100644 --- a/luarules/gadgets/unit_kill_count.lua +++ b/luarules/gadgets/unit_kill_count.lua @@ -14,13 +14,13 @@ end if gadgetHandler:IsSyncedCode() then - local GetUnitRulesParam = Spring.GetUnitRulesParam - local SetUnitRulesParam = Spring.SetUnitRulesParam + local GetUnitRulesParam = SpringShared.GetUnitRulesParam + local SetUnitRulesParam = SpringSynced.SetUnitRulesParam local teamAllyteam = {} - local teamList = Spring.GetTeamList() + local teamList = SpringShared.GetTeamList() for i = 1, #teamList do - teamAllyteam[teamList[i]] = select(6, Spring.GetTeamInfo(teamList[i])) + teamAllyteam[teamList[i]] = select(6, SpringShared.GetTeamInfo(teamList[i])) end -- crashing planes are handled in crashing_aircraft gadget diff --git a/luarules/gadgets/unit_lightning_splash_dmg.lua b/luarules/gadgets/unit_lightning_splash_dmg.lua index 584c4422331..fae9225d339 100644 --- a/luarules/gadgets/unit_lightning_splash_dmg.lua +++ b/luarules/gadgets/unit_lightning_splash_dmg.lua @@ -21,16 +21,16 @@ end local terminal_spark_effect = "genericshellexplosion-splash-lightning" -- can refactor into sparkWeapons if per-unit effects defined by customParams are desired local visual_chain_weapon = WeaponDefNames["lightning_chain"].id -- can refactor into sparkWeapons if per-unit effects defined by customParams are desired -local spGetUnitsInSphere = Spring.GetUnitsInSphere -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spSpawnCEG = Spring.SpawnCEG -local spAddUnitDamage = Spring.AddUnitDamage -local spSpawnProjectile = Spring.SpawnProjectile -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetGroundHeight = Spring.GetGroundHeight -local spGetProjectilePosition = Spring.GetProjectilePosition -local spGetProjectileVelocity = Spring.GetProjectileVelocity +local spGetUnitsInSphere = SpringShared.GetUnitsInSphere +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spSpawnCEG = SpringSynced.SpawnCEG +local spAddUnitDamage = SpringSynced.AddUnitDamage +local spSpawnProjectile = SpringSynced.SpawnProjectile +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetProjectilePosition = SpringShared.GetProjectilePosition +local spGetProjectileVelocity = SpringShared.GetProjectileVelocity local math_random = math.random local math_pi = math.pi diff --git a/luarules/gadgets/unit_mex_upgrade_reclaimer.lua b/luarules/gadgets/unit_mex_upgrade_reclaimer.lua index 512985ed03c..c4d335badcb 100644 --- a/luarules/gadgets/unit_mex_upgrade_reclaimer.lua +++ b/luarules/gadgets/unit_mex_upgrade_reclaimer.lua @@ -46,10 +46,10 @@ end -- get the first mex bellow that isn't itself, stacking more than one should be prevented by yardmaps local function hasMexBeneath(unitID) - local x, _, z = Spring.GetUnitPosition(unitID) - local units = Spring.GetUnitsInCylinder(x, z, 10) + local x, _, z = SpringShared.GetUnitPosition(unitID) + local units = SpringShared.GetUnitsInCylinder(x, z, 10) for k, uID in ipairs(units) do - if isMex[Spring.GetUnitDefID(uID)] and Spring.GetUnitIsDead(uID) == false then + if isMex[SpringShared.GetUnitDefID(uID)] and SpringShared.GetUnitIsDead(uID) == false then if unitID ~= uID then return uID end @@ -63,12 +63,12 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam) if isMex[unitDefID] then local mex = hasMexBeneath(unitID) if mex then - Spring.SetUnitNoSelect(mex, true) + SpringUnsynced.SetUnitNoSelect(mex, true) if transferInstantly then - local mexTeamID = Spring.GetUnitTeam(mex) - if mexTeamID ~= unitTeam and not select(3, Spring.GetTeamInfo(mexTeamID, false)) then - _G.transferredUnits[unitID] = Spring.GetGameFrame() - Spring.TransferUnit(unitID, mexTeamID) + local mexTeamID = SpringShared.GetUnitTeam(mex) + if mexTeamID ~= unitTeam and not select(3, SpringShared.GetTeamInfo(mexTeamID, false)) then + _G.transferredUnits[unitID] = SpringShared.GetGameFrame() + SpringSynced.TransferUnit(unitID, mexTeamID) end end end @@ -80,7 +80,7 @@ function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerD if isMex[unitDefID] then local mex = hasMexBeneath(unitID) if mex then - Spring.SetUnitNoSelect(mex, false) + SpringUnsynced.SetUnitNoSelect(mex, false) end end end @@ -92,12 +92,12 @@ function gadget:UnitFinished(unitID, unitDefID, unitTeam) -- if theres a mex below this one reclaim it, and donate this one to the owner of the previous mex local mex = hasMexBeneath(unitID) if mex then - local mexTeamID = Spring.GetUnitTeam(mex) - Spring.DestroyUnit(mex, false, true) - Spring.AddTeamResource(unitTeam, "metal", isMex[Spring.GetUnitDefID(mex)]) - if not transferInstantly and mexTeamID ~= unitTeam and not select(3, Spring.GetTeamInfo(mexTeamID, false)) then - _G.transferredUnits[unitID] = Spring.GetGameFrame() - Spring.TransferUnit(unitID, mexTeamID) + local mexTeamID = SpringShared.GetUnitTeam(mex) + SpringSynced.DestroyUnit(mex, false, true) + SpringSynced.AddTeamResource(unitTeam, "metal", isMex[SpringShared.GetUnitDefID(mex)]) + if not transferInstantly and mexTeamID ~= unitTeam and not select(3, SpringShared.GetTeamInfo(mexTeamID, false)) then + _G.transferredUnits[unitID] = SpringShared.GetGameFrame() + SpringSynced.TransferUnit(unitID, mexTeamID) end end end diff --git a/luarules/gadgets/unit_minesweeper_detection.lua b/luarules/gadgets/unit_minesweeper_detection.lua index a1a0e682a92..f7c66660b34 100644 --- a/luarules/gadgets/unit_minesweeper_detection.lua +++ b/luarules/gadgets/unit_minesweeper_detection.lua @@ -19,12 +19,12 @@ if not gadgetHandler:IsSyncedCode() then return false end -local spSetUnitLosState = Spring.SetUnitLosState -local spSetUnitLosMask = Spring.SetUnitLosMask -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitTeam = Spring.GetUnitTeam +local spSetUnitLosState = SpringSynced.SetUnitLosState +local spSetUnitLosMask = SpringSynced.SetUnitLosMask +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitTeam = SpringShared.GetUnitTeam local minesweeperRanges = {} local minesweepers = {} @@ -44,8 +44,8 @@ if table.count(minesweeperRanges) == 0 or table.count(mineDefIDs) == 0 then end local teamIDs = {} -for _, teamID in pairs(Spring.GetTeamList()) do - local _, _, _, _, _, allyTeam = Spring.GetTeamInfo(teamID, false) +for _, teamID in pairs(SpringShared.GetTeamList()) do + local _, _, _, _, _, allyTeam = SpringShared.GetTeamInfo(teamID, false) teamIDs[teamID] = allyTeam revealedMines[teamID] = {} minesweepers[teamID] = {} @@ -108,9 +108,9 @@ function gadget:GameFrame(n) end function gadget:Initialize() - for _, unitID in pairs(Spring.GetAllUnits()) do - local unitDefID = Spring.GetUnitDefID(unitID) - local unitTeam = Spring.GetUnitTeam(unitID) + for _, unitID in pairs(SpringShared.GetAllUnits()) do + local unitDefID = SpringShared.GetUnitDefID(unitID) + local unitTeam = SpringShared.GetUnitTeam(unitID) if minesweeperRanges[unitDefID] then minesweepers[unitTeam][unitID] = unitDefID end diff --git a/luarules/gadgets/unit_nanoradarpos.lua b/luarules/gadgets/unit_nanoradarpos.lua index 576fb548d57..3affda0972a 100644 --- a/luarules/gadgets/unit_nanoradarpos.lua +++ b/luarules/gadgets/unit_nanoradarpos.lua @@ -24,7 +24,7 @@ if gadgetHandler:IsSyncedCode() then function gadget:UnitCreated(uid, udid) if isNano[udid] then - Spring.SetUnitPosErrorParams(udid, 0, 0, 0, 0, 0, 0, math.huge) + SpringSynced.SetUnitPosErrorParams(udid, 0, 0, 0, 0, 0, 0, math.huge) end end diff --git a/luarules/gadgets/unit_no_land_damage.lua b/luarules/gadgets/unit_no_land_damage.lua index 1205ddb2bed..0d8cb9f29d0 100644 --- a/luarules/gadgets/unit_no_land_damage.lua +++ b/luarules/gadgets/unit_no_land_damage.lua @@ -19,7 +19,7 @@ if not gadgetHandler:IsSyncedCode() then return false -- silent removal end -local GetUnitBasePosition = Spring.GetUnitBasePosition +local GetUnitBasePosition = SpringShared.GetUnitBasePosition local weapons = { "armair_torpedo", "armseap_weapon" } local NO_LAND_DAMAGE = {} diff --git a/luarules/gadgets/unit_nonblocking_mines.lua b/luarules/gadgets/unit_nonblocking_mines.lua index 03c22c452d3..772c8bd5403 100644 --- a/luarules/gadgets/unit_nonblocking_mines.lua +++ b/luarules/gadgets/unit_nonblocking_mines.lua @@ -26,11 +26,11 @@ for udid, ud in pairs(UnitDefs) do unitSizing[udid] = { ud.xsize * 4 + 8, ud.zsize * 4 + 8 } -- add 8 for the mines size too end -local spSetUnitBlocking = Spring.SetUnitBlocking +local spSetUnitBlocking = SpringSynced.SetUnitBlocking function gadget:UnitCreated(uID, uDefID, uTeam) if isMine[uDefID] then - local x, _, z = Spring.GetUnitPosition(uID) + local x, _, z = SpringShared.GetUnitPosition(uID) mines[uID] = { x, z } spSetUnitBlocking(uID, false, false) end diff --git a/luarules/gadgets/unit_objectify.lua b/luarules/gadgets/unit_objectify.lua index 544e6285954..a3f8e1bb076 100644 --- a/luarules/gadgets/unit_objectify.lua +++ b/luarules/gadgets/unit_objectify.lua @@ -20,12 +20,12 @@ end ]] -- -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetUnitArmored = Spring.GetUnitArmored -local spAreTeamsAllied = Spring.AreTeamsAllied -local spGetSelectedUnitsCounts = Spring.GetSelectedUnitsCounts +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetUnitArmored = SpringShared.GetUnitArmored +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spGetSelectedUnitsCounts = SpringUnsynced.GetSelectedUnitsCounts local CMD_ATTACK = CMD.ATTACK local CMD_MOVE = CMD.MOVE @@ -85,36 +85,36 @@ if gadgetHandler:IsSyncedCode() then function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD.ATTACK) gadgetHandler:RegisterAllowCommand(CMD.BUILD) - for _, unitID in pairs(Spring.GetAllUnits()) do + for _, unitID in pairs(SpringShared.GetAllUnits()) do gadget:UnitCreated(unitID, spGetUnitDefID(unitID)) end end local function objectifyUnit(unitID) - Spring.SetUnitNeutral(unitID, true) - Spring.SetUnitStealth(unitID, true) - Spring.SetUnitSonarStealth(unitID, true) - Spring.SetUnitBlocking(unitID, true, true, true, true, true, true, false) -- set as crushable + SpringSynced.SetUnitNeutral(unitID, true) + SpringSynced.SetUnitStealth(unitID, true) + SpringSynced.SetUnitSonarStealth(unitID, true) + SpringSynced.SetUnitBlocking(unitID, true, true, true, true, true, true, false) -- set as crushable --for weaponID, _ in pairs(UnitDefs[spGetUnitDefID(unitID)].weapons) do -- Spring.UnitWeaponHoldFire(unitID, weaponID) --end end local function decorationUnit(unitID) - Spring.SetUnitNeutral(unitID, true) - Spring.SetUnitStealth(unitID, true) - Spring.SetUnitSonarStealth(unitID, true) - Spring.SetUnitBlocking(unitID, true, true, false, false, true, false, false) + SpringSynced.SetUnitNeutral(unitID, true) + SpringSynced.SetUnitStealth(unitID, true) + SpringSynced.SetUnitSonarStealth(unitID, true) + SpringSynced.SetUnitBlocking(unitID, true, true, false, false, true, false, false) for weaponID, _ in pairs(UnitDefs[spGetUnitDefID(unitID)].weapons) do - Spring.UnitWeaponHoldFire(unitID, weaponID) + SpringSynced.UnitWeaponHoldFire(unitID, weaponID) end - Spring.SetUnitNoSelect(unitID, true) - Spring.SetUnitNoMinimap(unitID, true) - Spring.SetUnitIconDraw(unitID, false) - Spring.SetUnitSensorRadius(unitID, "los", 0) - Spring.SetUnitSensorRadius(unitID, "airLos", 0) - Spring.SetUnitSensorRadius(unitID, "radar", 0) - Spring.SetUnitSensorRadius(unitID, "sonar", 0) + SpringUnsynced.SetUnitNoSelect(unitID, true) + SpringUnsynced.SetUnitNoMinimap(unitID, true) + SpringUnsynced.SetUnitIconDraw(unitID, false) + SpringSynced.SetUnitSensorRadius(unitID, "los", 0) + SpringSynced.SetUnitSensorRadius(unitID, "airLos", 0) + SpringSynced.SetUnitSensorRadius(unitID, "radar", 0) + SpringSynced.SetUnitSensorRadius(unitID, "sonar", 0) end function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam, weaponDefID) @@ -147,7 +147,7 @@ if gadgetHandler:IsSyncedCode() then if isDecoration[unitDefID] then return 0, 0 elseif isObject[unitDefID] and not paralyzer then - local _, maxHealth, _, _, buildProgress = Spring.GetUnitHealth(unitID) + local _, maxHealth, _, _, buildProgress = SpringShared.GetUnitHealth(unitID) if buildProgress and maxHealth and buildProgress < 1 then return (damage / 100) * maxHealth, nil end @@ -170,11 +170,11 @@ if gadgetHandler:IsSyncedCode() then elseif cmdID < 0 and numDecorations > 0 then if cmdParams[3] and isBuilder[unitDefID] then local udefid = math.abs(cmdID) - local units = Spring.GetUnitsInBox(cmdParams[1] - unitSize[udefid][1], cmdParams[2] - 200, cmdParams[3] - unitSize[udefid][2], cmdParams[1] + unitSize[udefid][1], cmdParams[2] + 50, cmdParams[3] + unitSize[udefid][2]) + local units = SpringShared.GetUnitsInBox(cmdParams[1] - unitSize[udefid][1], cmdParams[2] - 200, cmdParams[3] - unitSize[udefid][2], cmdParams[1] + unitSize[udefid][1], cmdParams[2] + 50, cmdParams[3] + unitSize[udefid][2]) for i = 1, #units do if isDecoration[spGetUnitDefID(units[i])] then - if Spring.GetUnitIsDead(units[i]) == false then - Spring.DestroyUnit(units[i], false, true) + if SpringShared.GetUnitIsDead(units[i]) == false then + SpringSynced.DestroyUnit(units[i], false, true) end end end @@ -187,10 +187,10 @@ if gadgetHandler:IsSyncedCode() then else -- UNSYNCED local myAllyTeam = Spring.GetMyAllyTeamID() - local spectating = Spring.GetSpectatingState() + local spectating = SpringUnsynced.GetSpectatingState() function gadget:PlayerChanged(playerID) myAllyTeam = Spring.GetMyAllyTeamID() - spectating = Spring.GetSpectatingState() + spectating = SpringUnsynced.GetSpectatingState() end -- "predicate" tables are checked in their index order diff --git a/luarules/gadgets/unit_onlytargetcategory.lua b/luarules/gadgets/unit_onlytargetcategory.lua index 25a567cbadb..a67c7b7bfda 100644 --- a/luarules/gadgets/unit_onlytargetcategory.lua +++ b/luarules/gadgets/unit_onlytargetcategory.lua @@ -51,7 +51,7 @@ end function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions, cmdTag, playerID, fromSynced, fromLua) -- accepts: CMD.ATTACK - if cmdParams[2] == nil and unitOnlyTargetsCategory[unitDefID] and type(cmdParams[1]) == "number" and not (unitCategories[Spring.GetUnitDefID(cmdParams[1])] and unitCategories[Spring.GetUnitDefID(cmdParams[1])][unitOnlyTargetsCategory[unitDefID]]) then + if cmdParams[2] == nil and unitOnlyTargetsCategory[unitDefID] and type(cmdParams[1]) == "number" and not (unitCategories[SpringShared.GetUnitDefID(cmdParams[1])] and unitCategories[SpringShared.GetUnitDefID(cmdParams[1])][unitOnlyTargetsCategory[unitDefID]]) then return false else if cmdParams[2] and unitDontAttackGround[unitDefID] then diff --git a/luarules/gadgets/unit_onlytargetempable.lua b/luarules/gadgets/unit_onlytargetempable.lua index d88d1303cde..e4c51031274 100644 --- a/luarules/gadgets/unit_onlytargetempable.lua +++ b/luarules/gadgets/unit_onlytargetempable.lua @@ -37,11 +37,11 @@ end function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions, cmdTag, playerID, fromSynced, fromLua) -- accepts: CMD.ATTACK - if empUnits[unitDefID] and cmdParams[2] == nil and type(cmdParams[1]) == "number" and UnitDefs[Spring.GetUnitDefID(cmdParams[1])] ~= nil then - if unEmpableUnits[Spring.GetUnitDefID(cmdParams[1])] then -- and UnitDefs[Spring.GetUnitDefID(cmdParams[1])].customParams.paralyzemultiplier == '0' then + if empUnits[unitDefID] and cmdParams[2] == nil and type(cmdParams[1]) == "number" and UnitDefs[SpringShared.GetUnitDefID(cmdParams[1])] ~= nil then + if unEmpableUnits[SpringShared.GetUnitDefID(cmdParams[1])] then -- and UnitDefs[Spring.GetUnitDefID(cmdParams[1])].customParams.paralyzemultiplier == '0' then return false else - local _, _, _, _, y = Spring.GetUnitPosition(cmdParams[1], true) + local _, _, _, _, y = SpringShared.GetUnitPosition(cmdParams[1], true) if y and y >= 0 then return true else diff --git a/luarules/gadgets/unit_paralyze_damage_limit.lua b/luarules/gadgets/unit_paralyze_damage_limit.lua index 0605178227f..da26c302b6f 100644 --- a/luarules/gadgets/unit_paralyze_damage_limit.lua +++ b/luarules/gadgets/unit_paralyze_damage_limit.lua @@ -18,7 +18,7 @@ if not gadgetHandler:IsSyncedCode() then return false end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() local maxTime = modOptions.emprework == true and 10 or 20 --- bug fixed @@ -149,8 +149,8 @@ for udid, ud in pairs(UnitDefs) do end -local spGetUnitHealth = Spring.GetUnitHealth -local spSetUnitHealth = Spring.SetUnitHealth +local spGetUnitHealth = SpringShared.GetUnitHealth +local spSetUnitHealth = SpringSynced.SetUnitHealth local math_min = math.min local math_max = math.max diff --git a/luarules/gadgets/unit_paralyze_damage_multiplier.lua b/luarules/gadgets/unit_paralyze_damage_multiplier.lua index 28de1d7e238..30d3f457f59 100644 --- a/luarules/gadgets/unit_paralyze_damage_multiplier.lua +++ b/luarules/gadgets/unit_paralyze_damage_multiplier.lua @@ -27,7 +27,7 @@ function gadget:UnitPreDamaged(uID, uDefID, uTeam, damage, paralyzer, weaponID, -- apply customParams paralyse multiplier local paralyzeMultiplier = paralyzeMultipliers[uDefID] - if Spring.GetModOptions().emprework == true then + if SpringShared.GetModOptions().emprework == true then if paralyzeMultiplier == 1 then --paralyzeMultiplier = 0.6 --a new default EMP resistance for everything diff --git a/luarules/gadgets/unit_paralyze_on_off.lua b/luarules/gadgets/unit_paralyze_on_off.lua index 9977e8da04e..6487b643160 100644 --- a/luarules/gadgets/unit_paralyze_on_off.lua +++ b/luarules/gadgets/unit_paralyze_on_off.lua @@ -28,7 +28,7 @@ function gadget:UnitPreDamaged(uID, uDefID, uTeam, damage, paralyzer, weaponID, if paralyzer then --check if paralyzer if off_on_stun[uDefID] == "true" then --check if should be turned off on stun -- check to see if this hit will stun - local health, maxHealth, paralyzeDamage = Spring.GetUnitHealth(uID) + local health, maxHealth, paralyzeDamage = SpringShared.GetUnitHealth(uID) if paralyzeDamage + damage > maxHealth then -- turn off unit if it will stun Spring.SetUnitCOBValue(uID, COB.ACTIVATION, 0) diff --git a/luarules/gadgets/unit_playable_raptor_manager.lua b/luarules/gadgets/unit_playable_raptor_manager.lua index 96a45fd05f0..412e90058d2 100644 --- a/luarules/gadgets/unit_playable_raptor_manager.lua +++ b/luarules/gadgets/unit_playable_raptor_manager.lua @@ -1,4 +1,4 @@ -local modoptions = Spring.GetModOptions() +local modoptions = SpringShared.GetModOptions() if modoptions.playableraptors ~= true and modoptions.forceallunits ~= true then return false end @@ -30,10 +30,10 @@ if gadgetHandler:IsSyncedCode() then return end - local builderDefID = Spring.GetUnitDefID(builderID) + local builderDefID = SpringShared.GetUnitDefID(builderID) if foundling[builderDefID] then - Spring.SetUnitHealth(unitID, { health = 2, build = 1 }) - Spring.DestroyUnit(builderID, false, true) + SpringSynced.SetUnitHealth(unitID, { health = 2, build = 1 }) + SpringSynced.DestroyUnit(builderID, false, true) end end diff --git a/luarules/gadgets/unit_preaim.lua b/luarules/gadgets/unit_preaim.lua index 006f61d9a2d..69a32b3e223 100644 --- a/luarules/gadgets/unit_preaim.lua +++ b/luarules/gadgets/unit_preaim.lua @@ -16,7 +16,7 @@ if not gadgetHandler:IsSyncedCode() then return end -local spSetUnitWeaponState = Spring.SetUnitWeaponState +local spSetUnitWeaponState = SpringSynced.SetUnitWeaponState --use weaponDef.customparams.exclude_preaim = true to exclude units from being able to pre-aim at targets almost within firing range. --this is a good idea for pop-up turrets so they don't prematurely reveal themselves. diff --git a/luarules/gadgets/unit_prevent_aircraft_hax.lua b/luarules/gadgets/unit_prevent_aircraft_hax.lua index d36a6607550..36f14355d6c 100644 --- a/luarules/gadgets/unit_prevent_aircraft_hax.lua +++ b/luarules/gadgets/unit_prevent_aircraft_hax.lua @@ -20,15 +20,15 @@ end local rangeLimit = 1800 local rangeLimitGaia = 20000 -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() local mapX = Game.mapSizeX local mapZ = Game.mapSizeZ local allMobileUnits = {} -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitDefID = Spring.GetUnitDefID -local spValidUnitID = Spring.ValidUnitID -local spIsPosInMap = Spring.IsPosInMap +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitDefID = SpringShared.GetUnitDefID +local spValidUnitID = SpringShared.ValidUnitID +local spIsPosInMap = SpringShared.IsPosInMap local CMD_STOP = CMD.STOP local CMD_GUARD = CMD.GUARD @@ -46,8 +46,8 @@ end function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD_STOP) gadgetHandler:RegisterAllowCommand(CMD_GUARD) - for _, unitID in pairs(Spring.GetAllUnits()) do - gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID), spGetUnitTeam(unitID)) + for _, unitID in pairs(SpringShared.GetAllUnits()) do + gadget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID), spGetUnitTeam(unitID)) end end @@ -75,11 +75,11 @@ function gadget:GameFrame(f) local unitTeam = spGetUnitTeam(unitID) if unitTeam == gaiaTeamID then if z < minMapGaia or x < minMapGaia or z > maxMapZGaia or x > maxMapXGaia then - Spring.DestroyUnit(unitID, false, true) + SpringSynced.DestroyUnit(unitID, false, true) end else if z < minMap or x < minMap or z > maxMapZ or x > maxMapX then - Spring.DestroyUnit(unitID, false, true) + SpringSynced.DestroyUnit(unitID, false, true) end end end diff --git a/luarules/gadgets/unit_prevent_cloaked_unit_reclaim.lua b/luarules/gadgets/unit_prevent_cloaked_unit_reclaim.lua index 7cf0f4bab7f..ba39665ae0d 100644 --- a/luarules/gadgets/unit_prevent_cloaked_unit_reclaim.lua +++ b/luarules/gadgets/unit_prevent_cloaked_unit_reclaim.lua @@ -20,16 +20,16 @@ local checkedUnits = {} local maxBuildDist = 0 if gadgetHandler:IsSyncedCode() then - local GetUnitAllyTeam = Spring.GetUnitAllyTeam - local GetUnitWorkerTask = Spring.GetUnitWorkerTask - local GiveOrderToUnit = Spring.GiveOrderToUnit - local GetUnitCurrentCommand = Spring.GetUnitCurrentCommand - local GetAllUnits = Spring.GetAllUnits - local IsUnitInRadar = Spring.IsUnitInRadar - local GetUnitPosition = Spring.GetUnitPosition - local GetUnitsInCylinder = Spring.GetUnitsInCylinder - local GetUnitDefID = Spring.GetUnitDefID - local GetUnitIsCloaked = Spring.GetUnitIsCloaked + local GetUnitAllyTeam = SpringShared.GetUnitAllyTeam + local GetUnitWorkerTask = SpringShared.GetUnitWorkerTask + local GiveOrderToUnit = SpringSynced.GiveOrderToUnit + local GetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand + local GetAllUnits = SpringShared.GetAllUnits + local IsUnitInRadar = SpringShared.IsUnitInRadar + local GetUnitPosition = SpringShared.GetUnitPosition + local GetUnitsInCylinder = SpringShared.GetUnitsInCylinder + local GetUnitDefID = SpringShared.GetUnitDefID + local GetUnitIsCloaked = SpringShared.GetUnitIsCloaked function gadget:AllowCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams) if (#cmdParams == 1) and GetUnitIsCloaked(cmdParams[1]) and (GetUnitAllyTeam(unitID) ~= GetUnitAllyTeam(cmdParams[1])) and not IsUnitInRadar(cmdParams[1], GetUnitAllyTeam(unitID)) then diff --git a/luarules/gadgets/unit_prevent_lab_hax2.lua b/luarules/gadgets/unit_prevent_lab_hax2.lua index 357930f124a..8fd5b954615 100644 --- a/luarules/gadgets/unit_prevent_lab_hax2.lua +++ b/luarules/gadgets/unit_prevent_lab_hax2.lua @@ -19,9 +19,9 @@ if gadgetHandler:IsSyncedCode() then local numtodestroy = 0 function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) -- destroy created unit if builder is dead - if Spring.ValidUnitID(builderID) and not Spring.GetUnitIsDead(builderID) then + if SpringShared.ValidUnitID(builderID) and not SpringShared.GetUnitIsDead(builderID) then else - local HP = Spring.GetUnitHealth(unitID) + local HP = SpringShared.GetUnitHealth(unitID) if HP <= 1 then -- avoid killing /give and Spring.CreateUnit() destroyQueue[numtodestroy + 1] = unitID numtodestroy = numtodestroy + 1 @@ -32,7 +32,7 @@ if gadgetHandler:IsSyncedCode() then function gadget:GameFrame() if numtodestroy > 0 then for i = numtodestroy, 1, -1 do - Spring.DestroyUnit(destroyQueue[i], false, true) + SpringSynced.DestroyUnit(destroyQueue[i], false, true) destroyQueue[i] = nil end numtodestroy = 0 @@ -40,7 +40,7 @@ if gadgetHandler:IsSyncedCode() then end function gadget:AllowUnitCreation(unitDefID, builderID, builderTeam, x, y, z, facing) -- do not allow create unit if builder is dead - if Spring.ValidUnitID(builderID) and not Spring.GetUnitIsDead(builderID) then + if SpringShared.ValidUnitID(builderID) and not SpringShared.GetUnitIsDead(builderID) then return true else return false diff --git a/luarules/gadgets/unit_prevent_load_hax.lua b/luarules/gadgets/unit_prevent_load_hax.lua index d91e75b36e6..6a459b08735 100644 --- a/luarules/gadgets/unit_prevent_load_hax.lua +++ b/luarules/gadgets/unit_prevent_load_hax.lua @@ -22,12 +22,12 @@ if not gadgetHandler:IsSyncedCode() then return false end -local GiveOrderToUnit = Spring.GiveOrderToUnit -local GetUnitPosition = Spring.GetUnitPosition -local GetUnitSeparation = Spring.GetUnitSeparation -local GetGameFrame = Spring.GetGameFrame -local GetUnitCommands = Spring.GetUnitCommands -local GetUnitTeam = Spring.GetUnitTeam +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit +local GetUnitPosition = SpringShared.GetUnitPosition +local GetUnitSeparation = SpringShared.GetUnitSeparation +local GetGameFrame = SpringShared.GetGameFrame +local GetUnitCommands = SpringShared.GetUnitCommands +local GetUnitTeam = SpringShared.GetUnitTeam local CMD_LOAD_UNITS = CMD.LOAD_UNITS local CMD_MOVE = CMD.MOVE local CMD_REMOVE = CMD.REMOVE diff --git a/luarules/gadgets/unit_prevent_nanoframe_blocking_hax.lua b/luarules/gadgets/unit_prevent_nanoframe_blocking_hax.lua index b5486ed8c3e..62b635290aa 100644 --- a/luarules/gadgets/unit_prevent_nanoframe_blocking_hax.lua +++ b/luarules/gadgets/unit_prevent_nanoframe_blocking_hax.lua @@ -26,12 +26,12 @@ local CMD_ATTACK = CMD.ATTACK local function AddNanoFrame(unitID) newNanoFrames[#newNanoFrames + 1] = unitID - local a, b, c, d, e, f, g = Spring.GetUnitBlocking(unitID) - Spring.SetUnitBlocking(unitID, a, b, false, d, e, f, g) -- non-blocking for projectiles + local a, b, c, d, e, f, g = SpringShared.GetUnitBlocking(unitID) + SpringSynced.SetUnitBlocking(unitID, a, b, false, d, e, f, g) -- non-blocking for projectiles - local neutral = Spring.GetUnitNeutral(unitID) + local neutral = SpringShared.GetUnitNeutral(unitID) newNanoFrameNeutralState[unitID] = neutral - Spring.SetUnitNeutral(unitID, true) + SpringSynced.SetUnitNeutral(unitID, true) --Spring.Echo("AddNanoFrame", #newNanoFrames, unitID) end @@ -40,12 +40,12 @@ local function RemoveNanoFrame(i) local unitID = newNanoFrames[i] --Spring.Echo("RemoveNanoFrame", i, unitID, newNanoFrameNeutralState[unitID]) - if Spring.ValidUnitID(unitID) then - local a, b, c, d, e, f, g = Spring.GetUnitBlocking(unitID) - Spring.SetUnitBlocking(unitID, a, b, true, d, e, f, g) -- blocking for projectiles + if SpringShared.ValidUnitID(unitID) then + local a, b, c, d, e, f, g = SpringShared.GetUnitBlocking(unitID) + SpringSynced.SetUnitBlocking(unitID, a, b, true, d, e, f, g) -- blocking for projectiles local neutral = newNanoFrameNeutralState[unitID] - Spring.SetUnitNeutral(unitID, neutral) + SpringSynced.SetUnitNeutral(unitID, neutral) --Spring.Echo("unset", unitID) end @@ -66,17 +66,17 @@ end local function CheckUnit(unitID) -- check if we should remove this unit from our list - if not Spring.ValidUnitID(unitID) then + if not SpringShared.ValidUnitID(unitID) then --Spring.Echo("to remove (invalid)", unitID) return true end - if Spring.GetUnitIsDead(unitID) then + if SpringShared.GetUnitIsDead(unitID) then --Spring.Echo("to remove (dead)", unitID) return true end - local _, buildProgress = Spring.GetUnitIsBeingBuilt(unitID) + local _, buildProgress = SpringShared.GetUnitIsBeingBuilt(unitID) if buildProgress >= blockingBuildProgress then return true end @@ -87,7 +87,7 @@ end function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) --local _,buildProgress = Spring.GetUnitIsBeingBuilt(unitID) if builderID then - local _, _, projectileBlocking = Spring.GetUnitBlocking(unitID) + local _, _, projectileBlocking = SpringShared.GetUnitBlocking(unitID) if projectileBlocking then AddNanoFrame(unitID) end @@ -126,10 +126,10 @@ end function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD_ATTACK) -- handle luarules reload - local units = Spring.GetAllUnits() + local units = SpringShared.GetAllUnits() for _, unitID in ipairs(units) do - local unitDefID = Spring.GetUnitDefID(unitID) - local unitTeam = Spring.GetUnitTeam(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) + local unitTeam = SpringShared.GetUnitTeam(unitID) gadget:UnitCreated(unitID, unitDefID, unitTeam) end end diff --git a/luarules/gadgets/unit_prevent_range_hax.lua b/luarules/gadgets/unit_prevent_range_hax.lua index 6cbeabf5db8..1e92f8c38f6 100644 --- a/luarules/gadgets/unit_prevent_range_hax.lua +++ b/luarules/gadgets/unit_prevent_range_hax.lua @@ -16,7 +16,7 @@ if not gadgetHandler:IsSyncedCode() then return false end -local spGetGroundHeight = Spring.GetGroundHeight +local spGetGroundHeight = SpringShared.GetGroundHeight local reissueOrder = Game.Commands.ReissueOrder local CMD_ATTACK = CMD.ATTACK diff --git a/luarules/gadgets/unit_prevent_share_load.lua b/luarules/gadgets/unit_prevent_share_load.lua index 57f85eac133..beff0ac1a54 100644 --- a/luarules/gadgets/unit_prevent_share_load.lua +++ b/luarules/gadgets/unit_prevent_share_load.lua @@ -17,6 +17,6 @@ if not gadgetHandler:IsSyncedCode() then end function gadget:AllowUnitTransfer(unitID, unitDefID, oldTeam, newTeam, capture) - Spring.GiveOrderToUnit(unitID, CMD.REMOVE, { CMD.LOAD_UNITS }, { "alt" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.REMOVE, { CMD.LOAD_UNITS }, { "alt" }) return true end diff --git a/luarules/gadgets/unit_prevent_share_self_d.lua b/luarules/gadgets/unit_prevent_share_self_d.lua index 0eed9d6a6b5..511b2827e95 100644 --- a/luarules/gadgets/unit_prevent_share_self_d.lua +++ b/luarules/gadgets/unit_prevent_share_self_d.lua @@ -17,11 +17,11 @@ if not gadgetHandler:IsSyncedCode() then end local monitorPlayers = {} -local spGetPlayerInfo = Spring.GetPlayerInfo +local spGetPlayerInfo = SpringShared.GetPlayerInfo function gadget:AllowUnitTransfer(unitID, unitDefID, oldTeam, newTeam, capture) - if Spring.GetUnitSelfDTime(unitID) > 0 then - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) + if SpringShared.GetUnitSelfDTime(unitID) > 0 then + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) end return true end @@ -39,20 +39,20 @@ local function removeSelfdOrders(teamID) --end -- cancel any self d orders - local units = Spring.GetTeamUnits(teamID) + local units = SpringShared.GetTeamUnits(teamID) for i = 1, #units do local unitID = units[i] - if Spring.GetUnitSelfDTime(unitID) > 0 then - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) + if SpringShared.GetUnitSelfDTime(unitID) > 0 then + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) end end end function gadget:Initialize() - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() for _, playerID in pairs(players) do local _, active, spec, teamID = spGetPlayerInfo(playerID, false) - local leaderPlayerID, isDead, isAiTeam = Spring.GetTeamInfo(teamID, false) + local leaderPlayerID, isDead, isAiTeam = SpringShared.GetTeamInfo(teamID, false) if isDead == 0 and not isAiTeam then --_, active, spec = spGetPlayerInfo(leaderPlayerID, false) if active and not spec then diff --git a/luarules/gadgets/unit_prevent_unload_hax.lua b/luarules/gadgets/unit_prevent_unload_hax.lua index ef9d4407ddc..126003d8d18 100644 --- a/luarules/gadgets/unit_prevent_unload_hax.lua +++ b/luarules/gadgets/unit_prevent_unload_hax.lua @@ -25,13 +25,13 @@ for udid, ud in pairs(UnitDefs) do end end -local SpSetUnitVelocity = Spring.SetUnitVelocity -local SpGetUnitVelocity = Spring.GetUnitVelocity -local SpGetGroundHeight = Spring.GetGroundHeight -local SpGetUnitPosition = Spring.GetUnitPosition -local SpGetGameFrame = Spring.GetGameFrame -local SpSetUnitPhysics = Spring.SetUnitPhysics -local SpSetUnitDirection = Spring.SetUnitDirection +local SpSetUnitVelocity = SpringSynced.SetUnitVelocity +local SpGetUnitVelocity = SpringShared.GetUnitVelocity +local SpGetGroundHeight = SpringShared.GetGroundHeight +local SpGetUnitPosition = SpringShared.GetUnitPosition +local SpGetGameFrame = SpringShared.GetGameFrame +local SpSetUnitPhysics = SpringSynced.SetUnitPhysics +local SpSetUnitDirection = SpringSynced.SetUnitDirection local unloadedUnits = {} @@ -61,8 +61,8 @@ function gadget:UnitUnloaded(unitID, unitDefID, teamID, transportID) SpSetUnitVelocity(unitID, x, y, z) else -- prevent unloaded units from sliding across the map - local px, py, pz = Spring.GetUnitPosition(unitID) - local dx, dy, dz = Spring.GetUnitDirection(unitID) + local px, py, pz = SpringShared.GetUnitPosition(unitID) + local dx, dy, dz = SpringShared.GetUnitDirection(unitID) local frame = SpGetGameFrame() + frameMargin unloadedUnits[unitID] = { ["px"] = px, ["py"] = py, ["pz"] = pz, ["dx"] = dx, ["dy"] = dy, ["dz"] = dz, ["frame"] = frame } diff --git a/luarules/gadgets/unit_projectile_overrange.lua b/luarules/gadgets/unit_projectile_overrange.lua index c7dacc81329..f69cb67bef6 100644 --- a/luarules/gadgets/unit_projectile_overrange.lua +++ b/luarules/gadgets/unit_projectile_overrange.lua @@ -37,16 +37,16 @@ local mapGravity = Game.gravity / Game.gameSpeed ^ 2 local descentGravity = -mapGravity * 5 --functions -local spGetUnitPosition = Spring.GetUnitPosition +local spGetUnitPosition = SpringShared.GetUnitPosition local mathRandom = math.random local mathCeil = math.ceil local mathSqrt = math.sqrt -local spGetProjectilePosition = Spring.GetProjectilePosition -local spSetProjectileCollision = Spring.SetProjectileCollision -local spGetProjectileVelocity = Spring.GetProjectileVelocity -local spSetProjectileVelocity = Spring.SetProjectileVelocity -local spSetProjectileTimeToLive = Spring.SetProjectileTimeToLive -local spSetProjectileGravity = Spring.SetProjectileGravity +local spGetProjectilePosition = SpringShared.GetProjectilePosition +local spSetProjectileCollision = SpringSynced.SetProjectileCollision +local spGetProjectileVelocity = SpringShared.GetProjectileVelocity +local spSetProjectileVelocity = SpringSynced.SetProjectileVelocity +local spSetProjectileTimeToLive = SpringSynced.SetProjectileTimeToLive +local spSetProjectileGravity = SpringSynced.SetProjectileGravity --tables local defWatchTable = {} diff --git a/luarules/gadgets/unit_reactive_armor.lua b/luarules/gadgets/unit_reactive_armor.lua index 234fbb323a1..b6880350adb 100644 --- a/luarules/gadgets/unit_reactive_armor.lua +++ b/luarules/gadgets/unit_reactive_armor.lua @@ -30,9 +30,9 @@ local table_new = table.new local math_floor = math.floor local math_clamp = math.clamp -local spCallCobScript = Spring.CallCOBScript -local spGetUnitDefID = Spring.GetUnitDefID -local spSetUnitRulesParam = Spring.SetUnitRulesParam +local spCallCobScript = SpringSynced.CallCOBScript +local spGetUnitDefID = SpringShared.GetUnitDefID +local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam local gameSpeed = Game.gameSpeed @@ -56,7 +56,7 @@ for unitDefID, unitDef in pairs(UnitDefs) do end end -local callFromLus = Spring.UnitScript.CallAsUnit +local callFromLus = SpringSynced.UnitScript.CallAsUnit local callFromCob = function(unitID, funcName, ...) spCallCobScript(unitID, funcName, 0, ...) -- to add arg count 0 end @@ -65,7 +65,7 @@ end -- since that is the first time the game gives us info on them. local function checkReactiveArmor(unitID, unitDefID, params) local hasMethod - local lusEnv = Spring.UnitScript.GetScriptEnv(unitID) + local lusEnv = SpringSynced.UnitScript.GetScriptEnv(unitID) if lusEnv then hasMethod = function(name) @@ -73,7 +73,7 @@ local function checkReactiveArmor(unitID, unitDefID, params) end else hasMethod = function(name) - return Spring.GetCOBScriptID(unitID, name) ~= nil + return SpringSynced.GetCOBScriptID(unitID, name) ~= nil end end @@ -114,13 +114,13 @@ local function checkReactiveArmor(unitID, unitDefID, params) if next(missing) then -- The unit script is malformed in some way and we make no attempts to recover it. - Spring.Log("Reactive Armor", LOG.ERROR, ("Unit script missing %s: %s"):format(table.concat(missing, ", "), UnitDefs[unitDefID].name)) + SpringShared.Log("Reactive Armor", LOG.ERROR, ("Unit script missing %s: %s"):format(table.concat(missing, ", "), UnitDefs[unitDefID].name)) success = false end if (params.pieces - 1) * gameSpeed > params.frames then -- Armor pieces regenerate once per second until the end of the armor restore duration. - Spring.Log("Reactive Armor", LOG.ERROR, ("Too many armor pieces (%d) for restore time: "):format(params.pieces, UnitDefs[unitDefID].name)) + SpringShared.Log("Reactive Armor", LOG.ERROR, ("Too many armor pieces (%d) for restore time: "):format(params.pieces, UnitDefs[unitDefID].name)) success = false end @@ -288,7 +288,7 @@ local debugReloads = false local function getUnitDebugInfo(unitID) local unitDefID = spGetUnitDefID(unitID) - local x, y, z = Spring.GetUnitPosition(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) return { x = x, y = y, @@ -297,7 +297,7 @@ local function getUnitDebugInfo(unitID) unitDefID = unitDefID, unitDefName = UnitDefs[unitDefID].name, unitDefParams = armoredUnitDefs[unitDefID] or "none", - health = Spring.GetUnitHealth(unitID), + health = SpringShared.GetUnitHealth(unitID), armorFrames = unitArmorFrames[unitID] or "nil", armorHealth = unitArmorHealth[unitID] or "nil", inCombatUntil = regenerateFrame[unitID] or "nil", @@ -309,8 +309,8 @@ local function showDebugInfo(unitID) local info = getUnitDebugInfo(unitID) if info.unitCountdown then local display = ("hp:%s res:%s"):format(tostring(info.armorHealth), tostring(info.unitCountdown)) - Spring.MarkerAddPoint(info.x, info.y, info.z, display) - Spring.Echo("Reactive Armor", info) + SpringUnsynced.MarkerAddPoint(info.x, info.y, info.z, display) + SpringShared.Echo("Reactive Armor", info) end end @@ -370,18 +370,18 @@ function gadget:Initialize() return end - callFromLus = Spring.UnitScript.CallAsUnit - gameFrame = Spring.GetGameFrame() + callFromLus = SpringSynced.UnitScript.CallAsUnit + gameFrame = SpringShared.GetGameFrame() combatEndFrame = gameFrame + unitCombatDuration if gameFrame <= 0 then return end - local spGetUnitRulesParam = Spring.GetUnitRulesParam + local spGetUnitRulesParam = SpringShared.GetUnitRulesParam local function reloadUnitState(unitID, unitDefID, unitTeam) - if Spring.GetUnitIsBeingBuilt(unitID) then + if SpringShared.GetUnitIsBeingBuilt(unitID) then return end @@ -412,10 +412,10 @@ function gadget:Initialize() end end - for _, unitID in ipairs(Spring.GetAllUnits()) do + for _, unitID in ipairs(SpringShared.GetAllUnits()) do local uDefID = spGetUnitDefID(unitID) if armoredUnitDefs[uDefID] then - reloadUnitState(unitID, uDefID, Spring.GetUnitTeam(unitID)) + reloadUnitState(unitID, uDefID, SpringShared.GetUnitTeam(unitID)) end end end diff --git a/luarules/gadgets/unit_reclaim_fix.lua b/luarules/gadgets/unit_reclaim_fix.lua index 4cb33566158..3dd3892291c 100644 --- a/luarules/gadgets/unit_reclaim_fix.lua +++ b/luarules/gadgets/unit_reclaim_fix.lua @@ -16,10 +16,10 @@ if not gadgetHandler:IsSyncedCode() then return end -local SetFeatureReclaim = Spring.SetFeatureReclaim -local GetFeaturePosition = Spring.GetFeaturePosition -local GetUnitDefID = Spring.GetUnitDefID -local GetFeatureResources = Spring.GetFeatureResources +local SetFeatureReclaim = SpringSynced.SetFeatureReclaim +local GetFeaturePosition = SpringShared.GetFeaturePosition +local GetUnitDefID = SpringShared.GetUnitDefID +local GetFeatureResources = SpringShared.GetFeatureResources local mathMax = math.max local featureListMaxResource = {} diff --git a/luarules/gadgets/unit_respawning.lua b/luarules/gadgets/unit_respawning.lua index 99013340865..077ff8f06f9 100644 --- a/luarules/gadgets/unit_respawning.lua +++ b/luarules/gadgets/unit_respawning.lua @@ -15,18 +15,18 @@ end if gadgetHandler:IsSyncedCode() then - local spCreateUnit = Spring.CreateUnit - local spDestroyUnit = Spring.DestroyUnit - local spGiveOrderToUnit = Spring.GiveOrderToUnit - local spSetUnitRulesParam = Spring.SetUnitRulesParam - local spGetUnitPosition = Spring.GetUnitPosition - local spGetUnitRulesParam = Spring.GetUnitRulesParam - local spGetUnitHealth = Spring.GetUnitHealth - local spGetUnitTeam = Spring.GetUnitTeam - local spSetUnitHealth = Spring.SetUnitHealth - local spGetGameSeconds = Spring.GetGameSeconds - local spGetUnitNearestEnemy = Spring.GetUnitNearestEnemy - local spGetUnitDefID = Spring.GetUnitDefID + local spCreateUnit = SpringSynced.CreateUnit + local spDestroyUnit = SpringSynced.DestroyUnit + local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit + local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam + local spGetUnitPosition = SpringShared.GetUnitPosition + local spGetUnitRulesParam = SpringShared.GetUnitRulesParam + local spGetUnitHealth = SpringShared.GetUnitHealth + local spGetUnitTeam = SpringShared.GetUnitTeam + local spSetUnitHealth = SpringSynced.SetUnitHealth + local spGetGameSeconds = SpringShared.GetGameSeconds + local spGetUnitNearestEnemy = SpringShared.GetUnitNearestEnemy + local spGetUnitDefID = SpringShared.GetUnitDefID local diag = math.diag @@ -77,18 +77,18 @@ if gadgetHandler:IsSyncedCode() then local health, maxHealth = spGetUnitHealth(unitID) local effigyID = meta.effigyID local ex, ey, ez = spGetUnitPosition(effigyID) - Spring.SetUnitPosition(unitID, ex, ez, true) - Spring.SpawnCEG("commander-spawn", ex, ey, ez, 0, 0, 0) - Spring.PlaySoundFile("commanderspawn-mono", 1.0, ex, ey, ez, 0, 0, 0, "sfx") + SpringSynced.SetUnitPosition(unitID, ex, ez, true) + SpringSynced.SpawnCEG("commander-spawn", ex, ey, ez, 0, 0, 0) + SpringUnsynced.PlaySoundFile("commanderspawn-mono", 1.0, ex, ey, ez, 0, 0, 0, "sfx") GG.ComSpawnDefoliate(ex, ey, ez) -- Mark effigy as used for respawning to prevent "lost" notifications meta.effigyID = nil if meta.respawn_pad == "false" then - Spring.SetUnitPosition(effigyID, x, z, true) - Spring.SpawnCEG("commander-spawn", x, y, z, 0, 0, 0) - Spring.PlaySoundFile("commanderspawn-mono", 1.0, x, y, z, 0, 0, 0, "sfx") + SpringSynced.SetUnitPosition(effigyID, x, z, true) + SpringSynced.SpawnCEG("commander-spawn", x, y, z, 0, 0, 0) + SpringUnsynced.PlaySoundFile("commanderspawn-mono", 1.0, x, y, z, 0, 0, 0, "sfx") GG.ComSpawnDefoliate(x, y, z) end @@ -116,14 +116,14 @@ if gadgetHandler:IsSyncedCode() then local udcp = defCustomParams[unitDefID] if udcp and udcp.iscommander and respawnMetaList[unitID] then local unitTeam = respawnMetaList[unitID].unitTeam - local allPlayers = Spring.GetPlayerList() + local allPlayers = SpringShared.GetPlayerList() local notificationEvent for _, playerID in ipairs(allPlayers) do - local playerName, active, isSpectator, teamID, allyTeamID = Spring.GetPlayerInfo(playerID, true) + local playerName, active, isSpectator, teamID, allyTeamID = SpringShared.GetPlayerInfo(playerID, true) if teamID and unitTeam and not isSpectator then if teamID == unitTeam then notificationEvent = "RespawningCommanders/CommanderTransposed" - elseif teamID and Spring.AreTeamsAllied(teamID, unitTeam) then + elseif teamID and SpringShared.AreTeamsAllied(teamID, unitTeam) then notificationEvent = "RespawningCommanders/AlliedCommanderTransposed" else notificationEvent = "RespawningCommanders/EnemyCommanderTransposed" @@ -164,8 +164,8 @@ if gadgetHandler:IsSyncedCode() then local blockedIncrement = 1 for i = 1, 500, blockedIncrement do local x, y, z = spGetUnitPosition(unitID) - local blockType, blockID = Spring.GetGroundBlocked(x - i, z - i) - local groundH = Spring.GetGroundHeight(x - i, z - i) + local blockType, blockID = SpringShared.GetGroundBlocked(x - i, z - i) + local groundH = SpringShared.GetGroundHeight(x - i, z - i) if respawnMetaList[unitID].effigy_offset == 0 then local newUnitID = spCreateUnit(respawnMetaList[unitID].effigy, x, groundH, z, 0, unitTeam) @@ -199,7 +199,7 @@ if gadgetHandler:IsSyncedCode() then if oldeffigyID then local oldEffigyBuildProgress = select(5, spGetUnitHealth(oldeffigyID)) if oldEffigyBuildProgress == 1 then - Spring.SetUnitCosts(unitID, { buildTime = 1, metalCost = 1, energyCost = 1 }) + SpringSynced.SetUnitCosts(unitID, { buildTime = 1, metalCost = 1, energyCost = 1 }) end destroyEffigy(oldeffigyID, false, true) end @@ -217,7 +217,7 @@ if gadgetHandler:IsSyncedCode() then if oldeffigyID then local oldEffigyBuildProgress = select(5, spGetUnitHealth(oldeffigyID)) if oldEffigyBuildProgress == 1 then - Spring.SetUnitCosts(unitID, { buildTime = 1, metalCost = 1, energyCost = 1 }) + SpringSynced.SetUnitCosts(unitID, { buildTime = 1, metalCost = 1, energyCost = 1 }) end destroyEffigy(oldeffigyID, false, true) end @@ -233,14 +233,14 @@ if gadgetHandler:IsSyncedCode() then local effigyOwnerID = effigyToCommander[unitID] if effigyOwnerID then - local udcp = defCustomParams[Spring.GetUnitDefID(effigyOwnerID)] + local udcp = defCustomParams[SpringShared.GetUnitDefID(effigyOwnerID)] if udcp and udcp.iscommander and respawnMetaList[effigyOwnerID].effigyID then -- Only send notification if the effigy wasn't already used for respawning local commanderTeam = respawnMetaList[effigyOwnerID].unitTeam - local allPlayers = Spring.GetPlayerList() + local allPlayers = SpringShared.GetPlayerList() for _, playerID in ipairs(allPlayers) do - local playerName, active, isSpectator, teamID, allyTeamID = Spring.GetPlayerInfo(playerID, true) + local playerName, active, isSpectator, teamID, allyTeamID = SpringShared.GetPlayerInfo(playerID, true) if teamID == commanderTeam then GG.notifications.queueNotification("RespawningCommanders/CommanderEffigyLost", "playerID", tostring(playerID)) end @@ -266,7 +266,7 @@ if gadgetHandler:IsSyncedCode() then if respawnMetaList[newID] and respawnMetaList[newID].effigyID then local ex, ey, ez = spGetUnitPosition(respawnMetaList[unitID].effigyID) if ex then - Spring.SetUnitPosition(respawnMetaList[newID].effigyID, ex, ez, true) + SpringSynced.SetUnitPosition(respawnMetaList[newID].effigyID, ex, ez, true) else destroyEffigy(respawnMetaList[newID].effigyID, false, true) end @@ -296,7 +296,7 @@ if gadgetHandler:IsSyncedCode() then if not attackerTeam then attackerTeam = unitTeam -- lava damage team = nil, so set to self team if nil end - local friendlyFire = Spring.AreTeamsAllied(unitTeam, attackerTeam) + local friendlyFire = SpringShared.AreTeamsAllied(unitTeam, attackerTeam) local enemyNearby = spGetUnitNearestEnemy(unitID, 1000) if friendlyFire and enemyNearby then friendlyFire = false @@ -314,7 +314,7 @@ if gadgetHandler:IsSyncedCode() then else - local spGetGameSeconds = Spring.GetGameSeconds + local spGetGameSeconds = SpringShared.GetGameSeconds local announcementStart = 0 local announcementEnabled = false @@ -323,8 +323,8 @@ else local displayList - local fontfile = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") - local vsx, vsy = Spring.GetViewGeometry() + local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") + local vsx, vsy = SpringUnsynced.GetViewGeometry() local fontfileScale = (0.5 + (vsx * vsy / 6200000)) local fontfileSize = 50 local fontfileOutlineSize = 10 @@ -332,7 +332,7 @@ else local font = gl.LoadFont(fontfile, fontfileSize * fontfileScale, fontfileOutlineSize * fontfileScale, fontfileOutlineStrength) local function Draw(newAnnouncement, newAnnouncementSize) - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() local uiScale = (0.7 + (vsx * vsy / 6500000)) displayList = gl.CreateList(function() font:Begin() @@ -355,7 +355,7 @@ else end function gadget:DrawScreen() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if announcementEnabled then diff --git a/luarules/gadgets/unit_resurrected.lua b/luarules/gadgets/unit_resurrected.lua index fc5d644ebfe..e7c16622691 100644 --- a/luarules/gadgets/unit_resurrected.lua +++ b/luarules/gadgets/unit_resurrected.lua @@ -24,11 +24,11 @@ local VISIBILITY_INLOS = { inlos = true } local UPDATE_INTERVAL = Game.gameSpeed local TIMEOUT_FRAMES = Game.gameSpeed * 3 -- long enough to get grabbed by FeatureCreated callback -local spGetUnitHealth = Spring.GetUnitHealth -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGetFeatureRulesParam = Spring.GetFeatureRulesParam -local spSetFeatureRulesParam = Spring.SetFeatureRulesParam +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGetFeatureRulesParam = SpringShared.GetFeatureRulesParam +local spSetFeatureRulesParam = SpringSynced.SetFeatureRulesParam local shouldWaitForHealing = {} local toBeUnWaited = {} @@ -40,7 +40,7 @@ for unitDefID, unitDef in pairs(UnitDefs) do end local function RestoreStateMechanics(unitID, featureID) - Spring.SetUnitExperience(unitID, spGetFeatureRulesParam(featureID, "previous_xp") or 0) + SpringSynced.SetUnitExperience(unitID, spGetFeatureRulesParam(featureID, "previous_xp") or 0) end local function RestoreStateGUI(unitID, featureID) @@ -60,7 +60,7 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) return end - local cmdID, featureID = Spring.GetUnitWorkerTask(builderID) + local cmdID, featureID = SpringShared.GetUnitWorkerTask(builderID) if cmdID ~= CMD_RESURRECT then return end @@ -76,25 +76,25 @@ function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) end -- FIXME: 1 -> true (0 is truthy in lua too), but would need to be fixed elsewhere as well - Spring.SetUnitRulesParam(unitID, "resurrected", 1, VISIBILITY_INLOS) + SpringSynced.SetUnitRulesParam(unitID, "resurrected", 1, VISIBILITY_INLOS) - Spring.SetUnitHealth(unitID, spGetUnitHealth(unitID) * 0.05) + SpringSynced.SetUnitHealth(unitID, spGetUnitHealth(unitID) * 0.05) RestoreStateMechanics(unitID, featureID) -- Don't retain GUI settings (movestate etc) from other players - if Spring.GetFeatureTeam(featureID) == Spring.GetUnitTeam(unitID) then + if SpringShared.GetFeatureTeam(featureID) == SpringShared.GetUnitTeam(unitID) then RestoreStateGUI(unitID, featureID) end end function gadget:UnitDestroyed(unitID, unitDefID, unitTeam) - local states = Spring.GetUnitStates(unitID) + local states = SpringShared.GetUnitStates(unitID) priorStates[unitID] = { - timeout = Spring.GetGameFrame() + TIMEOUT_FRAMES, + timeout = SpringShared.GetGameFrame() + TIMEOUT_FRAMES, firestate = states.firestate, movestate = states.movestate, - xp = Spring.GetUnitExperience(unitID), + xp = SpringShared.GetUnitExperience(unitID), } end diff --git a/luarules/gadgets/unit_reverse_move.lua b/luarules/gadgets/unit_reverse_move.lua index c47af72495c..a6cbab526a0 100644 --- a/luarules/gadgets/unit_reverse_move.lua +++ b/luarules/gadgets/unit_reverse_move.lua @@ -32,7 +32,7 @@ if unitRspeedCount == 0 then end unitRspeedCount = nil -local spGetUnitCommands = Spring.GetUnitCommands +local spGetUnitCommands = SpringShared.GetUnitCommands local reverseUnit = {} local refreshList = {} @@ -40,8 +40,8 @@ function gadget:UnitCreated(unitID, unitDefID) if unitRspeed[unitDefID] then reverseUnit[unitID] = unitDefID refreshList[unitID] = unitDefID - Spring.MoveCtrl.SetGroundMoveTypeData(unitID, "maxSpeed", unitSpeed[unitDefID]) - Spring.MoveCtrl.SetGroundMoveTypeData(unitID, "maxReverseSpeed", 0) + SpringSynced.MoveCtrl.SetGroundMoveTypeData(unitID, "maxSpeed", unitSpeed[unitDefID]) + SpringSynced.MoveCtrl.SetGroundMoveTypeData(unitID, "maxReverseSpeed", 0) end end @@ -51,8 +51,8 @@ function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerD end function gadget:Initialize() - for ct, unitID in pairs(Spring.GetAllUnits()) do - gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID)) + for ct, unitID in pairs(SpringShared.GetAllUnits()) do + gadget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID)) end end @@ -79,11 +79,11 @@ function gadget:GameFrame(f) for unitID, unitDefID in pairs(refreshList) do local cmd = spGetUnitCommands(unitID, 1) if cmd and cmd[1] and cmd[1]["options"] and cmd[1]["options"].ctrl then - Spring.MoveCtrl.SetGroundMoveTypeData(unitID, "maxSpeed", unitRspeed[unitDefID]) - Spring.MoveCtrl.SetGroundMoveTypeData(unitID, "maxReverseSpeed", unitRspeed[unitDefID]) + SpringSynced.MoveCtrl.SetGroundMoveTypeData(unitID, "maxSpeed", unitRspeed[unitDefID]) + SpringSynced.MoveCtrl.SetGroundMoveTypeData(unitID, "maxReverseSpeed", unitRspeed[unitDefID]) else - Spring.MoveCtrl.SetGroundMoveTypeData(unitID, "maxSpeed", unitSpeed[unitDefID]) - Spring.MoveCtrl.SetGroundMoveTypeData(unitID, "maxReverseSpeed", 0) + SpringSynced.MoveCtrl.SetGroundMoveTypeData(unitID, "maxSpeed", unitSpeed[unitDefID]) + SpringSynced.MoveCtrl.SetGroundMoveTypeData(unitID, "maxReverseSpeed", 0) end refreshList[unitID] = nil end diff --git a/luarules/gadgets/unit_scenario_loadout.lua b/luarules/gadgets/unit_scenario_loadout.lua index 0b41d256854..405bda60cfc 100644 --- a/luarules/gadgets/unit_scenario_loadout.lua +++ b/luarules/gadgets/unit_scenario_loadout.lua @@ -44,26 +44,26 @@ local startMetal = 1000 local startEnergy = 1000 local teamList = {} local additionalStorage = {} -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() function gadget:Initialize() - gaiaTeamID = Spring.GetGaiaTeamID() + gaiaTeamID = SpringShared.GetGaiaTeamID() end function gadget:GamePreload() - if Spring.GetGameRulesParam("loadedGame") == 1 then - Spring.Echo("Scenario: Loading saved game, skipping loadout") + if SpringShared.GetGameRulesParam("loadedGame") == 1 then + SpringShared.Echo("Scenario: Loading saved game, skipping loadout") gadgetHandler:RemoveGadget(self) end - if Spring.GetGameFrame() < 1 and not loadoutcomplete then + if SpringShared.GetGameFrame() < 1 and not loadoutcomplete then -- so that loaded savegames dont re-place - if Spring.GetModOptions().scenariooptions then - Spring.Echo("Scenario: Spawning on frame", Spring.GetGameFrame()) - local scenariooptions = string.base64Decode(Spring.GetModOptions().scenariooptions) + if SpringShared.GetModOptions().scenariooptions then + SpringShared.Echo("Scenario: Spawning on frame", SpringShared.GetGameFrame()) + local scenariooptions = string.base64Decode(SpringShared.GetModOptions().scenariooptions) scenariooptions = Json.decode(scenariooptions) if scenariooptions and scenariooptions.unitloadout then - Spring.Echo("Scenario: Creating unit loadout") + SpringShared.Echo("Scenario: Creating unit loadout") local unitloadout = scenariooptions.unitloadout if unitloadout then for k, unit in pairs(unitloadout) do @@ -71,9 +71,9 @@ function gadget:GamePreload() if UnitDefNames[unit.name] then local rot = rot_to_facing(unit.rot) - local unitID = Spring.CreateUnit(unit.name, unit.x, Spring.GetGroundHeight(unit.x, unit.z), unit.z, rot, unit.team) + local unitID = SpringSynced.CreateUnit(unit.name, unit.x, SpringShared.GetGroundHeight(unit.x, unit.z), unit.z, rot, unit.team) if unitID then - Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) if UnitDefNames[unit.name].energyStorage > 0 or UnitDefNames[unit.name].metalStorage > 0 then if additionalStorage[unit.team] == nil then additionalStorage[unit.team] = { metal = 0, energy = 0 } @@ -86,27 +86,27 @@ function gadget:GamePreload() nanoturretunitIDs[unitID] = true end if unit.neutral == true or unit.neutral == "true" then - Spring.SetUnitNeutral(unitID, true) + SpringSynced.SetUnitNeutral(unitID, true) end else - Spring.Echo("Scenario: UnitDef name is invalid:", unit.name) + SpringShared.Echo("Scenario: UnitDef name is invalid:", unit.name) end end end end if scenariooptions and scenariooptions.featureloadout then - Spring.Echo("Scenario: Creating feature loadout") + SpringShared.Echo("Scenario: Creating feature loadout") local featureloadout = scenariooptions.featureloadout if featureloadout and next(featureloadout) then for k, feature in pairs(featureloadout) do if FeatureDefNames[feature.name] then local rot = tonumber(feature.rot) or 0 - local featureID = Spring.CreateFeature(feature.name, feature.x, Spring.GetGroundHeight(feature.x, feature.z), feature.z, rot, gaiaTeamID) + local featureID = SpringSynced.CreateFeature(feature.name, feature.x, SpringShared.GetGroundHeight(feature.x, feature.z), feature.z, rot, gaiaTeamID) if feature.resurrectas and UnitDefNames[feature.resurrectas] then - Spring.SetFeatureResurrect(featureID, feature.resurrectas) + SpringSynced.SetFeatureResurrect(featureID, feature.resurrectas) end else - Spring.Echo("Scenario: FeatureDef name is invalid:", feature.name) + SpringShared.Echo("Scenario: FeatureDef name is invalid:", feature.name) end end end @@ -121,15 +121,15 @@ function gadget:GameFrame(n) if n == 1 then if next(nanoturretunitIDs) then for unitID, _ in pairs(nanoturretunitIDs) do - Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) end end if next(additionalStorage) then for teamID, additionalstorage in pairs(additionalStorage) do - local m, mstore = Spring.GetTeamResources(teamID, "metal") - local e, estore = Spring.GetTeamResources(teamID, "energy") - Spring.SetTeamResource(teamID, "ms", mstore + additionalstorage.metal) - Spring.SetTeamResource(teamID, "es", estore + additionalstorage.energy) + local m, mstore = SpringShared.GetTeamResources(teamID, "metal") + local e, estore = SpringShared.GetTeamResources(teamID, "energy") + SpringSynced.SetTeamResource(teamID, "ms", mstore + additionalstorage.metal) + SpringSynced.SetTeamResource(teamID, "es", estore + additionalstorage.energy) end additionalStorage = nil end diff --git a/luarules/gadgets/unit_scenario_script.lua b/luarules/gadgets/unit_scenario_script.lua index 2cc6b228dd2..0a27ed4bc15 100644 --- a/luarules/gadgets/unit_scenario_script.lua +++ b/luarules/gadgets/unit_scenario_script.lua @@ -19,8 +19,8 @@ else end local function GetScenarioID() - if Spring.GetModOptions().scenariooptions then - local scenariooptions = string.base64Decode(Spring.GetModOptions().scenariooptions) + if SpringShared.GetModOptions().scenariooptions then + local scenariooptions = string.base64Decode(SpringShared.GetModOptions().scenariooptions) scenariooptions = Json.decode(scenariooptions) return scenariooptions.scenarioid end @@ -36,5 +36,5 @@ if not VFS.FileExists("singleplayer/scenarios/scenarioscripts/" .. scenarioid .. return end -Spring.Echo("Scenario ID: " .. scenarioid) +SpringShared.Echo("Scenario ID: " .. scenarioid) VFS.Include("singleplayer/scenarios/scenarioscripts/" .. scenarioid .. ".lua") diff --git a/luarules/gadgets/unit_script.lua b/luarules/gadgets/unit_script.lua index 4454b8ef73f..4f9d845c19c 100644 --- a/luarules/gadgets/unit_script.lua +++ b/luarules/gadgets/unit_script.lua @@ -121,29 +121,29 @@ local co_running = coroutine.running local bit_and = math.bit_and local floor = math.floor -local sp_GetGameFrame = Spring.GetGameFrame -local sp_GetUnitWeaponState = Spring.GetUnitWeaponState -local sp_SetUnitWeaponState = Spring.SetUnitWeaponState -local sp_SetUnitShieldState = Spring.SetUnitShieldState -local sp_GetUnitDefID = Spring.GetUnitDefID -local sp_GetAllUnits = Spring.GetAllUnits -local sp_GetUnitPieceMap = Spring.GetUnitPieceMap +local sp_GetGameFrame = SpringShared.GetGameFrame +local sp_GetUnitWeaponState = SpringShared.GetUnitWeaponState +local sp_SetUnitWeaponState = SpringSynced.SetUnitWeaponState +local sp_SetUnitShieldState = SpringSynced.SetUnitShieldState +local sp_GetUnitDefID = SpringShared.GetUnitDefID +local sp_GetAllUnits = SpringShared.GetAllUnits +local sp_GetUnitPieceMap = SpringShared.GetUnitPieceMap -- Keep local reference to engine's CallAsUnit/WaitForMove/WaitForTurn, -- as we overwrite them with (safer) framework version later on. -local sp_CallAsUnit = Spring.UnitScript.CallAsUnit -local sp_WaitForMove = Spring.UnitScript.WaitForMove -local sp_WaitForTurn = Spring.UnitScript.WaitForTurn -local sp_WaitForScale = Spring.UnitScript.WaitForScale -local sp_SetPieceVisibility = Spring.UnitScript.SetPieceVisibility -local sp_SetDeathScriptFinished = Spring.UnitScript.SetDeathScriptFinished +local sp_CallAsUnit = SpringSynced.UnitScript.CallAsUnit +local sp_WaitForMove = SpringSynced.UnitScript.WaitForMove +local sp_WaitForTurn = SpringSynced.UnitScript.WaitForTurn +local sp_WaitForScale = SpringSynced.UnitScript.WaitForScale +local sp_SetPieceVisibility = SpringSynced.UnitScript.SetPieceVisibility +local sp_SetDeathScriptFinished = SpringSynced.UnitScript.SetDeathScriptFinished local LUA_WEAPON_MIN_INDEX = 1 local LUA_WEAPON_MAX_INDEX = LUA_WEAPON_MIN_INDEX + 31 local UNITSCRIPT_DIR = (UNITSCRIPT_DIR or "scripts/"):lower() local VFSMODE = VFS.ZIP_ONLY -if Spring.IsDevLuaEnabled() then +if SpringShared.IsDevLuaEnabled() then VFSMODE = VFS.RAW_ONLY end @@ -261,7 +261,7 @@ local function RunOnError(thread) if fun then local good, err = pcall(fun, err) if not good then - Spring.Log(section, LOG.ERROR, "error in error handler: " .. tostring(err)) + SpringShared.Log(section, LOG.ERROR, "error in error handler: " .. tostring(err)) end end end @@ -273,9 +273,9 @@ local function WakeUp(thread, ...) local co = thread.thread local good, err = co_resume(co, ...) if not good then - Spring.Log(section, LOG.ERROR, err) + SpringShared.Log(section, LOG.ERROR, err) if debug and debug.traceback then - Spring.Log(section, LOG.ERROR, debug.traceback(co)) + SpringShared.Log(section, LOG.ERROR, debug.traceback(co)) end RunOnError(thread) end @@ -537,12 +537,12 @@ end local function LoadChunk(filename) local text = VFS.LoadFile(filename, VFSMODE) if text == nil then - Spring.Log(section, LOG.ERROR, "Failed to load: " .. filename) + SpringShared.Log(section, LOG.ERROR, "Failed to load: " .. filename) return nil end local chunk, err = loadstring(scriptHeader .. text, filename) if chunk == nil then - Spring.Log(section, LOG.ERROR, "Failed to load: " .. Basename(filename) .. " (" .. err .. ")") + SpringShared.Log(section, LOG.ERROR, "Failed to load: " .. Basename(filename) .. " (" .. err .. ")") return nil end return chunk @@ -555,7 +555,7 @@ local function LoadScript(scriptName, filename) end function gadget:Initialize() - Spring.Log(section, LOG.INFO, string.format("Loading gadget: %-18s <%s>", ghInfo.name, ghInfo.basename)) + SpringShared.Log(section, LOG.INFO, string.format("Loading gadget: %-18s <%s>", ghInfo.name, ghInfo.basename)) -- This initialization code has following properties: -- * all used scripts are loaded => early syntax error detection @@ -588,7 +588,7 @@ function gadget:Initialize() local cbn = bn:gsub("%.cob$", "%.lua") local filename = scriptFiles[fn] or scriptFiles[bn] or scriptFiles[cfn] or scriptFiles[cbn] if filename then - Spring.Log(section, LOG.INFO, " Loading unit script: " .. filename) + SpringShared.Log(section, LOG.INFO, " Loading unit script: " .. filename) LoadScript(unitDef.scriptName, filename) end end @@ -604,7 +604,7 @@ end -------------------------------------------------------------------------------- -local StartThread = Spring.UnitScript.StartThread +local StartThread = SpringSynced.UnitScript.StartThread local function Wrap_AimWeapon(unitID, callins) local AimWeapon = callins["AimWeapon"] @@ -824,7 +824,7 @@ function gadget:UnitCreated(unitID, unitDefID) end -- Register the callins with Spring. - Spring.UnitScript.CreateScript(unitID, callins) + SpringSynced.UnitScript.CreateScript(unitID, callins) -- Register (must be last: it shouldn't be done in case of error.) units[unitID] = { diff --git a/luarules/gadgets/unit_seismic_ping.lua b/luarules/gadgets/unit_seismic_ping.lua index 0c40c0c398b..0e3a745c4b8 100644 --- a/luarules/gadgets/unit_seismic_ping.lua +++ b/luarules/gadgets/unit_seismic_ping.lua @@ -18,10 +18,10 @@ end -------------------------------------------------------------------------------- -- Speedups -------------------------------------------------------------------------------- -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local spGetMyAllyTeamID = Spring.GetMyAllyTeamID -local spGetGroundHeight = Spring.GetGroundHeight -local spGetViewGeometry = Spring.GetViewGeometry +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local glColor = gl.Color local glPushMatrix = gl.PushMatrix @@ -336,7 +336,7 @@ end function gadget:UnitSeismicPing(x, y, z, strength, allyTeam, unitID, unitDefID) local spec, fullview = spGetSpectatingState() local myAllyTeam = spGetMyAllyTeamID() - local unitAllyTeam = Spring.GetUnitAllyTeam(unitID) + local unitAllyTeam = SpringShared.GetUnitAllyTeam(unitID) if (spec or allyTeam == myAllyTeam) and unitAllyTeam ~= allyTeam then if spec and not fullview then @@ -360,15 +360,15 @@ function gadget:Update(dt) end function gadget:DrawWorld() - if #pings == 0 or Spring.IsGUIHidden() then + if #pings == 0 or SpringUnsynced.IsGUIHidden() then return end glDepthTest(false) -- Get visible world bounds for culling - local cx, cy, cz = Spring.GetCameraPosition() - local cs = Spring.GetCameraState() + local cx, cy, cz = SpringUnsynced.GetCameraPosition() + local cs = SpringUnsynced.GetCameraState() local vsx, vsy = spGetViewGeometry() -- Calculate visible world area based on camera state diff --git a/luarules/gadgets/unit_shield_behaviour.lua b/luarules/gadgets/unit_shield_behaviour.lua index 61b68aedcf5..0c4796acb0d 100644 --- a/luarules/gadgets/unit_shield_behaviour.lua +++ b/luarules/gadgets/unit_shield_behaviour.lua @@ -22,8 +22,8 @@ local pairs = pairs local next = next local ipairs = ipairs -local spGetUnitShieldState = Spring.GetUnitShieldState -local spSetUnitShieldState = Spring.SetUnitShieldState +local spGetUnitShieldState = SpringShared.GetUnitShieldState +local spSetUnitShieldState = SpringSynced.SetUnitShieldState local SHIELDSTATE_DISABLED = 0 local SHIELDSTATE_ENABLED = 1 @@ -35,7 +35,7 @@ local scriptedShieldDamages = {} -- Some modoptions require engine shield behaviors (namely their bounce/repulsion effects): -if Spring.GetModOptions().experimentalshields:find("bounce") then +if SpringShared.GetModOptions().experimentalshields:find("bounce") then for weaponDefID = 0, #WeaponDefs do local weaponDef = WeaponDefs[weaponDefID] originalShieldDamages[weaponDefID] = weaponDef.damages and weaponDef.damages[armorTypeShields] or 0 @@ -120,19 +120,19 @@ local INLOS = { inlos = true } local mathCeil = math.ceil -local spSetUnitShieldRechargeDelay = Spring.SetUnitShieldRechargeDelay -local spDeleteProjectile = Spring.DeleteProjectile -local spGetProjectileDefID = Spring.GetProjectileDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitWeaponVectors = Spring.GetUnitWeaponVectors -local spGetUnitsInSphere = Spring.GetUnitsInSphere -local spGetProjectilesInSphere = Spring.GetProjectilesInSphere -local spAreTeamsAllied = Spring.AreTeamsAllied -local spGetUnitIsActive = Spring.GetUnitIsActive -local spGetUnitIsDead = Spring.GetUnitIsDead -local spUseUnitResource = Spring.UseUnitResource -local spSetUnitRulesParam = Spring.SetUnitRulesParam -local spGetUnitArmored = Spring.GetUnitArmored +local spSetUnitShieldRechargeDelay = SpringSynced.SetUnitShieldRechargeDelay +local spDeleteProjectile = SpringSynced.DeleteProjectile +local spGetProjectileDefID = SpringShared.GetProjectileDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitWeaponVectors = SpringShared.GetUnitWeaponVectors +local spGetUnitsInSphere = SpringShared.GetUnitsInSphere +local spGetProjectilesInSphere = SpringShared.GetProjectilesInSphere +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spGetUnitIsActive = SpringShared.GetUnitIsActive +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spUseUnitResource = SpringSynced.UseUnitResource +local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam +local spGetUnitArmored = SpringShared.GetUnitArmored local shieldUnitDefs = {} local shieldUnitsData = {} @@ -755,9 +755,9 @@ function gadget:Initialize() GG.Shields.GetUnitShieldState = getUnitShieldState GG.Shields.RegisterShieldPreDamaged = registerShieldPreDamaged - for _, unitID in ipairs(Spring.GetAllUnits()) do - local unitDefID = Spring.GetUnitDefID(unitID) - local unitTeam = Spring.GetUnitTeam(unitID) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + local unitDefID = SpringShared.GetUnitDefID(unitID) + local unitTeam = SpringShared.GetUnitTeam(unitID) gadget:UnitFinished(unitID, unitDefID, unitTeam) end end diff --git a/luarules/gadgets/unit_sinking_ship.lua b/luarules/gadgets/unit_sinking_ship.lua index 4bfd8a0f2ee..7a3daa5acbe 100644 --- a/luarules/gadgets/unit_sinking_ship.lua +++ b/luarules/gadgets/unit_sinking_ship.lua @@ -18,12 +18,12 @@ end local damping = 0.1 -local spGetFeaturePosition = Spring.GetFeaturePosition -local spGetGroundHeight = Spring.GetGroundHeight -local spGetFeatureVelocity = Spring.GetFeatureVelocity -local spGetFeatureRotation = Spring.GetFeatureRotation -local spSetFeaturePhysics = Spring.SetFeaturePhysics -local spGetGameFrame = Spring.GetGameFrame +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetFeatureVelocity = SpringShared.GetFeatureVelocity +local spGetFeatureRotation = SpringShared.GetFeatureRotation +local spSetFeaturePhysics = SpringSynced.SetFeaturePhysics +local spGetGameFrame = SpringShared.GetGameFrame function gadget:FeatureCreated(featureID) if spGetGameFrame() < 1 then diff --git a/luarules/gadgets/unit_stack_hack_fix.lua b/luarules/gadgets/unit_stack_hack_fix.lua index 80faf3c11c1..8c243bb21b3 100644 --- a/luarules/gadgets/unit_stack_hack_fix.lua +++ b/luarules/gadgets/unit_stack_hack_fix.lua @@ -56,12 +56,12 @@ function gadget:GameFrame(n) for i = 1, #affectedUnits do local unitID = affectedUnits[i][1] local unitDefID = affectedUnits[i][2] - local nearestAlly = Spring.GetUnitNearestAlly(unitID, isAffectedUnit[unitDefID][1]) + local nearestAlly = SpringShared.GetUnitNearestAlly(unitID, isAffectedUnit[unitDefID][1]) if nearestAlly then - if not canMove[Spring.GetUnitDefID(nearestAlly)] then - if not Spring.GetUnitTransporter(unitID) then - local x, _, z = Spring.GetUnitPosition(unitID) - local ax, _, az = Spring.GetUnitPosition(nearestAlly) + if not canMove[SpringShared.GetUnitDefID(nearestAlly)] then + if not SpringShared.GetUnitTransporter(unitID) then + local x, _, z = SpringShared.GetUnitPosition(unitID) + local ax, _, az = SpringShared.GetUnitPosition(nearestAlly) local r = math.random(1, 3) local movementTargetX = 0 local movementTargetZ = 0 @@ -87,7 +87,7 @@ function gadget:GameFrame(n) movementTargetZ = -math.random(1, 10) end end - local movementTargetY = Spring.GetGroundHeight(x + movementTargetX, z + movementTargetZ) + local movementTargetY = SpringShared.GetGroundHeight(x + movementTargetX, z + movementTargetZ) local aboveMinWaterDepth = -isAffectedUnit[unitDefID][2] > movementTargetY local belowMaxWaterDepth = -isAffectedUnit[unitDefID][3] < movementTargetY @@ -99,7 +99,7 @@ function gadget:GameFrame(n) end if aboveMinWaterDepth and belowMaxWaterDepth and onMap then - Spring.SetUnitPosition(unitID, x + movementTargetX, z + movementTargetZ) + SpringSynced.SetUnitPosition(unitID, x + movementTargetX, z + movementTargetZ) end end end diff --git a/luarules/gadgets/unit_stealthy_passengers.lua b/luarules/gadgets/unit_stealthy_passengers.lua index 00863398e16..376ee80a9f8 100644 --- a/luarules/gadgets/unit_stealthy_passengers.lua +++ b/luarules/gadgets/unit_stealthy_passengers.lua @@ -17,8 +17,8 @@ if not gadgetHandler:IsSyncedCode() then return false end -local spGetUnitDefID = Spring.GetUnitDefID -local spSetUnitStealth = Spring.SetUnitStealth +local spGetUnitDefID = SpringShared.GetUnitDefID +local spSetUnitStealth = SpringSynced.SetUnitStealth local stringFind = string.find local stealthyUnits = {} diff --git a/luarules/gadgets/unit_stockpile_limit.lua b/luarules/gadgets/unit_stockpile_limit.lua index 3b43aa4e98f..df050f29d7e 100644 --- a/luarules/gadgets/unit_stockpile_limit.lua +++ b/luarules/gadgets/unit_stockpile_limit.lua @@ -22,8 +22,8 @@ if gadgetHandler:IsSyncedCode() then local StockpileDesiredTarget = {} local unitStockpileLimit = {} - local GetUnitStockpile = Spring.GetUnitStockpile - local GiveOrderToUnit = Spring.GiveOrderToUnit + local GetUnitStockpile = SpringShared.GetUnitStockpile + local GiveOrderToUnit = SpringSynced.GiveOrderToUnit local mathClamp = math.clamp for udid, ud in pairs(UnitDefs) do @@ -133,9 +133,9 @@ if gadgetHandler:IsSyncedCode() then function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD_STOCKPILE) - local units = Spring.GetAllUnits() + local units = SpringShared.GetAllUnits() for i = 1, #units do - local unitDefID = Spring.GetUnitDefID(units[i]) + local unitDefID = SpringShared.GetUnitDefID(units[i]) gadget:UnitCreated(units[i], unitDefID) end end diff --git a/luarules/gadgets/unit_stockpile_script.lua b/luarules/gadgets/unit_stockpile_script.lua index d2cab671d32..e4b3db8864d 100644 --- a/luarules/gadgets/unit_stockpile_script.lua +++ b/luarules/gadgets/unit_stockpile_script.lua @@ -24,14 +24,14 @@ for udid, ud in pairs(UnitDefs) do end end -local spGetUnitStockpile = Spring.GetUnitStockpile -local spCallCOBScript = Spring.CallCOBScript -local spGetCOBScriptID = Spring.GetCOBScriptID +local spGetUnitStockpile = SpringShared.GetUnitStockpile +local spCallCOBScript = SpringSynced.CallCOBScript +local spGetCOBScriptID = SpringSynced.GetCOBScriptID function gadget:Initialize() - for i, unitID in pairs(Spring.GetAllUnits()) do - gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID)) - if hasSetStockpile[Spring.GetUnitDefID(unitID)] then + for i, unitID in pairs(SpringShared.GetAllUnits()) do + gadget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID)) + if hasSetStockpile[SpringShared.GetUnitDefID(unitID)] then spCallCOBScript(unitID, "SetStockpile", 0, spGetUnitStockpile(unitID)) end end diff --git a/luarules/gadgets/unit_stomp.lua b/luarules/gadgets/unit_stomp.lua index 2e42a779f22..7db3dd6e8dd 100644 --- a/luarules/gadgets/unit_stomp.lua +++ b/luarules/gadgets/unit_stomp.lua @@ -45,7 +45,7 @@ end function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam) if krogkickWeapon[weaponDefID] then if unitTeam and attackerTeam then - if Spring.AreTeamsAllied(unitTeam, attackerTeam) == false then + if SpringShared.AreTeamsAllied(unitTeam, attackerTeam) == false then if stompableDefs[unitDefID] then return 2000, 0 else diff --git a/luarules/gadgets/unit_stun_control.lua b/luarules/gadgets/unit_stun_control.lua index cafb191c8ab..d1104183de8 100644 --- a/luarules/gadgets/unit_stun_control.lua +++ b/luarules/gadgets/unit_stun_control.lua @@ -33,7 +33,7 @@ end function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions, cmdTag, playerID, fromSynced, fromLua) -- accepts: CMD.ONOFF - if Spring.GetUnitIsStunned(unitID) then + if SpringShared.GetUnitIsStunned(unitID) then return false else return true diff --git a/luarules/gadgets/unit_stun_script.lua b/luarules/gadgets/unit_stun_script.lua index 630d3e921c2..39f127aed0e 100644 --- a/luarules/gadgets/unit_stun_script.lua +++ b/luarules/gadgets/unit_stun_script.lua @@ -26,9 +26,9 @@ for udid, ud in pairs(UnitDefs) do end end -local spGetUnitIsStunned = Spring.GetUnitIsStunned -local spCallCOBScript = Spring.CallCOBScript -local spGetCOBScriptID = Spring.GetCOBScriptID +local spGetUnitIsStunned = SpringShared.GetUnitIsStunned +local spCallCOBScript = SpringSynced.CallCOBScript +local spGetCOBScriptID = SpringSynced.GetCOBScriptID function gadget:GameFrame(n) -- check if stunned units have become deparalyzed @@ -43,8 +43,8 @@ function gadget:GameFrame(n) end function gadget:Initialize() - for i, unitID in pairs(Spring.GetAllUnits()) do - gadget:UnitCreated(unitID, Spring.GetUnitDefID(unitID)) + for i, unitID in pairs(SpringShared.GetAllUnits()) do + gadget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID)) end end diff --git a/luarules/gadgets/unit_stun_storage.lua b/luarules/gadgets/unit_stun_storage.lua index 1724561447b..bab3b8d8f3d 100644 --- a/luarules/gadgets/unit_stun_storage.lua +++ b/luarules/gadgets/unit_stun_storage.lua @@ -16,8 +16,8 @@ if not gadgetHandler:IsSyncedCode() then return false end -local spGetTeamResources = Spring.GetTeamResources -local spSetTeamResource = Spring.SetTeamResource +local spGetTeamResources = SpringShared.GetTeamResources +local spSetTeamResource = SpringSynced.SetTeamResource local paralyzedUnits = {} @@ -107,7 +107,7 @@ function gadget:UnitStunned(unitID, unitDefID, teamID, stunned) if stunned then if not paralyzedUnits[unitID] then - local beingBuilt, _ = Spring.GetUnitIsBeingBuilt(unitID) + local beingBuilt, _ = SpringShared.GetUnitIsBeingBuilt(unitID) if not beingBuilt then reduceStorage(unitID, unitDefID, teamID) end @@ -132,7 +132,7 @@ end function gadget:UnitFinished(unitID, unitDefID, unitTeam) if storageDefs[unitDefID] then - local _, maxHealth, paralyzeDamage, _, _ = Spring.GetUnitHealth(unitID) + local _, maxHealth, paralyzeDamage, _, _ = SpringShared.GetUnitHealth(unitID) if paralyzeDamage > maxHealth then reduceStorage(unitID, unitDefID, unitTeam) end @@ -146,29 +146,29 @@ function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerD end function gadget:Initialize() - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() if #allUnits == 0 then return end - local spGetUnitIsStunned = Spring.GetUnitIsStunned + local spGetUnitIsStunned = SpringShared.GetUnitIsStunned for i = 1, #allUnits do local unitID = allUnits[i] - if select(5, Spring.GetUnitHealth(unitID)) == 1 then - local unitDefID = Spring.GetUnitDefID(unitID) + if select(5, SpringShared.GetUnitHealth(unitID)) == 1 then + local unitDefID = SpringShared.GetUnitDefID(unitID) if storageDefs[unitDefID] and spGetUnitIsStunned(unitID) then - reduceStorage(unitID, unitDefID, Spring.GetUnitTeam(unitID)) + reduceStorage(unitID, unitDefID, SpringShared.GetUnitTeam(unitID)) end end end end function gadget:Shutdown() - local spGetUnitIsStunned = Spring.GetUnitIsStunned + local spGetUnitIsStunned = SpringShared.GetUnitIsStunned for unitID, unitDefID in pairs(paralyzedUnits) do if spGetUnitIsStunned(unitID) then - restoreStorage(unitID, unitDefID, Spring.GetUnitTeam(unitID)) + restoreStorage(unitID, unitDefID, SpringShared.GetUnitTeam(unitID)) end end end diff --git a/luarules/gadgets/unit_sunfacing.lua b/luarules/gadgets/unit_sunfacing.lua index b828cbe1231..deee42de14b 100644 --- a/luarules/gadgets/unit_sunfacing.lua +++ b/luarules/gadgets/unit_sunfacing.lua @@ -16,7 +16,7 @@ if not gadgetHandler:IsSyncedCode() then return false end -local spCallCOBScript = Spring.CallCOBScript +local spCallCOBScript = SpringSynced.CallCOBScript local mathAtan2 = math.atan2 local mathDeg = math.deg local mathTau = math.tau diff --git a/luarules/gadgets/unit_target_on_the_move.lua b/luarules/gadgets/unit_target_on_the_move.lua index e4778a2e74d..c15453ac6a4 100644 --- a/luarules/gadgets/unit_target_on_the_move.lua +++ b/luarules/gadgets/unit_target_on_the_move.lua @@ -19,7 +19,7 @@ local CMD_UNIT_SET_TARGET_RECTANGLE = GameCMD.UNIT_SET_TARGET_RECTANGLE local deleteMaxDistance = 30 -local spGetUnitRulesParam = Spring.GetUnitRulesParam +local spGetUnitRulesParam = SpringShared.GetUnitRulesParam function GG.GetUnitTarget(unitID) local targetID = spGetUnitRulesParam(unitID, "targetID") @@ -41,27 +41,27 @@ if gadgetHandler:IsSyncedCode() then -- Should be small enough to not be evident, and big enough to save perf. local USEEN_UPDATE_FREQUENCY = 15 - local spInsertUnitCmdDesc = Spring.InsertUnitCmdDesc - local spGetUnitAllyTeam = Spring.GetUnitAllyTeam - local spSetUnitTarget = Spring.SetUnitTarget - local spValidUnitID = Spring.ValidUnitID - local spGetUnitDefID = Spring.GetUnitDefID - local spGetUnitLosState = Spring.GetUnitLosState - local spGetUnitTeam = Spring.GetUnitTeam - local spAreTeamsAllied = Spring.AreTeamsAllied - local spGetUnitsInRectangle = Spring.GetUnitsInRectangle - local spGetUnitsInCylinder = Spring.GetUnitsInCylinder - local spSetUnitRulesParam = Spring.SetUnitRulesParam - local spGetUnitCommandCount = Spring.GetUnitCommandCount - local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand - local spGiveOrderArrayToUnit = Spring.GiveOrderArrayToUnit - local spGetUnitWeaponTryTarget = Spring.GetUnitWeaponTryTarget - local spGetUnitWeaponTestTarget = Spring.GetUnitWeaponTestTarget - local spGetUnitWeaponTestRange = Spring.GetUnitWeaponTestRange - local spGetUnitWeaponHaveFreeLineOfFire = Spring.GetUnitWeaponHaveFreeLineOfFire - local spGetGroundHeight = Spring.GetGroundHeight - local spGetAllUnits = Spring.GetAllUnits - local spGetPlayerInfo = Spring.GetPlayerInfo + local spInsertUnitCmdDesc = SpringSynced.InsertUnitCmdDesc + local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam + local spSetUnitTarget = SpringSynced.SetUnitTarget + local spValidUnitID = SpringShared.ValidUnitID + local spGetUnitDefID = SpringShared.GetUnitDefID + local spGetUnitLosState = SpringShared.GetUnitLosState + local spGetUnitTeam = SpringShared.GetUnitTeam + local spAreTeamsAllied = SpringShared.AreTeamsAllied + local spGetUnitsInRectangle = SpringShared.GetUnitsInRectangle + local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder + local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam + local spGetUnitCommandCount = SpringShared.GetUnitCommandCount + local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand + local spGiveOrderArrayToUnit = SpringSynced.GiveOrderArrayToUnit + local spGetUnitWeaponTryTarget = SpringShared.GetUnitWeaponTryTarget + local spGetUnitWeaponTestTarget = SpringShared.GetUnitWeaponTestTarget + local spGetUnitWeaponTestRange = SpringShared.GetUnitWeaponTestRange + local spGetUnitWeaponHaveFreeLineOfFire = SpringShared.GetUnitWeaponHaveFreeLineOfFire + local spGetGroundHeight = SpringShared.GetGroundHeight + local spGetAllUnits = SpringShared.GetAllUnits + local spGetPlayerInfo = SpringShared.GetPlayerInfo local tremove = table.remove @@ -175,7 +175,7 @@ if gadgetHandler:IsSyncedCode() then if currentCmdID and currentCmdID == CMD.ATTACK then return false else - Spring.SetUnitTarget(unitID, nil) + SpringSynced.SetUnitTarget(unitID, nil) return false end end @@ -611,7 +611,7 @@ if gadgetHandler:IsSyncedCode() then end end local function unpauseTargetting(unitID) - addUnitTargets(unitID, Spring.GetUnitDefID(unitID), pausedTargets[unitID].targets, true, "unpauseTargetting") + addUnitTargets(unitID, SpringShared.GetUnitDefID(unitID), pausedTargets[unitID].targets, true, "unpauseTargetting") pausedTargets[unitID] = nil end @@ -763,19 +763,19 @@ else -- UNSYNCED local GL_LINE_STRIP = GL.LINE_STRIP local GL_LINES = GL.LINES - local spGetUnitPosition = Spring.GetUnitPosition - local spValidUnitID = Spring.ValidUnitID + local spGetUnitPosition = SpringShared.GetUnitPosition + local spValidUnitID = SpringShared.ValidUnitID local spGetMyAllyTeamID = Spring.GetMyAllyTeamID local spGetMyTeamID = Spring.GetMyTeamID - local spIsUnitSelected = Spring.IsUnitSelected - local spGetSpectatingState = Spring.GetSpectatingState - local spGetUnitAllyTeam = Spring.GetUnitAllyTeam - local spGetUnitTeam = Spring.GetUnitTeam - local spPlaySoundFile = Spring.PlaySoundFile - local spSetActiveCommand = Spring.SetActiveCommand - local spAssignMouseCursor = Spring.AssignMouseCursor - local spSetCustomCommandDrawData = Spring.SetCustomCommandDrawData - local spAddWorldIcon = Spring.AddWorldIcon + local spIsUnitSelected = SpringUnsynced.IsUnitSelected + local spGetSpectatingState = SpringUnsynced.GetSpectatingState + local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam + local spGetUnitTeam = SpringShared.GetUnitTeam + local spPlaySoundFile = SpringUnsynced.PlaySoundFile + local spSetActiveCommand = SpringUnsynced.SetActiveCommand + local spAssignMouseCursor = SpringUnsynced.AssignMouseCursor + local spSetCustomCommandDrawData = SpringUnsynced.SetCustomCommandDrawData + local spAddWorldIcon = SpringUnsynced.AddWorldIcon local pairsNext = next local myAllyTeam = spGetMyAllyTeamID() @@ -979,7 +979,7 @@ else -- UNSYNCED end function gadget:DrawWorld() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end diff --git a/luarules/gadgets/unit_timeslow.lua b/luarules/gadgets/unit_timeslow.lua index 7580b50f5f6..fd13d749fa0 100644 --- a/luarules/gadgets/unit_timeslow.lua +++ b/luarules/gadgets/unit_timeslow.lua @@ -1,5 +1,5 @@ -if not Spring.GetModOptions().emprework then +if not SpringShared.GetModOptions().emprework then return end @@ -21,13 +21,13 @@ if not gadgetHandler:IsSyncedCode() then return end -local spValidUnitID = Spring.ValidUnitID -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitHealth = Spring.GetUnitHealth -local spSetUnitRulesParam = Spring.SetUnitRulesParam -local spGetUnitTeam = Spring.GetUnitTeam -local spSetUnitTarget = Spring.SetUnitTarget -local spGetUnitNearestEnemy = Spring.GetUnitNearestEnemy +local spValidUnitID = SpringShared.ValidUnitID +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitHealth = SpringShared.GetUnitHealth +local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam +local spGetUnitTeam = SpringShared.GetUnitTeam +local spSetUnitTarget = SpringSynced.SetUnitTarget +local spGetUnitNearestEnemy = SpringShared.GetUnitNearestEnemy local CMD_ATTACK = CMD.ATTACK local CMD_REMOVE = CMD.REMOVE @@ -36,12 +36,12 @@ local CMD_FIGHT = CMD.FIGHT local CMD_SET_WANTED_MAX_SPEED = CMD.SET_WANTED_MAX_SPEED local LOS_ACCESS = { inlos = true } -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() local attritionWeaponDefs, MAX_SLOW_FACTOR, DEGRADE_TIMER, DEGRADE_FACTOR, UPDATE_PERIOD = include("LuaRules/Configs/timeslow_defs.lua") local slowedUnits = {} -Spring.SetGameRulesParam("slowState", 1) +SpringSynced.SetGameRulesParam("slowState", 1) local function updateSlow(unitID, state) --Spring.Echo("hornet upd slow unit id " .. unitID .. " state.slowDamage " .. state.slowDamage)-- .. " max slow factor " .. MAX_SLOW_FACTOR) diff --git a/luarules/gadgets/unit_tombstones.lua b/luarules/gadgets/unit_tombstones.lua index 0b7baff11e8..1a227c4da24 100644 --- a/luarules/gadgets/unit_tombstones.lua +++ b/luarules/gadgets/unit_tombstones.lua @@ -32,16 +32,16 @@ end function gadget:UnitDestroyed(unitID, unitDefID, teamID, attackerID, attackerDefID, attackerTeamID) if isCommander[unitDefID] then - local px, py, pz = Spring.GetUnitPosition(unitID) + local px, py, pz = SpringShared.GetUnitPosition(unitID) pz = pz - 40 - if not Spring.GetUnitRulesParam(unitID, "unit_evolved") then - local tombstoneID = Spring.CreateFeature(isCommander[unitDefID], px, Spring.GetGroundHeight(px, pz), pz, 0, teamID) + if not SpringShared.GetUnitRulesParam(unitID, "unit_evolved") then + local tombstoneID = SpringSynced.CreateFeature(isCommander[unitDefID], px, SpringShared.GetGroundHeight(px, pz), pz, 0, teamID) if tombstoneID then - local rx, ry, rz = Spring.GetFeatureRotation(tombstoneID) + local rx, ry, rz = SpringShared.GetFeatureRotation(tombstoneID) rx = rx + 0.18 + (math.random(0, 6) / 50) rz = rz - 0.12 + (math.random(0, 12) / 50) ry = ry - 0.12 + (math.random(0, 12) / 50) - Spring.SetFeatureRotation(tombstoneID, rx, ry, rz) + SpringSynced.SetFeatureRotation(tombstoneID, rx, ry, rz) end end end diff --git a/luarules/gadgets/unit_transport_dies_load_dies.lua b/luarules/gadgets/unit_transport_dies_load_dies.lua index a441fa2241c..c1ece0739f4 100644 --- a/luarules/gadgets/unit_transport_dies_load_dies.lua +++ b/luarules/gadgets/unit_transport_dies_load_dies.lua @@ -54,10 +54,10 @@ function gadget:UnitUnloaded(unitID, unitDefID, teamID, transportID) if not isParatrooper[unitDefID] then --don't destroy units with effigies. Spring.SetUnitPosition cannot move a unit mid-fall. - if Spring.GetUnitRulesParam(unitID, "unit_effigy") then + if SpringShared.GetUnitRulesParam(unitID, "unit_effigy") then return end - currentFrame = Spring.GetGameFrame() + currentFrame = SpringShared.GetGameFrame() if not toKill[currentFrame + 1] then toKill[currentFrame + 1] = {} end @@ -69,7 +69,7 @@ function gadget:UnitUnloaded(unitID, unitDefID, teamID, transportID) --Spring.Echo("added killing request for " .. unitID .. " on frame " .. currentFrame+1 .. " from transport " .. transportID ) else --commandos are given a move order to the location of the ground below where the transport died; remove it - Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) end end @@ -79,16 +79,16 @@ function gadget:GameFrame(currentFrame) local tID = fromtrans[currentFrame][uID] --Spring.Echo ("delayed killing check called for unit " .. uID .. " and trans " .. tID .. ". ") --check that trans is dead/crashing and unit is still alive - if not Spring.GetUnitIsDead(uID) and (Spring.GetUnitIsDead(tID) or (Spring.GetUnitMoveTypeData(tID).aircraftState == "crashing")) then + if not SpringShared.GetUnitIsDead(uID) and (SpringShared.GetUnitIsDead(tID) or (SpringShared.GetUnitMoveTypeData(tID).aircraftState == "crashing")) then --Spring.Echo("killing unit " .. uID)= - local deathExplosion = UnitDefs[Spring.GetUnitDefID(uID)].deathExplosion + local deathExplosion = UnitDefs[SpringShared.GetUnitDefID(uID)].deathExplosion if deathExplosion and WeaponDefNames[deathExplosion].id and WeaponDefs[WeaponDefNames[deathExplosion].id] then local tabledamages = WeaponDefs[WeaponDefNames[deathExplosion].id] - Spring.SetUnitWeaponDamages(uID, "selfDestruct", tabledamages) + SpringSynced.SetUnitWeaponDamages(uID, "selfDestruct", tabledamages) tabledamages = WeaponDefs[WeaponDefNames[deathExplosion].id].damages - Spring.SetUnitWeaponDamages(uID, "selfDestruct", tabledamages) + SpringSynced.SetUnitWeaponDamages(uID, "selfDestruct", tabledamages) end - Spring.DestroyUnit(uID, true, false) + SpringSynced.DestroyUnit(uID, true, false) end end toKill[currentFrame] = nil diff --git a/luarules/gadgets/unit_transportable_nanos.lua b/luarules/gadgets/unit_transportable_nanos.lua index 3b5aa664748..46c8525517f 100644 --- a/luarules/gadgets/unit_transportable_nanos.lua +++ b/luarules/gadgets/unit_transportable_nanos.lua @@ -16,11 +16,11 @@ if not gadgetHandler:IsSyncedCode() then return false end -local GetUnitTeam = Spring.GetUnitTeam -local GetUnitDefID = Spring.GetUnitDefID -local GetGroundNormal = Spring.GetGroundNormal -local GetUnitIsTransporting = Spring.GetUnitIsTransporting -local ValidUnitID = Spring.ValidUnitID +local GetUnitTeam = SpringShared.GetUnitTeam +local GetUnitDefID = SpringShared.GetUnitDefID +local GetGroundNormal = SpringShared.GetGroundNormal +local GetUnitIsTransporting = SpringShared.GetUnitIsTransporting +local ValidUnitID = SpringShared.ValidUnitID local stringFind = string.find local CMD_LOAD_UNITS = CMD.LOAD_UNITS @@ -30,7 +30,7 @@ local Nanos = { [UnitDefNames.cornanotc.id] = true, [UnitDefNames.armnanotc.id] = true, } -if Spring.GetModOptions().experimentallegionfaction then +if SpringShared.GetModOptions().experimentallegionfaction then Nanos[UnitDefNames.legnanotc.id] = true end for udid, ud in pairs(UnitDefs) do diff --git a/luarules/gadgets/unit_transported_building_ghost.lua b/luarules/gadgets/unit_transported_building_ghost.lua index 26831810559..bff44a26eb5 100644 --- a/luarules/gadgets/unit_transported_building_ghost.lua +++ b/luarules/gadgets/unit_transported_building_ghost.lua @@ -12,7 +12,7 @@ function gadget:GetInfo() } end -spSetUnitLeavesGhost = Spring.SetUnitLeavesGhost +spSetUnitLeavesGhost = SpringSynced.SetUnitLeavesGhost if not gadgetHandler:IsSyncedCode() then return diff --git a/luarules/gadgets/unit_transportee_hider.lua b/luarules/gadgets/unit_transportee_hider.lua index d9923d7d108..826b7d4b7c3 100644 --- a/luarules/gadgets/unit_transportee_hider.lua +++ b/luarules/gadgets/unit_transportee_hider.lua @@ -16,13 +16,13 @@ if not gadgetHandler:IsSyncedCode() then return end -local SetUnitNoDraw = Spring.SetUnitNoDraw -local SetUnitStealth = Spring.SetUnitStealth -local SetUnitSonarStealth = Spring.SetUnitSonarStealth -local GetUnitDefID = Spring.GetUnitDefID -local GiveOrderToUnit = Spring.GiveOrderToUnit -local GetAllUnits = Spring.GetAllUnits -local GetUnitTeam = Spring.GetUnitTeam +local SetUnitNoDraw = SpringUnsynced.SetUnitNoDraw +local SetUnitStealth = SpringSynced.SetUnitStealth +local SetUnitSonarStealth = SpringSynced.SetUnitSonarStealth +local GetUnitDefID = SpringShared.GetUnitDefID +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit +local GetAllUnits = SpringShared.GetAllUnits +local GetUnitTeam = SpringShared.GetUnitTeam local CMD_LOAD_ONTO = CMD.LOAD_ONTO local CMD_STOP = CMD.STOP diff --git a/luarules/gadgets/unit_transports_air_speed.lua b/luarules/gadgets/unit_transports_air_speed.lua index e6e07dc50ea..39859adc7b0 100644 --- a/luarules/gadgets/unit_transports_air_speed.lua +++ b/luarules/gadgets/unit_transports_air_speed.lua @@ -39,10 +39,10 @@ local massUsageFraction = 0 local allowedSpeed = 0 local currentMassUsage = 0 -local spGetUnitVelocity = Spring.GetUnitVelocity -local spSetUnitVelocity = Spring.SetUnitVelocity -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitIsTransporting = Spring.GetUnitIsTransporting +local spGetUnitVelocity = SpringShared.GetUnitVelocity +local spSetUnitVelocity = SpringSynced.SetUnitVelocity +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitIsTransporting = SpringShared.GetUnitIsTransporting -- update allowed speed for transport local function updateAllowedSpeed(transportId) diff --git a/luarules/gadgets/unit_turretspeed.lua b/luarules/gadgets/unit_turretspeed.lua index f782c5104d9..4dadd0dd7a8 100644 --- a/luarules/gadgets/unit_turretspeed.lua +++ b/luarules/gadgets/unit_turretspeed.lua @@ -46,9 +46,9 @@ if not gadgetHandler:IsSyncedCode() then return end -local spGetAllUnits = Spring.GetAllUnits -local spGetUnitDefID = Spring.GetUnitDefID -local spCallCOBScript = Spring.CallCOBScript +local spGetAllUnits = SpringShared.GetAllUnits +local spGetUnitDefID = SpringShared.GetUnitDefID +local spCallCOBScript = SpringSynced.CallCOBScript local stringFind = string.find local stringLower = string.lower diff --git a/luarules/gadgets/unit_wanted_speed.lua b/luarules/gadgets/unit_wanted_speed.lua index ee8382fc8df..c6ad7e8ca78 100644 --- a/luarules/gadgets/unit_wanted_speed.lua +++ b/luarules/gadgets/unit_wanted_speed.lua @@ -1,5 +1,5 @@ -if not Spring.GetModOptions().emprework then +if not SpringShared.GetModOptions().emprework then return end @@ -105,7 +105,7 @@ local function SetUnitWantedSpeed(unitID, unitDefID, wantedSpeed, forceUpdate) return end - if Spring.MoveCtrl.GetTag(unitID) then + if SpringSynced.MoveCtrl.GetTag(unitID) then units[unitID].lastWantedSpeed = wantedSpeed return end @@ -117,9 +117,9 @@ local function SetUnitWantedSpeed(unitID, unitDefID, wantedSpeed, forceUpdate) --Spring.Utilities.UnitEcho(unitID, wantedSpeed or "f") if units[unitID].moveType == 1 then - Spring.MoveCtrl.SetGunshipMoveTypeData(unitID, "maxWantedSpeed", (wantedSpeed or 2000)) + SpringSynced.MoveCtrl.SetGunshipMoveTypeData(unitID, "maxWantedSpeed", (wantedSpeed or 2000)) elseif units[unitID].moveType == 2 then - Spring.MoveCtrl.SetGroundMoveTypeData(unitID, "maxWantedSpeed", (wantedSpeed or 2000)) + SpringSynced.MoveCtrl.SetGroundMoveTypeData(unitID, "maxWantedSpeed", (wantedSpeed or 2000)) end end @@ -133,14 +133,14 @@ local function MaintainWantedSpeed(unitID) return end - if Spring.MoveCtrl.GetTag(unitID) then + if SpringSynced.MoveCtrl.GetTag(unitID) then return end if units[unitID].moveType == 1 then - Spring.MoveCtrl.SetGunshipMoveTypeData(unitID, "maxWantedSpeed", units[unitID].lastWantedSpeed) + SpringSynced.MoveCtrl.SetGunshipMoveTypeData(unitID, "maxWantedSpeed", units[unitID].lastWantedSpeed) elseif units[unitID].moveType == 2 then - Spring.MoveCtrl.SetGroundMoveTypeData(unitID, "maxWantedSpeed", units[unitID].lastWantedSpeed) + SpringSynced.MoveCtrl.SetGroundMoveTypeData(unitID, "maxWantedSpeed", units[unitID].lastWantedSpeed) end end diff --git a/luarules/gadgets/unit_water_depth_damage.lua b/luarules/gadgets/unit_water_depth_damage.lua index c2f33d6646e..9f3bb61364d 100644 --- a/luarules/gadgets/unit_water_depth_damage.lua +++ b/luarules/gadgets/unit_water_depth_damage.lua @@ -36,21 +36,21 @@ local fallDamageCompoundingFactor = 1.05 local gameFrame = 0 local gameFrameExpirationThreshold = 3 -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() local waterDamageDefID = Game.envDamageTypes.Water local gameSpeed = Game.gameSpeed -local spGetUnitIsDead = Spring.GetUnitIsDead -local spValidUnitID = Spring.ValidUnitID -local spAddUnitDamage = Spring.AddUnitDamage -local spGetUnitVelocity = Spring.GetUnitVelocity -local spGetUnitBasePosition = Spring.GetUnitBasePosition -local spGetUnitPosition = Spring.GetUnitPosition -local spSpawnCEG = Spring.SpawnCEG -local spPlaySoundFile = Spring.PlaySoundFile -local spTestMoveOrder = Spring.TestMoveOrder -local spGetUnitHealth = Spring.GetUnitHealth -local spDestroyUnit = Spring.DestroyUnit +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spValidUnitID = SpringShared.ValidUnitID +local spAddUnitDamage = SpringSynced.AddUnitDamage +local spGetUnitVelocity = SpringShared.GetUnitVelocity +local spGetUnitBasePosition = SpringShared.GetUnitBasePosition +local spGetUnitPosition = SpringShared.GetUnitPosition +local spSpawnCEG = SpringSynced.SpawnCEG +local spPlaySoundFile = SpringUnsynced.PlaySoundFile +local spTestMoveOrder = SpringShared.TestMoveOrder +local spGetUnitHealth = SpringShared.GetUnitHealth +local spDestroyUnit = SpringSynced.DestroyUnit local unitDefData = {} local transportDrops = {} diff --git a/luarules/gadgets/unit_waterspeedmultiplier.lua b/luarules/gadgets/unit_waterspeedmultiplier.lua index 924058eb7b0..4248049e556 100644 --- a/luarules/gadgets/unit_waterspeedmultiplier.lua +++ b/luarules/gadgets/unit_waterspeedmultiplier.lua @@ -33,11 +33,11 @@ local watchUpdateRate = 0.5000 ---@type number in seconds | slow watch interval local math_clamp = math.clamp -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetUnitPosition = Spring.GetUnitPosition -local spGetGroundHeight = Spring.GetGroundHeight -local spGetMoveTypeData = Spring.GetUnitMoveTypeData -local spSetGroundMoveTypeData = Spring.MoveCtrl.SetGroundMoveTypeData +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetMoveTypeData = SpringShared.GetUnitMoveTypeData +local spSetGroundMoveTypeData = SpringSynced.MoveCtrl.SetGroundMoveTypeData -- Setup @@ -221,7 +221,7 @@ function gadget:Initialize() end local unitFinished = gadget.UnitFinished - for _, unitID in ipairs(Spring.GetAllUnits()) do - unitFinished(gadget, unitID, Spring.GetUnitDefID(unitID), 0) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + unitFinished(gadget, unitID, SpringShared.GetUnitDefID(unitID), 0) end end diff --git a/luarules/gadgets/unit_weapon_smart_select_helper.lua b/luarules/gadgets/unit_weapon_smart_select_helper.lua index 67e51990f85..54a147a50ea 100644 --- a/luarules/gadgets/unit_weapon_smart_select_helper.lua +++ b/luarules/gadgets/unit_weapon_smart_select_helper.lua @@ -68,12 +68,12 @@ local GROUND_TARGET = 2 local gameFrame = 0 --functions -local spCallCOBScript = Spring.CallCOBScript -local spGetUnitWeaponHaveFreeLineOfFire = Spring.GetUnitWeaponHaveFreeLineOfFire -local spGetUnitWeaponTarget = Spring.GetUnitWeaponTarget -local spGetUnitWeaponState = Spring.GetUnitWeaponState -local spGetUnitEstimatedPath = Spring.GetUnitEstimatedPath -local spSetUnitTarget = Spring.SetUnitTarget +local spCallCOBScript = SpringSynced.CallCOBScript +local spGetUnitWeaponHaveFreeLineOfFire = SpringShared.GetUnitWeaponHaveFreeLineOfFire +local spGetUnitWeaponTarget = SpringShared.GetUnitWeaponTarget +local spGetUnitWeaponState = SpringShared.GetUnitWeaponState +local spGetUnitEstimatedPath = SpringShared.GetUnitEstimatedPath +local spSetUnitTarget = SpringSynced.SetUnitTarget local mathMin = math.min local mathMax = math.max @@ -82,9 +82,9 @@ local smartUnitDefs = {} local modeSwitchFrames = {} -- Add with other local function declarations -local spInsertUnitCmdDesc = Spring.InsertUnitCmdDesc -local spEditUnitCmdDesc = Spring.EditUnitCmdDesc -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc +local spInsertUnitCmdDesc = SpringSynced.InsertUnitCmdDesc +local spEditUnitCmdDesc = SpringSynced.EditUnitCmdDesc +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc local trajectoryCmdDesc = { id = CMD_SMART_TOGGLE, @@ -99,8 +99,8 @@ local defaultCmdDesc = table.copy(trajectoryCmdDesc) function gadget:Initialize() gadgetHandler:RegisterAllowCommand(CMD_SMART_TOGGLE) - local units = Spring.GetAllUnits() - local spGetUnitDefID = Spring.GetUnitDefID + local units = SpringShared.GetAllUnits() + local spGetUnitDefID = SpringShared.GetUnitDefID for i = 1, #units do gadget:UnitCreated(units[i], spGetUnitDefID(units[i])) end @@ -309,7 +309,7 @@ end function gadget:UnitCreated(unitID, unitDefID) if smartUnitDefs[unitDefID] then - local scriptID = Spring.GetCOBScriptID(unitID, "SetAimingState") + local scriptID = SpringSynced.GetCOBScriptID(unitID, "SetAimingState") if scriptID then smartUnits[unitID] = { unitDefID = unitDefID, diff --git a/luarules/gadgets/unit_windmill_control.lua b/luarules/gadgets/unit_windmill_control.lua index 46f0ebe1a00..919df68a696 100644 --- a/luarules/gadgets/unit_windmill_control.lua +++ b/luarules/gadgets/unit_windmill_control.lua @@ -18,7 +18,7 @@ end -- Only apply these when resource multipliers are active, to save performance local energyMultActive = false -if Spring.GetModOptions().multiplier_energyproduction * Spring.GetModOptions().multiplier_resourceincome ~= 1 then +if SpringShared.GetModOptions().multiplier_energyproduction * SpringShared.GetModOptions().multiplier_resourceincome ~= 1 then energyMultActive = true end @@ -38,15 +38,15 @@ end local windmills = {} -local GetCOBScriptID = Spring.GetCOBScriptID -local AddUnitResource = Spring.AddUnitResource -local GetUnitIsStunned = Spring.GetUnitIsStunned +local GetCOBScriptID = SpringSynced.GetCOBScriptID +local AddUnitResource = SpringSynced.AddUnitResource +local GetUnitIsStunned = SpringShared.GetUnitIsStunned --local CallCOBScript = Spring.CallCOBScript --local GetHeadingFromVector = Spring.GetHeadingFromVector function gadget:GameFrame(n) if (n + 15) % 30 < 0.1 then - local _, _, _, strength, x, _, z = Spring.GetWind() + local _, _, _, strength, x, _, z = SpringShared.GetWind() for unitID, scriptIDs in pairs(windmills) do if not GetUnitIsStunned(unitID) then AddUnitResource(unitID, "e", strength * (scriptIDs.mult - 1)) @@ -66,8 +66,8 @@ local function SetupUnit(unitID, unitDefID) end function gadget:Initialize() - for _, unitID in ipairs(Spring.GetAllUnits()) do - local unitDefID = Spring.GetUnitDefID(unitID) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + local unitDefID = SpringShared.GetUnitDefID(unitID) if windDefs[unitDefID] then SetupUnit(unitID, unitDefID) end diff --git a/luarules/gadgets/unit_workertime_boost.lua b/luarules/gadgets/unit_workertime_boost.lua index fd9358dcb76..262f29af84b 100644 --- a/luarules/gadgets/unit_workertime_boost.lua +++ b/luarules/gadgets/unit_workertime_boost.lua @@ -20,9 +20,9 @@ end -- workertimeboost = number -- in the unitdefs of the builder. This is the mulitplier by which workertime is boosted. -- wtboostunittype = "MOBILE TURRET" defined in unitdef of builder which defines what units trigger workertime boost for that builder. -local spGetUnitIsBuilding = Spring.GetUnitIsBuilding -local spGetUnitDefID = Spring.GetUnitDefID -local spSetUnitRulesParam = Spring.SetUnitRulesParam +local spGetUnitIsBuilding = SpringShared.GetUnitIsBuilding +local spGetUnitDefID = SpringShared.GetUnitDefID +local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam local boostableUnits = {} local builderWatchDefs = {} local builderWatch = {} @@ -77,15 +77,15 @@ function gadget:GameFrame(frame) end end if enableBoost == true then - Spring.SetUnitBuildSpeed(id, data.boost) + SpringSynced.SetUnitBuildSpeed(id, data.boost) spSetUnitRulesParam(id, "workertimeBoosted", data.boost) else - Spring.SetUnitBuildSpeed(id, data.buildspeed) + SpringSynced.SetUnitBuildSpeed(id, data.buildspeed) data.timestamp = frame + 60 spSetUnitRulesParam(id, "workertimeBoosted", 0) end else - Spring.SetUnitBuildSpeed(id, data.buildspeed) + SpringSynced.SetUnitBuildSpeed(id, data.buildspeed) end end end diff --git a/luarules/gadgets/unit_xmas.lua b/luarules/gadgets/unit_xmas.lua index 29977c4d2b9..d43c1031836 100644 --- a/luarules/gadgets/unit_xmas.lua +++ b/luarules/gadgets/unit_xmas.lua @@ -54,8 +54,8 @@ local candycaneSnowMapMult = 2.5 local addGaiaBalls = false -- if false, only own team colored balls are added local enableUnitDecorations = true -- burst out xmas ball after unit death -for _, teamID in ipairs(Spring.GetTeamList()) do - if select(4, Spring.GetTeamInfo(teamID, false)) then -- is AI? +for _, teamID in ipairs(SpringShared.GetTeamList()) do + if select(4, SpringShared.GetTeamInfo(teamID, false)) then -- is AI? enableUnitDecorations = false end end @@ -120,9 +120,9 @@ local decorations = {} local decorationsTerminal = {} local createDecorations = {} local createdDecorations = {} -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() local random = math.random -local GetGroundHeight = Spring.GetGroundHeight +local GetGroundHeight = SpringShared.GetGroundHeight local initiated VFS.Include("luarules/configs/map_biomes.lua") @@ -143,9 +143,9 @@ function initiateXmas() -- spawn candy canes (if not already done) local detectedCandycane = false - local allfeatures = Spring.GetAllFeatures() + local allfeatures = SpringShared.GetAllFeatures() for i, featureID in ipairs(allfeatures) do - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if string.find(FeatureDefs[featureDefID].name, "candycane") then detectedCandycane = true break @@ -157,11 +157,11 @@ function initiateXmas() local z = random(0, Game.mapSizeZ) local y = GetGroundHeight(x, z) if y > 5 then - local groundType, groundType2 = Spring.GetGroundInfo(x, z) + local groundType, groundType2 = SpringShared.GetGroundInfo(x, z) if type(groundType) == "string" and groundType ~= "void" or groundType2 ~= "void" then -- 105 compatibility local caneType = math.ceil(random(1, 7)) - local featureID = Spring.CreateFeature("candycane" .. caneType, x, y, z, random(0, 360)) - Spring.SetFeatureRotation(featureID, random(-12, 12), random(-12, 12), random(-180, 180)) + local featureID = SpringSynced.CreateFeature("candycane" .. caneType, x, y, z, random(0, 360)) + SpringSynced.SetFeatureRotation(featureID, random(-12, 12), random(-12, 12), random(-180, 180)) end end end @@ -175,15 +175,15 @@ function gadget:GameFrame(n) for unitID, frame in pairs(decorations) do if frame < n then decorations[unitID] = nil - local x, y, z = Spring.GetUnitPosition(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) if x then - local gy = Spring.GetGroundHeight(x, z) + local gy = SpringShared.GetGroundHeight(x, z) decorationsTerminal[unitID] = n + random(0, 50) + 225 + ((y - gy) * 33) -- allows if in sea to take longer to go under seafloor if decorationsTerminal[unitID] > n + 1500 then -- limit time decorationsTerminal[unitID] = n + 1500 end - local env = Spring.UnitScript.GetScriptEnv(unitID) - Spring.UnitScript.CallAsUnit(unitID, env.Sink) + local env = SpringSynced.UnitScript.GetScriptEnv(unitID) + SpringSynced.UnitScript.CallAsUnit(unitID, env.Sink) end end end @@ -192,8 +192,8 @@ function gadget:GameFrame(n) for unitID, frame in pairs(decorationsTerminal) do if frame < n then decorationsTerminal[unitID] = nil - if Spring.GetUnitIsDead(unitID) == false then - Spring.DestroyUnit(unitID, false, true) + if SpringShared.GetUnitIsDead(unitID) == false then + SpringSynced.DestroyUnit(unitID, false, true) end end end @@ -213,13 +213,13 @@ function gadget:GameFrame(n) local size = math.clamp(math.floor(hasDecoration[data[5]][4]), 1, #decorationSizes) -- retrieve max size size = math.min(size, (math.ceil((size * 0.35) + (math.random() * (size * 0.65))))) -- pick a size local decorationDefID = decorationSizes[size][math.floor(1 + (math.random() * (#decorationSizes[size] - 0.001)))] -- pick one of 2 variants/textured baubles - uID = Spring.CreateUnit(decorationDefID, data[1], data[2], data[3], 0, teamID) + uID = SpringSynced.CreateUnit(decorationDefID, data[1], data[2], data[3], 0, teamID) if uID ~= nil then decorationCount = decorationCount + 1 - decorations[uID] = Spring.GetGameFrame() + hasDecoration[data[5]][3] + (random() * (hasDecoration[data[5]][3] * 0.33)) - Spring.SetUnitRotation(uID, random() * 360, random() * 360, random() * 360) + decorations[uID] = SpringShared.GetGameFrame() + hasDecoration[data[5]][3] + (random() * (hasDecoration[data[5]][3] * 0.33)) + SpringSynced.SetUnitRotation(uID, random() * 360, random() * 360, random() * 360) local impulseMult = hasDecoration[data[5]][2] - Spring.AddUnitImpulse(uID, (random() - 0.5) * (impulseMult / 2), 1 + (random() * impulseMult), (random() - 0.5) * (impulseMult / 2)) + SpringSynced.AddUnitImpulse(uID, (random() - 0.5) * (impulseMult / 2), 1 + (random() * impulseMult), (random() - 0.5) * (impulseMult / 2)) end i = i + 1 end @@ -231,11 +231,11 @@ function gadget:GameFrame(n) for _, unitID in ipairs(createdDecorations) do if not decorations[unitID] then decorationCount = decorationCount + 1 - decorations[unitID] = Spring.GetGameFrame() + 2000 + (random() * 1000) - Spring.SetUnitRotation(unitID, random() * 360, random() * 360, random() * 360) + decorations[unitID] = SpringShared.GetGameFrame() + 2000 + (random() * 1000) + SpringSynced.SetUnitRotation(unitID, random() * 360, random() * 360, random() * 360) --Spring.AddUnitImpulse(unitID, (random()-0.5)*2, 3.8+(random()*1), (random()-0.5)*2) local impulseMult = 80 - Spring.AddUnitImpulse(unitID, (random() - 0.5) * (impulseMult / 3), 1 + (random() * (impulseMult / 1.6)), (random() - 0.5) * (impulseMult / 3)) + SpringSynced.AddUnitImpulse(unitID, (random() - 0.5) * (impulseMult / 3), 1 + (random() * (impulseMult / 1.6)), (random() - 0.5) * (impulseMult / 3)) end end createdDecorations = {} @@ -249,19 +249,19 @@ end function gadget:FeatureCreated(featureID, allyTeam) -- replace comwreck with xmas comwreck - if isComWreck[Spring.GetFeatureDefID(featureID)] then - local px, py, pz = Spring.GetFeaturePosition(featureID) - local rx, ry, rz = Spring.GetFeatureRotation(featureID) - local dx, dy, dz = Spring.GetFeatureDirection(featureID) - local heading = Spring.GetFeatureHeading(featureID) - local teamID = Spring.GetFeatureTeam(featureID) - Spring.DestroyFeature(featureID) - local xmasFeatureID = Spring.CreateFeature(xmasComwreckDefID, px, py, pz, heading, teamID) + if isComWreck[SpringShared.GetFeatureDefID(featureID)] then + local px, py, pz = SpringShared.GetFeaturePosition(featureID) + local rx, ry, rz = SpringShared.GetFeatureRotation(featureID) + local dx, dy, dz = SpringShared.GetFeatureDirection(featureID) + local heading = SpringShared.GetFeatureHeading(featureID) + local teamID = SpringShared.GetFeatureTeam(featureID) + SpringSynced.DestroyFeature(featureID) + local xmasFeatureID = SpringSynced.CreateFeature(xmasComwreckDefID, px, py, pz, heading, teamID) if xmasFeatureID then - Spring.SetFeatureRotation(xmasFeatureID, rx, ry, rz) - Spring.SetFeatureDirection(xmasFeatureID, dx, dy, dz) - local featureResurrect = Spring.GetFeatureResurrect(featureID) - Spring.SetFeatureResurrect(xmasFeatureID, featureResurrect, "s", 0) + SpringSynced.SetFeatureRotation(xmasFeatureID, rx, ry, rz) + SpringSynced.SetFeatureDirection(xmasFeatureID, dx, dy, dz) + local featureResurrect = SpringShared.GetFeatureResurrect(featureID) + SpringSynced.SetFeatureResurrect(xmasFeatureID, featureResurrect, "s", 0) end end end @@ -277,9 +277,9 @@ function gadget:UnitDestroyed(unitID, unitDefID, teamID, attackerID, attackerDef elseif attackerID ~= nil then --and (not _G.destroyingTeam or not _G.destroyingTeam[select(6,Spring.GetTeamInfo(teamID,false))]) then -- is not reclaimed and not lastcom death chain ripple explosion if enableUnitDecorations and hasDecoration[unitDefID] ~= nil and (decorationCount < maxDecorations or hasDecoration[unitDefID][5]) then - local inProgress = Spring.GetUnitIsBeingBuilt(unitID) + local inProgress = SpringShared.GetUnitIsBeingBuilt(unitID) if not inProgress then -- exclude incompleted nanoframes - local x, y, z = Spring.GetUnitPosition(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) createDecorations[#createDecorations + 1] = { x, y, z, teamID, unitDefID } --Spring.Echo(hasDecoration[unitDefID][1]) end diff --git a/luarules/gadgets/unit_xp_range_bonus.lua b/luarules/gadgets/unit_xp_range_bonus.lua index 91b398384ca..45a5afd2764 100644 --- a/luarules/gadgets/unit_xp_range_bonus.lua +++ b/luarules/gadgets/unit_xp_range_bonus.lua @@ -16,8 +16,8 @@ if not gadgetHandler:IsSyncedCode() then return false end -local spSetUnitWeaponState = Spring.SetUnitWeaponState -local spSetUnitMaxRange = Spring.SetUnitMaxRange +local spSetUnitWeaponState = SpringSynced.SetUnitWeaponState +local spSetUnitMaxRange = SpringSynced.SetUnitMaxRange local unpack = unpack local gainsRangeFromXp = {} @@ -28,7 +28,7 @@ for unitDefID, unitDef in pairs(UnitDefs) do end function gadget:Initialize() - Spring.SetExperienceGrade(0.01) --without this, gadget:UnitExperience doesn't work at all. + SpringSynced.SetExperienceGrade(0.01) --without this, gadget:UnitExperience doesn't work at all. end function gadget:UnitExperience(unitID, unitDefID, unitTeam, xp, oldxp) diff --git a/luarules/gadgets/unit_zombies.lua b/luarules/gadgets/unit_zombies.lua index 2aeef1c03e8..1a5fa1925ec 100644 --- a/luarules/gadgets/unit_zombies.lua +++ b/luarules/gadgets/unit_zombies.lua @@ -14,7 +14,7 @@ if not gadgetHandler:IsSyncedCode() then return false end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() local ZOMBIE_GUARD_RADIUS = 500 -- Radius for zombies to guard allies local ZOMBIE_MAX_ORDER_ATTEMPTS = 10 @@ -89,46 +89,46 @@ local UNAUTHORIZED_TEXT = "You are not authorized to use zombie commands" --i18n local MAP_SIZE_X = Game.mapSizeX local MAP_SIZE_Z = Game.mapSizeZ -local spGetUnitRotation = Spring.GetUnitRotation -local spGetUnitNearestEnemy = Spring.GetUnitNearestEnemy -local spValidUnitID = Spring.ValidUnitID -local spGetGroundHeight = Spring.GetGroundHeight -local spGetUnitPosition = Spring.GetUnitPosition -local spGetFeaturePosition = Spring.GetFeaturePosition -local spCreateUnit = Spring.CreateUnit -local spTransferUnit = Spring.TransferUnit -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetAllUnits = Spring.GetAllUnits -local spGetGameFrame = Spring.GetGameFrame -local spGetAllFeatures = Spring.GetAllFeatures -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spDestroyFeature = Spring.DestroyFeature -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGiveOrderArrayToUnit = Spring.GiveOrderArrayToUnit -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder -local spSetTeamResource = Spring.SetTeamResource -local spGetUnitHealth = Spring.GetUnitHealth -local spSetUnitHealth = Spring.SetUnitHealth -local spSetUnitRulesParam = Spring.SetUnitRulesParam -local spGetUnitRulesParam = Spring.GetUnitRulesParam -local spGetFeatureDefID = Spring.GetFeatureDefID -local spTestMoveOrder = Spring.TestMoveOrder -local spSpawnCEG = Spring.SpawnCEG -local spGetFeatureResources = Spring.GetFeatureResources -local spGetFeatureHealth = Spring.GetFeatureHealth -local spDestroyUnit = Spring.DestroyUnit -local spGetUnitDirection = Spring.GetUnitDirection -local spCreateFeature = Spring.CreateFeature -local spSpawnExplosion = Spring.SpawnExplosion -local spPlaySoundFile = Spring.PlaySoundFile -local spGetFeatureRadius = Spring.GetFeatureRadius -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spSetUnitExperience = Spring.SetUnitExperience -local spGetUnitExperience = Spring.GetUnitExperience -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitHeight = Spring.GetUnitHeight +local spGetUnitRotation = SpringShared.GetUnitRotation +local spGetUnitNearestEnemy = SpringShared.GetUnitNearestEnemy +local spValidUnitID = SpringShared.ValidUnitID +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spCreateUnit = SpringSynced.CreateUnit +local spTransferUnit = SpringSynced.TransferUnit +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetAllUnits = SpringShared.GetAllUnits +local spGetGameFrame = SpringShared.GetGameFrame +local spGetAllFeatures = SpringShared.GetAllFeatures +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spDestroyFeature = SpringSynced.DestroyFeature +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGiveOrderArrayToUnit = SpringSynced.GiveOrderArrayToUnit +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local spSetTeamResource = SpringSynced.SetTeamResource +local spGetUnitHealth = SpringShared.GetUnitHealth +local spSetUnitHealth = SpringSynced.SetUnitHealth +local spSetUnitRulesParam = SpringSynced.SetUnitRulesParam +local spGetUnitRulesParam = SpringShared.GetUnitRulesParam +local spGetFeatureDefID = SpringShared.GetFeatureDefID +local spTestMoveOrder = SpringShared.TestMoveOrder +local spSpawnCEG = SpringSynced.SpawnCEG +local spGetFeatureResources = SpringShared.GetFeatureResources +local spGetFeatureHealth = SpringShared.GetFeatureHealth +local spDestroyUnit = SpringSynced.DestroyUnit +local spGetUnitDirection = SpringShared.GetUnitDirection +local spCreateFeature = SpringSynced.CreateFeature +local spSpawnExplosion = SpringSynced.SpawnExplosion +local spPlaySoundFile = SpringUnsynced.PlaySoundFile +local spGetFeatureRadius = SpringShared.GetFeatureRadius +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spSetUnitExperience = SpringSynced.SetUnitExperience +local spGetUnitExperience = SpringShared.GetUnitExperience +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitHeight = SpringShared.GetUnitHeight local random = math.random local distance2dSquared = math.distance2dSquared local pi = math.pi @@ -139,11 +139,11 @@ local floor = math.floor local clamp = math.clamp local ceil = math.ceil -local teams = Spring.GetTeamList() +local teams = SpringShared.GetTeamList() local scavTeamID -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() for _, teamID in ipairs(teams) do - local teamLuaAI = Spring.GetTeamLuaAI(teamID) + local teamLuaAI = SpringShared.GetTeamLuaAI(teamID) if teamLuaAI and string.find(teamLuaAI, "ScavengersAI") then scavTeamID = teamID end @@ -299,12 +299,12 @@ local function setGaiaStorage() local metalStorageToSet = 1000000 local energyStorageToSet = 1000000 - local _, currentMetalStorage = Spring.GetTeamResources(gaiaTeamID, "metal") + local _, currentMetalStorage = SpringShared.GetTeamResources(gaiaTeamID, "metal") if currentMetalStorage and currentMetalStorage < metalStorageToSet then spSetTeamResource(gaiaTeamID, "ms", metalStorageToSet) end - local _, currentEnergyStorage = Spring.GetTeamResources(gaiaTeamID, "energy") + local _, currentEnergyStorage = SpringShared.GetTeamResources(gaiaTeamID, "energy") if currentEnergyStorage and currentEnergyStorage < energyStorageToSet then spSetTeamResource(gaiaTeamID, "es", energyStorageToSet) end @@ -526,7 +526,7 @@ local function updateOrders(unitID, unitDefID, closestKnownEnemy, currentCommand end if factoriesWithCombatOptions[unitDefID] then - local factoryCommands = Spring.GetFactoryCommands(unitID, -1) or {} + local factoryCommands = SpringShared.GetFactoryCommands(unitID, -1) or {} local currentCommandCount = #factoryCommands if currentCommandCount < ZOMBIE_FACTORY_BUILD_COUNT then issueRandomFactoryBuildOrders(unitID, unitDefID) @@ -721,8 +721,8 @@ function gadget:GameFrame(frame) end if frame % ZOMBIE_CHECK_INTERVAL == 0 then - Spring.AddTeamResource(gaiaTeamID, "metal", 1000000) - Spring.AddTeamResource(gaiaTeamID, "energy", 1000000) + SpringSynced.AddTeamResource(gaiaTeamID, "metal", 1000000) + SpringSynced.AddTeamResource(gaiaTeamID, "energy", 1000000) for featureID, featureData in pairs(corpsesData) do local featureX, featureY, featureZ = spGetFeaturePosition(featureID) if not featureX then --doesn't exist anymore @@ -883,7 +883,7 @@ local function createZombieFromFeature(featureID) end local function queueAllCorpsesForSpawning() - local features = Spring.GetAllFeatures() + local features = SpringShared.GetAllFeatures() for _, featureID in ipairs(features) do queueCorpseForSpawning(featureID, true) end @@ -901,7 +901,7 @@ local function pacifyZombies(enabled) end for zombieID, _ in pairs(zombieWatch) do if spValidUnitID(zombieID) then - Spring.GiveOrderToUnit(zombieID, CMD.FIRE_STATE, fireState) + SpringSynced.GiveOrderToUnit(zombieID, CMD.FIRE_STATE, fireState) end end end @@ -932,7 +932,7 @@ local function fightNearTargets(targetUnits) local fightZ = targetZ + sin(angle) * offsetDistance local fightY = spGetGroundHeight(fightX, fightZ) - Spring.GiveOrderToUnit(zombieID, CMD.FIGHT, { fightX, fightY, fightZ }, {}) + SpringSynced.GiveOrderToUnit(zombieID, CMD.FIGHT, { fightX, fightY, fightZ }, {}) end end end @@ -944,13 +944,13 @@ end local function aggroTeamID(teamID) clearAllOrders() - local isDead = select(3, Spring.GetTeamInfo(teamID)) + local isDead = select(3, SpringShared.GetTeamInfo(teamID)) if isDead or isDead == nil then return false end - local targetUnits = Spring.GetTeamUnits(teamID) or {} + local targetUnits = SpringShared.GetTeamUnits(teamID) or {} return fightNearTargets(targetUnits) end @@ -958,14 +958,14 @@ local function aggroAllyID(allyID) clearAllOrders() local targetUnits = {} - local allyTeams = Spring.GetTeamList(allyID) + local allyTeams = SpringShared.GetTeamList(allyID) if not allyTeams then return false end for _, teamID in pairs(allyTeams) do - local unitsToAdd = Spring.GetTeamUnits(teamID) + local unitsToAdd = SpringShared.GetTeamUnits(teamID) for _, unitID in pairs(unitsToAdd) do table.insert(targetUnits, unitID) end @@ -976,10 +976,10 @@ end local function killAllZombies() for zombieID, zombieData in pairs(zombieWatch) do - if spValidUnitID(zombieID) and not Spring.GetUnitIsDead(zombieID) then + if spValidUnitID(zombieID) and not SpringShared.GetUnitIsDead(zombieID) then local currentHealth = spGetUnitHealth(zombieID) if currentHealth and currentHealth > 0 then - Spring.AddUnitDamage(zombieID, currentHealth, 0, NULL_ATTACKER, ENVIRONMENTAL_DAMAGE_ID) + SpringSynced.AddUnitDamage(zombieID, currentHealth, 0, NULL_ATTACKER, ENVIRONMENTAL_DAMAGE_ID) end end end @@ -998,7 +998,7 @@ local function clearAllZombieSpawns() end local function isAuthorized(playerID) - if Spring.IsCheatingEnabled() then + if SpringShared.IsCheatingEnabled() then return true end local accountID = Spring.Utilities.GetAccountID(playerID) @@ -1025,11 +1025,11 @@ local function convertUnitsToZombies(unitIDs) end local function setAllGaiaToZombies() - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() local convertedCount = 0 for _, unitID in ipairs(allUnits) do - local unitTeam = Spring.GetUnitTeam(unitID) + local unitTeam = SpringShared.GetUnitTeam(unitID) if unitTeam == gaiaTeamID and not isZombie(unitID) then setZombie(unitID) convertedCount = convertedCount + 1 @@ -1041,186 +1041,186 @@ end local function commandSetAllGaiaToZombies(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end local convertedCount = setAllGaiaToZombies() - Spring.SendMessageToPlayer(playerID, "Set " .. convertedCount .. " Gaia units as zombies") + SpringUnsynced.SendMessageToPlayer(playerID, "Set " .. convertedCount .. " Gaia units as zombies") end local function commandQueueAllCorpsesForReanimation(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end queueAllCorpsesForSpawning() - Spring.SendMessageToPlayer(playerID, "Queued all corpses for spawning") + SpringUnsynced.SendMessageToPlayer(playerID, "Queued all corpses for spawning") end local function commandToggleAutoReanimation(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end if #words == 0 then - Spring.SendMessageToPlayer(playerID, "Usage: /luarules zombieautospawn 0|1") + SpringUnsynced.SendMessageToPlayer(playerID, "Usage: /luarules zombieautospawn 0|1") return end local enabled = tonumber(words[1]) if enabled == nil or (enabled ~= 0 and enabled ~= 1) then - Spring.SendMessageToPlayer(playerID, "Invalid value. Use 0 to disable or 1 to enable") + SpringUnsynced.SendMessageToPlayer(playerID, "Invalid value. Use 0 to disable or 1 to enable") return end setAutoSpawning(enabled == 1) - Spring.SendMessageToPlayer(playerID, "Auto spawning " .. (enabled == 1 and "enabled" or "disabled")) + SpringUnsynced.SendMessageToPlayer(playerID, "Auto spawning " .. (enabled == 1 and "enabled" or "disabled")) end local function commandPacifyZombies(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end if #words == 0 then - Spring.SendMessageToPlayer(playerID, "Usage: /luarules zombiepacify 0|1") + SpringUnsynced.SendMessageToPlayer(playerID, "Usage: /luarules zombiepacify 0|1") return end local enabled = tonumber(words[1]) if enabled == nil or (enabled ~= 0 and enabled ~= 1) then - Spring.SendMessageToPlayer(playerID, "Invalid value. Use 0 to disable or 1 to enable") + SpringUnsynced.SendMessageToPlayer(playerID, "Invalid value. Use 0 to disable or 1 to enable") return end pacifyZombies(enabled == 1) - Spring.SendMessageToPlayer(playerID, "Zombies " .. (enabled == 1 and "pacified" or "unpacified")) + SpringUnsynced.SendMessageToPlayer(playerID, "Zombies " .. (enabled == 1 and "pacified" or "unpacified")) end local function commandSuspendAutoOrders(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end if #words == 0 then - Spring.SendMessageToPlayer(playerID, "Usage: /luarules zombiesuspendorders 0|1") + SpringUnsynced.SendMessageToPlayer(playerID, "Usage: /luarules zombiesuspendorders 0|1") return end local enabled = tonumber(words[1]) if enabled == nil or (enabled ~= 0 and enabled ~= 1) then - Spring.SendMessageToPlayer(playerID, "Invalid value. Use 0 to disable or 1 to enable") + SpringUnsynced.SendMessageToPlayer(playerID, "Invalid value. Use 0 to disable or 1 to enable") return end suspendAutoOrders(enabled == 1) - Spring.SendMessageToPlayer(playerID, "Zombie auto-orders " .. (enabled == 1 and "suspended" or "resumed")) + SpringUnsynced.SendMessageToPlayer(playerID, "Zombie auto-orders " .. (enabled == 1 and "suspended" or "resumed")) end local function commandAggroZombiesToTeam(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end if #words == 0 then - Spring.SendMessageToPlayer(playerID, "Usage: /luarules zombieaggroteam ") + SpringUnsynced.SendMessageToPlayer(playerID, "Usage: /luarules zombieaggroteam ") return end local targetTeamID = tonumber(words[1]) if not targetTeamID or targetTeamID < 0 then - Spring.SendMessageToPlayer(playerID, "Invalid team ID") + SpringUnsynced.SendMessageToPlayer(playerID, "Invalid team ID") return end local success = aggroTeamID(targetTeamID) if success then - Spring.SendMessageToPlayer(playerID, "Zombies aggroed to team " .. targetTeamID) + SpringUnsynced.SendMessageToPlayer(playerID, "Zombies aggroed to team " .. targetTeamID) else - Spring.SendMessageToPlayer(playerID, "Team " .. targetTeamID .. " not found or has no units") + SpringUnsynced.SendMessageToPlayer(playerID, "Team " .. targetTeamID .. " not found or has no units") end end local function commandAggroZombiesToAlly(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end if #words == 0 then - Spring.SendMessageToPlayer(playerID, "Usage: /luarules zombieaggroally ") + SpringUnsynced.SendMessageToPlayer(playerID, "Usage: /luarules zombieaggroally ") return end local targetAllyID = tonumber(words[1]) if not targetAllyID or targetAllyID < 0 then - Spring.SendMessageToPlayer(playerID, "Invalid ally ID") + SpringUnsynced.SendMessageToPlayer(playerID, "Invalid ally ID") return end local success = aggroAllyID(targetAllyID) if success then - Spring.SendMessageToPlayer(playerID, "Zombies aggroed to ally team " .. targetAllyID) + SpringUnsynced.SendMessageToPlayer(playerID, "Zombies aggroed to ally team " .. targetAllyID) else - Spring.SendMessageToPlayer(playerID, "Ally team " .. targetAllyID .. " not found or has no units") + SpringUnsynced.SendMessageToPlayer(playerID, "Ally team " .. targetAllyID .. " not found or has no units") end end local function commandKillAllZombies(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end killAllZombies() - Spring.SendMessageToPlayer(playerID, "Killed all zombies") + SpringUnsynced.SendMessageToPlayer(playerID, "Killed all zombies") end local function commandClearAllZombieOrders(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end clearAllOrders() - Spring.SendMessageToPlayer(playerID, "Cleared zombie orders") + SpringUnsynced.SendMessageToPlayer(playerID, "Cleared zombie orders") end local function commandClearZombieSpawns(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end clearAllZombieSpawns() - Spring.SendMessageToPlayer(playerID, "Cleared all queued zombie spawns") + SpringUnsynced.SendMessageToPlayer(playerID, "Cleared all queued zombie spawns") end local function commandToggleDebugMode(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end if #words == 0 then - Spring.SendMessageToPlayer(playerID, "Usage: /luarules zombiedebug 0|1") + SpringUnsynced.SendMessageToPlayer(playerID, "Usage: /luarules zombiedebug 0|1") return end local enabled = tonumber(words[1]) if enabled == nil or (enabled ~= 0 and enabled ~= 1) then - Spring.SendMessageToPlayer(playerID, "Invalid value. Use 0 to disable or 1 to enable") + SpringUnsynced.SendMessageToPlayer(playerID, "Invalid value. Use 0 to disable or 1 to enable") return end debugMode = enabled == 1 - Spring.SendMessageToPlayer(playerID, "Zombie debug mode " .. (debugMode and "enabled" or "disabled")) + SpringUnsynced.SendMessageToPlayer(playerID, "Zombie debug mode " .. (debugMode and "enabled" or "disabled")) end local function setZombieMode(mode) @@ -1235,26 +1235,26 @@ end local function commandSetZombieMode(_, line, words, playerID) if not isAuthorized(playerID) then - Spring.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) + SpringUnsynced.SendMessageToPlayer(playerID, UNAUTHORIZED_TEXT) return end if #words == 0 then - Spring.SendMessageToPlayer(playerID, "Usage: /luarules zombiemode normal|hard|nightmare|extreme") + SpringUnsynced.SendMessageToPlayer(playerID, "Usage: /luarules zombiemode normal|hard|nightmare|extreme") return end local mode = string.lower(words[1]) if mode ~= "normal" and mode ~= "hard" and mode ~= "nightmare" and mode ~= "extreme" then - Spring.SendMessageToPlayer(playerID, "Invalid mode. Use: normal, hard, nightmare, or extreme") + SpringUnsynced.SendMessageToPlayer(playerID, "Invalid mode. Use: normal, hard, nightmare, or extreme") return end local success = setZombieMode(mode) if success then - Spring.SendMessageToPlayer(playerID, "Zombie mode set to " .. mode) + SpringUnsynced.SendMessageToPlayer(playerID, "Zombie mode set to " .. mode) else - Spring.SendMessageToPlayer(playerID, "Failed to set zombie mode to " .. mode) + SpringUnsynced.SendMessageToPlayer(playerID, "Failed to set zombie mode to " .. mode) end end diff --git a/luarules/mission_api/actions.lua b/luarules/mission_api/actions.lua index d659c993373..acfc7a7540e 100644 --- a/luarules/mission_api/actions.lua +++ b/luarules/mission_api/actions.lua @@ -10,13 +10,13 @@ local function disableTrigger(triggerId) end local function sendMessage(message) - Spring.Echo(message) + SpringShared.Echo(message) end local function spawnUnits(name, unitDefName, quantity, x, y, z) - y = y or Spring.GetGroundHeight(x, z) + y = y or SpringShared.GetGroundHeight(x, z) - local unitId = Spring.CreateUnit(unitDefName, x, y, z, "south", 0) + local unitId = SpringSynced.CreateUnit(unitDefName, x, y, z, "south", 0) if unitId and name then trackedUnits[name] = unitId @@ -31,7 +31,7 @@ local function despawnUnits(name) trackedUnits[name] = nil trackedUnits[unitId] = nil - Spring.DestroyUnit(unitId, false, true) + SpringSynced.DestroyUnit(unitId, false, true) end end diff --git a/luarules/mission_api/actions_loader.lua b/luarules/mission_api/actions_loader.lua index fabf7c9cc8b..8536a1a8a30 100644 --- a/luarules/mission_api/actions_loader.lua +++ b/luarules/mission_api/actions_loader.lua @@ -15,7 +15,7 @@ local actions = {} local function prevalidateActions() for actionId, action in pairs(actions) do if not action.type then - Spring.Log("actions_loader.lua", LOG.ERROR, "[Mission API] Action missing type: " .. actionId) + SpringShared.Log("actions_loader.lua", LOG.ERROR, "[Mission API] Action missing type: " .. actionId) end for _, parameter in pairs(parameters[action.type]) do @@ -23,11 +23,11 @@ local function prevalidateActions() local type = type(value) if value == nil and parameter.required then - Spring.Log("actions_loader.lua", LOG.ERROR, "[Mission API] Action missing required parameter. Action: " .. actionId .. ", Parameter: " .. parameter.name) + SpringShared.Log("actions_loader.lua", LOG.ERROR, "[Mission API] Action missing required parameter. Action: " .. actionId .. ", Parameter: " .. parameter.name) end if value ~= nil and type ~= parameter.type then - Spring.Log("actions_loader.lua", LOG.ERROR, "[Mission API] Unexpected parameter type, expected " .. parameter.type .. ", got " .. type .. ". Action: " .. actionId .. ", Parameter: " .. parameter.name) + SpringShared.Log("actions_loader.lua", LOG.ERROR, "[Mission API] Unexpected parameter type, expected " .. parameter.type .. ", got " .. type .. ". Action: " .. actionId .. ", Parameter: " .. parameter.name) end end end diff --git a/luarules/mission_api/triggers_loader.lua b/luarules/mission_api/triggers_loader.lua index cbbdf17f024..3911b922062 100644 --- a/luarules/mission_api/triggers_loader.lua +++ b/luarules/mission_api/triggers_loader.lua @@ -25,11 +25,11 @@ local triggers = {} local function prevalidateTriggers() for triggerId, trigger in pairs(triggers) do if not trigger.type then - Spring.Log("triggers_loader.lua", LOG.ERROR, "[Mission API] Trigger missing type: " .. triggerId) + SpringShared.Log("triggers_loader.lua", LOG.ERROR, "[Mission API] Trigger missing type: " .. triggerId) end if not trigger.actions or next(trigger.actions) == nil then - Spring.Log("triggers_loader.lua", LOG.ERROR, "[Mission API] Trigger has no actions: " .. triggerId) + SpringShared.Log("triggers_loader.lua", LOG.ERROR, "[Mission API] Trigger has no actions: " .. triggerId) end for _, parameter in pairs(parameters[trigger.type]) do @@ -37,11 +37,11 @@ local function prevalidateTriggers() local type = type(value) if value == nil and parameter.required then - Spring.Log("triggers_loader.lua", LOG.ERROR, "[Mission API] Trigger missing required parameter. Trigger: " .. triggerId .. ", Parameter: " .. parameter.name) + SpringShared.Log("triggers_loader.lua", LOG.ERROR, "[Mission API] Trigger missing required parameter. Trigger: " .. triggerId .. ", Parameter: " .. parameter.name) end if value ~= nil and type ~= parameter.type then - Spring.Log("triggers_loader.lua", LOG.ERROR, "[Mission API] Unexpected parameter type, expected " .. parameter.type .. ", got " .. type .. ". Trigger: " .. triggerId .. ", Parameter: " .. parameter.name) + SpringShared.Log("triggers_loader.lua", LOG.ERROR, "[Mission API] Unexpected parameter type, expected " .. parameter.type .. ", got " .. type .. ". Trigger: " .. triggerId .. ", Parameter: " .. parameter.name) end end end @@ -72,7 +72,7 @@ local function postvalidateTriggers() for triggerId, trigger in pairs(triggers) do for _, actionId in pairs(trigger.actions) do if not actions[actionId] then - Spring.Log("triggers_loader.lua", LOG.ERROR, "[Mission API] Trigger has action that does not exist. Trigger: " .. triggerId .. ", Action: " .. actionId) + SpringShared.Log("triggers_loader.lua", LOG.ERROR, "[Mission API] Trigger has action that does not exist. Trigger: " .. triggerId .. ", Action: " .. actionId) end end end diff --git a/luarules/system.lua b/luarules/system.lua index cac735976f2..2aab9fb9404 100644 --- a/luarules/system.lua +++ b/luarules/system.lua @@ -12,7 +12,7 @@ -------------------------------------------------------------------------------- if System == nil then if tracy == nil then - Spring.Echo("Gadgetside tracy: No support detected, replacing tracy.* with function stubs.") + SpringShared.Echo("Gadgetside tracy: No support detected, replacing tracy.* with function stubs.") tracy = {} tracy.ZoneBeginN = function() return diff --git a/luaui.lua b/luaui.lua index 49c536e681c..28b53beb9bb 100644 --- a/luaui.lua +++ b/luaui.lua @@ -28,7 +28,7 @@ do end end -Spring.Echo("Using LUAUI_DIRNAME = " .. LUAUI_DIRNAME) +SpringShared.Echo("Using LUAUI_DIRNAME = " .. LUAUI_DIRNAME) -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- diff --git a/luaui/Include/AtlasOnDemand.lua b/luaui/Include/AtlasOnDemand.lua index 1e368044281..548973eef5c 100644 --- a/luaui/Include/AtlasOnDemand.lua +++ b/luaui/Include/AtlasOnDemand.lua @@ -244,7 +244,7 @@ local function MakeAtlasOnDemand(config) -- @return an array of UV coordinates in xXyY format function AtlasOnDemand:ReserveSpace(id, xsize, ysize) if self.uvcoords[id] then - Spring.Echo(string.format("AtlasOnDemand %s Warning: ID %s is already added to this atlas", self.name, tostring(id))) + SpringShared.Echo(string.format("AtlasOnDemand %s Warning: ID %s is already added to this atlas", self.name, tostring(id))) return self.uvcoords[id] end @@ -327,7 +327,7 @@ local function MakeAtlasOnDemand(config) end if columnfull then if self.debug then - Spring.Echo("Column Full!", self.firstemptycolumn) + SpringShared.Echo("Column Full!", self.firstemptycolumn) end self.firstemptycolumn = self.firstemptycolumn + 1 end @@ -338,7 +338,7 @@ local function MakeAtlasOnDemand(config) return uvcoords, task else - Spring.Echo(string.format("AtlasOnDemand %s Error: cant find space for %s of size %d x %d", self.name, tostring(id), xsize, ysize)) + SpringShared.Echo(string.format("AtlasOnDemand %s Error: cant find space for %s of size %d x %d", self.name, tostring(id), xsize, ysize)) return { x = 0, y = 0, X = 1, Y = 1, w = xsize, h = ysize, d = 0 } end end @@ -354,7 +354,7 @@ local function MakeAtlasOnDemand(config) return { x = 0, X = 1, y = 0, Y = 1, w = 1, h = 1, id = image } end if self.uvcoords[image] then - Spring.Echo(string.format("AtlasOnDemand %s Warning: image %s is already added to this atlas", self.name, tostring(image))) + SpringShared.Echo(string.format("AtlasOnDemand %s Warning: image %s is already added to this atlas", self.name, tostring(image))) return self.uvcoords[image] end if xsize and ysize then @@ -362,7 +362,7 @@ local function MakeAtlasOnDemand(config) else local texInfo = gl.TextureInfo(image) if texInfo and (texInfo.xsize ~= xsize or texInfo.ysize ~= ysize) then - Spring.Echo(string.format("AtlasOnDemand %s Warning: image %s size does not match %dx%d given, %dx%d from TextureInfo", self.name, tostring(image), xsize or -1, ysize or -1, texInfo.xsize, texInfo.ysize)) + SpringShared.Echo(string.format("AtlasOnDemand %s Warning: image %s size does not match %dx%d given, %dx%d from TextureInfo", self.name, tostring(image), xsize or -1, ysize or -1, texInfo.xsize, texInfo.ysize)) if xsize == nil then xsize = texInfo.xsize end @@ -394,7 +394,7 @@ local function MakeAtlasOnDemand(config) self.hastasks = true return #self.renderImageTaskList else - Spring.Echo(string.format("AtlasOnDemand %s Warning: unable to read gl.TextureInfo(%s)", self.name, tostring(image))) + SpringShared.Echo(string.format("AtlasOnDemand %s Warning: unable to read gl.TextureInfo(%s)", self.name, tostring(image))) end end -- This should return a width, height and UV set for pixel-perfect rendering @@ -418,7 +418,7 @@ local function MakeAtlasOnDemand(config) return self.uvcoords[text] else if not self.defaultfont then - Spring.Echo(string.format("AtlasOnDemand %s Warning: text %s without font cannot be added because atlas has no default font set", self.name, tostring(id))) + SpringShared.Echo(string.format("AtlasOnDemand %s Warning: text %s without font cannot be added because atlas has no default font set", self.name, tostring(id))) self.uvcoords[text] = { x = 0, X = 1, y = 0, Y = 1, w = 1, h = 1, id = id } -- add a fallback so we only warn once per item return self.uvcoords[text] else @@ -463,7 +463,7 @@ local function MakeAtlasOnDemand(config) -- textparams.options = 'N' .. textparams.options if self.uvcoords[textparams.id] then - Spring.Echo(string.format("AtlasOnDemand %s Warning: text %s is already added to this atlas", self.name, tostring(textparams.id))) + SpringShared.Echo(string.format("AtlasOnDemand %s Warning: text %s is already added to this atlas", self.name, tostring(textparams.id))) return self.uvcoords[textparams.id] end -- get the actual width and height of the text object: @@ -475,7 +475,7 @@ local function MakeAtlasOnDemand(config) local height = math.ceil((textheight + textdescender) * textparams.size) textdescender = -1 * textdescender * textparams.size -- descender is negative for 'b' ? if self.debug then - Spring.Echo(string.format("Pre adjusted textsize for %s at size %d is w=%d h=%d descender=%d", textparams.text, textparams.size, width, height, textdescender)) + SpringShared.Echo(string.format("Pre adjusted textsize for %s at size %d is w=%d h=%d descender=%d", textparams.text, textparams.size, width, height, textdescender)) end local pad = 1 if string.find(textparams.options, "o", nil, true) then @@ -494,10 +494,10 @@ local function MakeAtlasOnDemand(config) width = width + 2 * pad height = height + 2 * pad + textdescender textdescender = math.round(textdescender + pad, 0) - local vsx, vsy = Spring.GetViewGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() if self.debug then - Spring.Echo(string.format('AddText: "%s", size=%d, w=%d h=%d d=%d pad =%f', textparams.text, textparams.size, width, height, textdescender, pad)) + SpringShared.Echo(string.format('AddText: "%s", size=%d, w=%d h=%d d=%d pad =%f', textparams.text, textparams.size, width, height, textdescender, pad)) end local uvcoords, task = self:ReserveSpace(textparams.id, width, height) @@ -593,7 +593,7 @@ local function MakeAtlasOnDemand(config) end textparams.font:Begin() if self.debug then - Spring.Echo("Font set to", textparams.font.path, textparams.size) + SpringShared.Echo("Font set to", textparams.font.path, textparams.size) end currentParams.font = textparams.font end @@ -644,8 +644,8 @@ local function MakeAtlasOnDemand(config) -- So, a big problem seems to be using fonts that are not size-allocated correctly! if self.debug then - Spring.Echo(string.format("Task params: id = %s w=%.3f h=%.3f x=%.3f y=%.3f", task.id, task.w, task.h, task.x, task.y)) - Spring.Echo(string.format("renderText: text = %s, x = %f, y = %.3f, size = %.3f, opts = %s", textparams.text, x, y, textparams.size, textparams.options)) + SpringShared.Echo(string.format("Task params: id = %s w=%.3f h=%.3f x=%.3f y=%.3f", task.id, task.w, task.h, task.x, task.y)) + SpringShared.Echo(string.format("renderText: text = %s, x = %f, y = %.3f, size = %.3f, opts = %s", textparams.text, x, y, textparams.size, textparams.options)) end font:Print(textparams.text, x, y, textparams.size, textparams.options) --font:Print(textparams.text, x,y, 36, textparams.options..'') @@ -662,7 +662,7 @@ local function MakeAtlasOnDemand(config) function AtlasOnDemand:TextRect(id, x, y, align) local uvcoords = self.uvcoords[id] if not uvcoords then - Spring.Echo("AtlasOnDemand:TextRect cannot find id", id) + SpringShared.Echo("AtlasOnDemand:TextRect cannot find id", id) return end local ypos = y @@ -710,7 +710,7 @@ local function MakeAtlasOnDemand(config) for y = 1, self.yslots do parts[y] = string.format("% 5s", fillRow[y]) end - Spring.Echo(table.concat(parts)) + SpringShared.Echo(table.concat(parts)) end end @@ -730,14 +730,14 @@ local function MakeAtlasOnDemand(config) gl.Texture(0, self.textureID) --o = o + math.sin(Spring.GetDrawFrame()*0.01) - local vsx, vsy = Spring.GetViewGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() local o = 10 gl.TexRect(o, o, math.min(vsx - o, self.xsize + o), math.min(vsy - o, self.ysize + o), 0, 0, 1, 1) if aliastest then local aliasUV = self.uvcoords[self.aliasing_grid_test_image] - Spring.Echo(aliasUV.x, aliasUV.y, aliasUV.X, aliasUV.Y, aliasUV.w, aliasUV.h) + SpringShared.Echo(aliasUV.x, aliasUV.y, aliasUV.X, aliasUV.Y, aliasUV.w, aliasUV.h) local xs = 0 for i = 1, 6 do gl.TexRect(xs, vsy - i * aliasUV.h, xs + i * aliasUV.w, vsy, aliasUV.x, aliasUV.y, aliasUV.X, aliasUV.Y) diff --git a/luaui/Include/DrawPrimitiveAtUnit.lua b/luaui/Include/DrawPrimitiveAtUnit.lua index e89dc3cf2f6..3716ea49762 100644 --- a/luaui/Include/DrawPrimitiveAtUnit.lua +++ b/luaui/Include/DrawPrimitiveAtUnit.lua @@ -68,7 +68,7 @@ local function InitDrawPrimitiveAtUnit(shaderConfig, DPATname) DrawPrimitiveAtUnitShader = LuaShader.CheckShaderUpdates(shaderSourceCache) or DrawPrimitiveAtUnitShader if not DrawPrimitiveAtUnitShader then - Spring.Echo("Failed to compile shader for ", DPATname) + SpringShared.Echo("Failed to compile shader for ", DPATname) return nil end @@ -86,7 +86,7 @@ local function InitDrawPrimitiveAtUnit(shaderConfig, DPATname) 5 -- unitIDattribID (instData) ) if DrawPrimitiveAtUnitVBO == nil then - Spring.Echo("Failed to create DrawPrimitiveAtUnitVBO for ", DPATname) + SpringShared.Echo("Failed to create DrawPrimitiveAtUnitVBO for ", DPATname) return nil end diff --git a/luaui/Include/LuaShader.lua b/luaui/Include/LuaShader.lua index a43652552fd..565744b71db 100644 --- a/luaui/Include/LuaShader.lua +++ b/luaui/Include/LuaShader.lua @@ -4,7 +4,7 @@ if not LuaShaderNewLocationMessageShown then local info = dest and dest.GetInfo() local name = info and info.name or "unknown" local msg = "A user widget (" .. name .. ") is including LuaUI/Include/LuaShader.lua directly, please change it to use gl.LuaShader instead." - Spring.Log("UserWidget", LOG.DEPRECATED, msg) + SpringShared.Log("UserWidget", LOG.DEPRECATED, msg) LuaShaderNewLocationMessageShown = true end diff --git a/luaui/Include/action_hotkeys.lua b/luaui/Include/action_hotkeys.lua index 241a2ebb777..5b448062c1d 100644 --- a/luaui/Include/action_hotkeys.lua +++ b/luaui/Include/action_hotkeys.lua @@ -1,6 +1,6 @@ local actionHotkeys = {} -for _, keybinding in pairs(Spring.GetKeyBindings()) do +for _, keybinding in pairs(SpringUnsynced.GetKeyBindings()) do local cmd = keybinding.command local boundWith = keybinding.boundWith if (not actionHotkeys[cmd]) or #boundWith < #actionHotkeys[cmd] then diff --git a/luaui/Include/blueprint_substitution/definitions.lua b/luaui/Include/blueprint_substitution/definitions.lua index 8c1835d18a1..b6d23db078b 100644 --- a/luaui/Include/blueprint_substitution/definitions.lua +++ b/luaui/Include/blueprint_substitution/definitions.lua @@ -23,7 +23,7 @@ DefinitionsModule.unitCategories = {} -- Unit Name -> Category Name local function DefCat(enumKey, unitTable) -- Made local to definitions.lua if DefinitionsModule.UNIT_CATEGORIES[enumKey] then local errorMsg = string.format("[BlueprintDefinitions ERROR] Duplicate category key definition attempted: '%s'. The previous definition will be overwritten.", enumKey) - Spring.Log("BlueprintDefs", LOG.ERROR, errorMsg) + SpringShared.Log("BlueprintDefs", LOG.ERROR, errorMsg) end DefinitionsModule.UNIT_CATEGORIES[enumKey] = enumKey @@ -37,7 +37,7 @@ local function DefCat(enumKey, unitTable) -- Made local to definitions.lua end function DefinitionsModule.defineUnitCategories() - Spring.Log("BlueprintDefs", LOG.DEBUG, "Defining static unit categories START...") + SpringShared.Log("BlueprintDefs", LOG.DEBUG, "Defining static unit categories START...") local SIDES = DefinitionsModule.SIDES -- Use SIDES from the module -- Clear existing tables (important if this function could be called multiple times on the same module instance, though typically not) @@ -162,7 +162,7 @@ function DefinitionsModule.defineUnitCategories() for _ in pairs(DefinitionsModule.UNIT_CATEGORIES) do categoryCount = categoryCount + 1 end - Spring.Log("BlueprintDefs", LOG.DEBUG, string.format("Defined %d categories covering %d units. END", categoryCount, unitCount)) + SpringShared.Log("BlueprintDefs", LOG.DEBUG, string.format("Defined %d categories covering %d units. END", categoryCount, unitCount)) end function DefinitionsModule.getCategory(unitDefID) diff --git a/luaui/Include/blueprint_substitution/logic.lua b/luaui/Include/blueprint_substitution/logic.lua index 37079425949..fb747a94835 100644 --- a/luaui/Include/blueprint_substitution/logic.lua +++ b/luaui/Include/blueprint_substitution/logic.lua @@ -20,13 +20,13 @@ BlueprintSubLogic.equivalentUnits = {} BlueprintSubLogic.MasterBuildingData = {} local unitNameToDefIDMap = {} -Spring.Log("BlueprintSubLogic", LOG.INFO, "Precomputing UnitDefs Name->ID map...") +SpringShared.Log("BlueprintSubLogic", LOG.INFO, "Precomputing UnitDefs Name->ID map...") for defID, def in pairs(UnitDefs) do if def and def.name then unitNameToDefIDMap[def.name:lower()] = defID end end -Spring.Log("BlueprintSubLogic", LOG.INFO, "Finished precomputing Name->ID map.") +SpringShared.Log("BlueprintSubLogic", LOG.INFO, "Finished precomputing Name->ID map.") function BlueprintSubLogic.validateCategoryDefinitions() local categoryKeys = {} @@ -43,10 +43,10 @@ function BlueprintSubLogic.validateCategoryDefinitions() for dupe in pairs(duplicateCategories) do table.insert(dupes, dupe) end - Spring.Log("BlueprintSubLogic", LOG.ERROR, string.format("[BlueprintSubLogic ERROR] Found duplicate category keys: %s", table.concat(dupes, ", "))) + SpringShared.Log("BlueprintSubLogic", LOG.ERROR, string.format("[BlueprintSubLogic ERROR] Found duplicate category keys: %s", table.concat(dupes, ", "))) end - Spring.Log("BlueprintSubLogic", LOG.DEBUG, "Validating category definitions (Unit Assignments)...") + SpringShared.Log("BlueprintSubLogic", LOG.DEBUG, "Validating category definitions (Unit Assignments)...") local multiAssigned = {} local unitAssignments = {} for unitName, categoryName in pairs(BlueprintSubLogic.unitCategories) do @@ -59,17 +59,17 @@ function BlueprintSubLogic.validateCategoryDefinitions() local count = 0 for unitName, categories in pairs(multiAssigned) do count = count + 1 - Spring.Log("BlueprintSubLogic", LOG.WARNING, string.format("Unit '%s' is assigned to multiple categories: %s", unitName, table.concat(categories, ", "))) + SpringShared.Log("BlueprintSubLogic", LOG.WARNING, string.format("Unit '%s' is assigned to multiple categories: %s", unitName, table.concat(categories, ", "))) end if count > 0 then - Spring.Log("BlueprintSubLogic", LOG.WARNING, string.format("Found %d units with multiple category assignments (This may be intended)", count)) + SpringShared.Log("BlueprintSubLogic", LOG.WARNING, string.format("Found %d units with multiple category assignments (This may be intended)", count)) else - Spring.Log("BlueprintSubLogic", LOG.DEBUG, "No duplicate unit assignments found") + SpringShared.Log("BlueprintSubLogic", LOG.DEBUG, "No duplicate unit assignments found") end end function BlueprintSubLogic.generateEquivalentUnits() - Spring.Log("BlueprintSubLogic", LOG.INFO, "Generating equivalent units...") + SpringShared.Log("BlueprintSubLogic", LOG.INFO, "Generating equivalent units...") local categoryUnits = BlueprintSubLogic.categoryUnits local equivalentUnits = BlueprintSubLogic.equivalentUnits for k in pairs(equivalentUnits) do @@ -98,7 +98,7 @@ function BlueprintSubLogic.generateEquivalentUnits() end end end - Spring.Log("BlueprintSubLogic", LOG.INFO, string.format("Generated %d unit mappings.", mappingCount)) + SpringShared.Log("BlueprintSubLogic", LOG.INFO, string.format("Generated %d unit mappings.", mappingCount)) end function BlueprintSubLogic.getSideFromUnitName(unitName) @@ -218,7 +218,7 @@ end BlueprintSubLogic.validateCategoryDefinitions() BlueprintSubLogic.generateEquivalentUnits() -Spring.Log("BlueprintSubLogic", LOG.INFO, "Generating Master Building Data...") +SpringShared.Log("BlueprintSubLogic", LOG.INFO, "Generating Master Building Data...") local buildingCount = 0 if BlueprintSubLogic.unitCategories then for unitNameLower, categoryName in pairs(BlueprintSubLogic.unitCategories) do @@ -241,8 +241,8 @@ if BlueprintSubLogic.unitCategories then buildingCount = buildingCount + 1 end end -Spring.Log("BlueprintSubLogic", LOG.INFO, string.format("Generated Master Building Data for %d buildings.", buildingCount)) -Spring.Log("BlueprintSubLogic", LOG.INFO, "Internal data structures for substitution logic generated. Module ready to be used.") +SpringShared.Log("BlueprintSubLogic", LOG.INFO, string.format("Generated Master Building Data for %d buildings.", buildingCount)) +SpringShared.Log("BlueprintSubLogic", LOG.INFO, "Internal data structures for substitution logic generated. Module ready to be used.") local function _getActualSubstitutedUnitName(originalUnitName, targetSide) if not originalUnitName or not targetSide then @@ -252,13 +252,13 @@ local function _getActualSubstitutedUnitName(originalUnitName, targetSide) local unitNameLower = originalUnitName:lower() local buildingData = BlueprintSubLogic.MasterBuildingData[unitNameLower] if not buildingData then - Spring.Log("BlueprintSubLogic", LOG.INFO, string.format("_getActualSubstitutedUnitDefID: No building data for unit '%s'. Returning original.", unitNameLower)) + SpringShared.Log("BlueprintSubLogic", LOG.INFO, string.format("_getActualSubstitutedUnitDefID: No building data for unit '%s'. Returning original.", unitNameLower)) return originalUnitName end local equivalentUnitName = buildingData.equivalents[targetSide] if not equivalentUnitName or equivalentUnitName == "" then - Spring.Log("BlueprintSubLogic", LOG.WARNING, string.format("_getActualSubstitutedUnitDefID: No mapping for unit '%s' to target side '%s'.", unitNameLower, targetSide)) + SpringShared.Log("BlueprintSubLogic", LOG.WARNING, string.format("_getActualSubstitutedUnitDefID: No mapping for unit '%s' to target side '%s'.", unitNameLower, targetSide)) return originalUnitName end @@ -313,7 +313,7 @@ local function _generateSubstitutionSummary(aggregatedStats, itemTypeString, sou verboseMessage = verboseMessage .. string.format(" (No relevant %s items to process for substitution)", itemTypeString:lower()) end - Spring.Log("BlueprintSubLogic", LOG.INFO, verboseMessage) + SpringShared.Log("BlueprintSubLogic", LOG.INFO, verboseMessage) local simpleMessage if stats.totalConsidered > 0 then @@ -355,7 +355,7 @@ function BlueprintSubLogic.processBlueprintSubstitution(originalBlueprint, targe local sourceSide = originalBlueprint and originalBlueprint.sourceInfo and originalBlueprint.sourceInfo.primarySourceSide if not (originalBlueprint and originalBlueprint.units and targetSide) then - Spring.Log("BlueprintSubLogic", LOG.ERROR, "processBlueprintSubstitution: Called with invalid arguments (nil blueprint, units, or targetSide).") + SpringShared.Log("BlueprintSubLogic", LOG.ERROR, "processBlueprintSubstitution: Called with invalid arguments (nil blueprint, units, or targetSide).") local errorStats = { totalConsidered = 0, substituted = 0, failedNoMapping = 0, failedInvalidEquivalent = 0, unchangedSameSide = 0, unchangedOther = 0, unchangedNotBuilding = 0, hadMappingFailures = true } return { stats = errorStats, summaryMessage = "Internal error: Invalid arguments for substitution.", substitutionFailed = true } end @@ -366,7 +366,7 @@ function BlueprintSubLogic.processBlueprintSubstitution(originalBlueprint, targe return { stats = errorStats, summaryMessage = summary, substitutionFailed = true } end - Spring.Log("BlueprintSubLogic", LOG.DEBUG, string.format("Processing blueprint substitution (in-place) from %s to %s for %d units.", tostring(sourceSide), tostring(targetSide), originalBlueprint and #originalBlueprint.units or 0)) + SpringShared.Log("BlueprintSubLogic", LOG.DEBUG, string.format("Processing blueprint substitution (in-place) from %s to %s for %d units.", tostring(sourceSide), tostring(targetSide), originalBlueprint and #originalBlueprint.units or 0)) local aggregatedStats = { totalConsidered = 0, @@ -411,12 +411,12 @@ end function BlueprintSubLogic.processBuildQueueSubstitution(originalBuildQueue, sourceSide, targetSide) if not (originalBuildQueue and sourceSide and targetSide) then - Spring.Log("BlueprintSubLogic", LOG.ERROR, "processBuildQueueSubstitution: Called with incomplete arguments (nil sourceSide or targetSide). Review caller logic.") + SpringShared.Log("BlueprintSubLogic", LOG.ERROR, "processBuildQueueSubstitution: Called with incomplete arguments (nil sourceSide or targetSide). Review caller logic.") local errorStats = { totalConsidered = 0, substituted = 0, failedNoMapping = 0, failedInvalidEquivalent = 0, unchangedSameSide = 0, unchangedOther = 0, unchangedNotBuilding = 0, hadMappingFailures = true } return { stats = errorStats, summaryMessage = "Internal error: Incomplete arguments for substitution.", substitutionFailed = true } end - Spring.Log("BlueprintSubLogic", LOG.DEBUG, string.format("Processing build queue substitution (in-place) from %s to %s for %d items.", sourceSide, targetSide, #originalBuildQueue)) + SpringShared.Log("BlueprintSubLogic", LOG.DEBUG, string.format("Processing build queue substitution (in-place) from %s to %s for %d items.", sourceSide, targetSide, #originalBuildQueue)) local aggregatedStats = { totalConsidered = 0, @@ -454,7 +454,7 @@ function BlueprintSubLogic.processBuildQueueSubstitution(originalBuildQueue, sou end else aggregatedStats.unchangedOther = aggregatedStats.unchangedOther + 1 - Spring.Log("BlueprintSubLogic", LOG.DEBUG, string.format("processBuildQueueSubstitution: No MasterBuildingData for %s. Item not substituted.", originalUnitName:lower())) + SpringShared.Log("BlueprintSubLogic", LOG.DEBUG, string.format("processBuildQueueSubstitution: No MasterBuildingData for %s. Item not substituted.", originalUnitName:lower())) end end else @@ -462,7 +462,7 @@ function BlueprintSubLogic.processBuildQueueSubstitution(originalBuildQueue, sou end else aggregatedStats.unchangedNotBuilding = aggregatedStats.unchangedNotBuilding + 1 - Spring.Log("BlueprintSubLogic", LOG.WARNING, string.format("processBuildQueueSubstitution: Skipping malformed item: %s", tostring(bq_item))) + SpringShared.Log("BlueprintSubLogic", LOG.WARNING, string.format("processBuildQueueSubstitution: Skipping malformed item: %s", tostring(bq_item))) end end local summaryMsg, subFailed = _generateSubstitutionSummary(aggregatedStats, "Build queue", sourceSide, targetSide) diff --git a/luaui/Include/blueprint_substitution/reports.lua b/luaui/Include/blueprint_substitution/reports.lua index bb0b17094ad..8f16ab55f07 100644 --- a/luaui/Include/blueprint_substitution/reports.lua +++ b/luaui/Include/blueprint_substitution/reports.lua @@ -31,17 +31,17 @@ local function echoChunked(lines, chunkSize) for j = i, chunkEnd do table.insert(chunkLines, lines[j]) end - Spring.Echo(table.concat(chunkLines, "\n")) + SpringShared.Echo(table.concat(chunkLines, "\n")) end end function REPORTS.SetDependencies(subLogic) - Spring.Log("BlueprintReports", "info", "Receiving dependencies via SetDependencies...") + SpringShared.Log("BlueprintReports", "info", "Receiving dependencies via SetDependencies...") substitutionLogic = subLogic if not substitutionLogic then - Spring.Log("BlueprintReports", "error", "Failed to receive necessary logic tables via SetDependencies!") + SpringShared.Log("BlueprintReports", "error", "Failed to receive necessary logic tables via SetDependencies!") else - Spring.Log("BlueprintReports", "info", "Dependencies received successfully via SetDependencies.") + SpringShared.Log("BlueprintReports", "info", "Dependencies received successfully via SetDependencies.") end end @@ -50,7 +50,7 @@ end -- =================================================================== function REPORTS.generateMappingReport() - Spring.Echo("\n--- Blueprint Mapping Report Start (CSV Format) ---") + SpringShared.Echo("\n--- Blueprint Mapping Report Start (CSV Format) ---") local SIDES = substitutionLogic.SIDES local masterBuildingDataMinimal = substitutionLogic.MasterBuildingData local reportLines = {} @@ -165,7 +165,7 @@ function REPORTS.generateMappingReport() table.insert(uncategorizedUnits["UNKNOWN"], reportLine) end else - Spring.Log("BlueprintReports", "warning", "[Mapping Report] Could not find UnitDef for ID: " .. tostring(buildingCoreData.unitDefID) .. " Name: " .. unitNameLower) + SpringShared.Log("BlueprintReports", "warning", "[Mapping Report] Could not find UnitDef for ID: " .. tostring(buildingCoreData.unitDefID) .. " Name: " .. unitNameLower) end end @@ -185,7 +185,7 @@ function REPORTS.generateMappingReport() end function REPORTS.generateCategoryListReport() - Spring.Echo("\n--- Blueprint Category List Start ---") + SpringShared.Echo("\n--- Blueprint Category List Start ---") local UNIT_CATEGORIES = substitutionLogic.UNIT_CATEGORIES local categoryUnits = substitutionLogic.categoryUnits @@ -202,7 +202,7 @@ function REPORTS.generateCategoryListReport() local reportLines = {} local header = string.format("Found %d defined categories:", #sortedCategories) table.insert(reportLines, header) - Spring.Log("BlueprintReports", "info", "[Category List] " .. header) + SpringShared.Log("BlueprintReports", "info", "[Category List] " .. header) for _, entry in ipairs(sortedCategories) do local categoryName = entry.cat diff --git a/luaui/Include/instancevbotable.lua b/luaui/Include/instancevbotable.lua index ebeff53351d..53f4fdc8ad9 100644 --- a/luaui/Include/instancevbotable.lua +++ b/luaui/Include/instancevbotable.lua @@ -4,7 +4,7 @@ if not LuaVBOTableNewLocationMessageShown then local info = dest.GetInfo() local name = info and info.name or "unknown" local msg = "A user widget (" .. name .. ") is including LuaUI/Include/instancevbotable.lua directly, please change it to use gl.InstanceVBOTable instead." - Spring.Log("UserWidget", LOG.DEPRECATED, msg) + SpringShared.Log("UserWidget", LOG.DEPRECATED, msg) LuaVBOTableNewLocationMessageShown = true end diff --git a/luaui/Include/minimap_utils.lua b/luaui/Include/minimap_utils.lua index 5a4ca1c9cf0..f35b3be80c0 100644 --- a/luaui/Include/minimap_utils.lua +++ b/luaui/Include/minimap_utils.lua @@ -1,9 +1,9 @@ local mapWidth = Game.mapSizeX local mapHeight = Game.mapSizeZ -local spGetMiniMapGeometry = Spring.GetMiniMapGeometry -local spGetGroundHeight = Spring.GetGroundHeight -local spGetMiniMapRotation = Spring.GetMiniMapRotation +local spGetMiniMapGeometry = SpringUnsynced.GetMiniMapGeometry +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetMiniMapRotation = SpringUnsynced.GetMiniMapRotation local math_floor = math.floor local PI_HALF = math.pi / 2 diff --git a/luaui/Include/select_api.lua b/luaui/Include/select_api.lua index 61c9d15ac9a..291d3ec5447 100644 --- a/luaui/Include/select_api.lua +++ b/luaui/Include/select_api.lua @@ -7,17 +7,17 @@ local SelectApi = {} local defaultdamagetag = Game.armorTypes["default"] local vtoldamagetag = Game.armorTypes["vtol"] -local spGetUnitIsCloaked = Spring.GetUnitIsCloaked -local spGetUnitCommands = Spring.GetUnitCommands -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitGroup = Spring.GetUnitGroup -local spGetUnitHealth = Spring.GetUnitHealth -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay -local spIsUnitSelected = Spring.IsUnitSelected -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetUnitPosition = Spring.GetUnitPosition +local spGetUnitIsCloaked = SpringShared.GetUnitIsCloaked +local spGetUnitCommands = SpringShared.GetUnitCommands +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitGroup = SpringUnsynced.GetUnitGroup +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spIsUnitSelected = SpringUnsynced.IsUnitSelected +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetUnitPosition = SpringShared.GetUnitPosition local customFilterLookup = {} local customCommandLookup = {} @@ -51,7 +51,7 @@ local function handleCaching(invert, tokenLower, filterFunction, optionalArg) end local function logError(message) - Spring.Log("Select API", LOG.ERROR, message) + SpringShared.Log("Select API", LOG.ERROR, message) end local function isBuilder(udef) @@ -487,12 +487,12 @@ local function parseConclusion(conclusionDef) if conclusionDefLower == "selectall" then return function(uids) - Spring.SelectUnitArray(uids, appendSelected) + SpringUnsynced.SelectUnitArray(uids, appendSelected) end elseif conclusionDefLower == "selectone" then return function(uids) if #uids == 0 then - Spring.SelectUnitArray({}, appendSelected) + SpringUnsynced.SelectUnitArray({}, appendSelected) return end @@ -500,25 +500,25 @@ local function parseConclusion(conclusionDef) local uid = uids[1] if not uid then - Spring.SelectUnitArray({}, appendSelected) + SpringUnsynced.SelectUnitArray({}, appendSelected) return end -- center on unit local ux, uy, uz = spGetUnitPosition(uid) - Spring.SetCameraTarget(ux, uy, uz, 1) - Spring.SelectUnitArray(uids, appendSelected) + SpringUnsynced.SetCameraTarget(ux, uy, uz, 1) + SpringUnsynced.SelectUnitArray(uids, appendSelected) end elseif conclusionDefLower == "selectclosesttocursor" then return function(uids) if not uids or #uids == 0 then - Spring.SelectUnitArray({}, appendSelected) + SpringUnsynced.SelectUnitArray({}, appendSelected) return end local x, y, z = getMouseWorldPos() if x == nil or y == nil or z == nil then - Spring.SelectUnitArray({}, appendSelected) + SpringUnsynced.SelectUnitArray({}, appendSelected) return end @@ -540,18 +540,18 @@ local function parseConclusion(conclusionDef) end local oneUid = { closest_uid } - Spring.SelectUnitArray(oneUid, appendSelected) + SpringUnsynced.SelectUnitArray(oneUid, appendSelected) end elseif startsWith(conclusionDefLower, "selectnum_") or startsWith(conclusionDefLower, "selectnumber_") then return parseNumber(conclusionDef, function(countUntil, uids) uids = getCountUnits(uids, countUntil, appendSelected) - Spring.SelectUnitArray(uids, appendSelected) + SpringUnsynced.SelectUnitArray(uids, appendSelected) end) elseif startsWith(conclusionDefLower, "selectpart_") then return parseNumber(conclusionDef, function(percent, uids) local countUntil = math.floor(#uids * percent / 100) uids = getCountUnits(uids, countUntil, appendSelected) - Spring.SelectUnitArray(uids, appendSelected) + SpringUnsynced.SelectUnitArray(uids, appendSelected) end) else logError(conclusionDef .. " is not a valid conclusion") @@ -564,12 +564,12 @@ local function parseSource(sourceDef) if sourceDefLower == "allmap" then return function() local myTeamId = Spring.GetMyTeamID() - return Spring.GetTeamUnits(myTeamId) + return SpringShared.GetTeamUnits(myTeamId) end elseif sourceDefLower == "visible" then return function() local myTeamId = Spring.GetMyTeamID() - return Spring.GetVisibleUnits(myTeamId) + return SpringUnsynced.GetVisibleUnits(myTeamId) end elseif sourceDefLower == "prevselection" or sourceDefLower == "previousselection" then return function() @@ -579,7 +579,7 @@ local function parseSource(sourceDef) return parseNumber(sourceDef, function(distance) local x, y, z = getMouseWorldPos() if x and y and z then - return Spring.GetUnitsInSphere(x, y, z, distance) + return SpringShared.GetUnitsInSphere(x, y, z, distance) else return {} end @@ -588,7 +588,7 @@ local function parseSource(sourceDef) return parseNumber(sourceDef, function(distance) local x, y, z = getMouseWorldPos() if x and z then - return Spring.GetUnitsInCylinder(x, z, distance) + return SpringShared.GetUnitsInCylinder(x, z, distance) else return {} end diff --git a/luaui/Include/unitBlocking.lua b/luaui/Include/unitBlocking.lua index 626b4737b8b..13d99ea8a6f 100644 --- a/luaui/Include/unitBlocking.lua +++ b/luaui/Include/unitBlocking.lua @@ -16,17 +16,17 @@ function unitBlocking.getBlockedUnitDefs(unitDefIDs) return {} end - local teamRules = Spring.GetTeamRulesParams(myTeamID) or {} + local teamRules = SpringShared.GetTeamRulesParams(myTeamID) or {} local blockedUnits = {} if unitDefIDs then for i, unitDefID in ipairs(unitDefIDs) do if type(unitDefID) ~= "number" then - Spring.Log("unitBlocking", LOG.ERROR, "getBlockedUnitDefs: unitDefID at index " .. i .. " is not a number (got " .. type(unitDefID) .. ": " .. tostring(unitDefID) .. ")") + SpringShared.Log("unitBlocking", LOG.ERROR, "getBlockedUnitDefs: unitDefID at index " .. i .. " is not a number (got " .. type(unitDefID) .. ": " .. tostring(unitDefID) .. ")") return {} end if not UnitDefs[unitDefID] then - Spring.Log("unitBlocking", LOG.ERROR, "getBlockedUnitDefs: unitDefID " .. unitDefID .. " does not exist in UnitDefs") + SpringShared.Log("unitBlocking", LOG.ERROR, "getBlockedUnitDefs: unitDefID " .. unitDefID .. " does not exist in UnitDefs") return {} end end diff --git a/luaui/RmlWidgets/gui_quick_start/gui_quick_start.lua b/luaui/RmlWidgets/gui_quick_start/gui_quick_start.lua index 8573061423a..ebac7110143 100644 --- a/luaui/RmlWidgets/gui_quick_start/gui_quick_start.lua +++ b/luaui/RmlWidgets/gui_quick_start/gui_quick_start.lua @@ -16,7 +16,7 @@ function widget:GetInfo() } end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() if not modOptions or not modOptions.quick_start then return false @@ -32,7 +32,7 @@ end local shouldApplyFactoryDiscount = modOptions.quick_start == "factory_discount" or (modOptions.quick_start == "default" and (modOptions.temp_enable_territorial_domination or modOptions.deathmode == "territorial_domination")) -local spGetGameRulesParam = Spring.GetGameRulesParam +local spGetGameRulesParam = SpringShared.GetGameRulesParam local spGetMyTeamID = Spring.GetMyTeamID local spI18N = Spring.I18N @@ -144,7 +144,7 @@ local function createBuildRangeCircleDisplayList(commanderX, commanderZ, buildRa return gl.CreateList(function() gl.LineWidth(2) gl.Color(1.0, 0.0, 1.0, 0.7) - local y = Spring.GetGroundHeight(commanderX, commanderZ) + 10 + local y = SpringShared.GetGroundHeight(commanderX, commanderZ) + 10 gl.DrawGroundCircle(commanderX, y, commanderZ, buildRadius, 64) gl.Color(1, 1, 1, 1) gl.LineWidth(1) @@ -187,7 +187,7 @@ local function updateDisplayList(commanderX, commanderZ) for stepIndex = 0, subdivisionCount do local x = segmentStart.x + deltaX * stepIndex local z = segmentStart.z + deltaZ * stepIndex - local y = Spring.GetGroundHeight(x, z) + 10 + local y = SpringShared.GetGroundHeight(x, z) + 10 gl.Vertex(x, y, z) end end) @@ -283,12 +283,12 @@ local function updateTraversabilityGrid() return end - local startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") + local startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") if not startDefID then return end - local commanderX, commanderY, commanderZ = Spring.GetTeamStartPosition(myTeamID) + local commanderX, commanderY, commanderZ = SpringShared.GetTeamStartPosition(myTeamID) -- Returns 0, 0, 0 when none chosen (was -100, -100, -100 previously) local startChosen = (commanderX ~= 0) or (commanderY ~= 0) or (commanderZ ~= 0) if not startChosen then @@ -412,7 +412,7 @@ local function calculateBudgetForItem(unitDefID, gameRules, shouldApplyDiscount, end local function getCommanderPosition(myTeamID) - local commanderX, commanderY, commanderZ = Spring.GetTeamStartPosition(myTeamID) + local commanderX, commanderY, commanderZ = SpringShared.GetTeamStartPosition(myTeamID) return commanderX or 0, commanderZ or 0 end @@ -446,7 +446,7 @@ local function computeProjectedUsage() local budgetProjected = 0 if pregameUnitSelected > 0 and UnitDefs[pregameUnitSelected] then local uDef = UnitDefs[pregameUnitSelected] - local mx, my = Spring.GetMouseState() + local mx, my = SpringUnsynced.GetMouseState() local positionsToCheck = {} local getBuildPositions = wgGetBuildPositionsFunc @@ -455,7 +455,7 @@ local function computeProjectedUsage() if buildPositions and #buildPositions > 0 then positionsToCheck = buildPositions else - local _, pos = Spring.TraceScreenRay(mx, my, true, false, false, uDef.modCategories and uDef.modCategories.underwater) + local _, pos = SpringUnsynced.TraceScreenRay(mx, my, true, false, false, uDef.modCategories and uDef.modCategories.underwater) if pos then positionsToCheck = { { x = pos[1], y = pos[2], z = pos[3] } } end @@ -604,12 +604,12 @@ local function updateDataModel(forceUpdate) if currentQueueLength > widgetState.lastQueueLength then if currentBudgetRemaining < widgetState.lastBudgetRemaining then if modelUpdate.budgetTotal >= modelUpdate.budgetUsed then - Spring.PlaySoundFile("beep6", 0.5, nil, nil, nil, nil, nil, nil, "ui") + SpringUnsynced.PlaySoundFile("beep6", 0.5, nil, nil, nil, nil, nil, nil, "ui") else - Spring.PlaySoundFile("cmd-build", 0.5, nil, nil, nil, nil, nil, nil, "ui") + SpringUnsynced.PlaySoundFile("cmd-build", 0.5, nil, nil, nil, nil, nil, nil, "ui") end elseif widgetState.lastBudgetRemaining == currentBudgetRemaining then - Spring.PlaySoundFile("cmd-build", 1.0, nil, nil, nil, nil, nil, nil, "ui") + SpringUnsynced.PlaySoundFile("cmd-build", 1.0, nil, nil, nil, nil, nil, nil, "ui") end end @@ -735,7 +735,7 @@ end function widget:Initialize() - local isSpectating = Spring.GetSpectatingState() + local isSpectating = SpringUnsynced.GetSpectatingState() if isSpectating then widgetHandler:RemoveWidget(self) end @@ -849,7 +849,7 @@ function widget:Shutdown() end function widget:Update() - local currentGameFrame = Spring.GetGameFrame() + local currentGameFrame = SpringShared.GetGameFrame() if currentGameFrame > 0 then hideWarnings() if wgTopbar and wgTopbar.setResourceBarsVisible then diff --git a/luaui/RmlWidgets/gui_tech_points/gui_tech_points.lua b/luaui/RmlWidgets/gui_tech_points/gui_tech_points.lua index 9a6687da22c..12efa2d6cfc 100644 --- a/luaui/RmlWidgets/gui_tech_points/gui_tech_points.lua +++ b/luaui/RmlWidgets/gui_tech_points/gui_tech_points.lua @@ -16,13 +16,13 @@ function widget:GetInfo() } end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() if not modOptions.tech_blocking then return false end -local spGetTeamRulesParam = Spring.GetTeamRulesParam +local spGetTeamRulesParam = SpringShared.GetTeamRulesParam local spGetMyTeamID = Spring.GetMyTeamID local spI18N = Spring.I18N @@ -121,7 +121,7 @@ local function getTechData() if techBlockingPerTeam then if currentTime - widgetState.lastTeamCountUpdate > CACHE_INTERVAL then local myAllyTeamID = Spring.GetMyAllyTeamID() - local teamList = Spring.GetTeamList(myAllyTeamID) + local teamList = SpringShared.GetTeamList(myAllyTeamID) local newTeamCount = #teamList if newTeamCount ~= widgetState.cachedTeamCount then @@ -214,7 +214,7 @@ local function createTechPointsElements() end local function updatePopups(techLevel) - if not widgetState.initialPopupShown and widgetState.gameStartTime and (popupsEnabled or Spring.GetGameFrame() > POPUP_DELAY_FRAMES) then + if not widgetState.initialPopupShown and widgetState.gameStartTime and (popupsEnabled or SpringShared.GetGameFrame() > POPUP_DELAY_FRAMES) then popupsEnabled = true if widgetState.document then updateUIElementText(widgetState.document, "tech-level-popup", spI18N("ui.techBlocking.techPopup.level1")) @@ -308,7 +308,7 @@ function widget:Initialize() if modOptions.tech_blocking_per_team then local myAllyTeamID = Spring.GetMyAllyTeamID() - local teamList = Spring.GetTeamList(myAllyTeamID) + local teamList = SpringShared.GetTeamList(myAllyTeamID) widgetState.cachedTeamCount = #teamList widgetState.lastTeamCountUpdate = os.clock() widgetState.cachedT2Threshold = baseT2 * widgetState.cachedTeamCount diff --git a/luaui/RmlWidgets/gui_territorial_domination/gui_territorial_domination.lua b/luaui/RmlWidgets/gui_territorial_domination/gui_territorial_domination.lua index a8ebfaadbb3..53da1e9cd30 100644 --- a/luaui/RmlWidgets/gui_territorial_domination/gui_territorial_domination.lua +++ b/luaui/RmlWidgets/gui_territorial_domination/gui_territorial_domination.lua @@ -16,7 +16,7 @@ function widget:GetInfo() } end -local modOptions = Spring.GetModOptions() +local modOptions = SpringShared.GetModOptions() if modOptions.deathmode ~= "territorial_domination" then return false end @@ -27,17 +27,17 @@ end local MODEL_NAME = "territorial_score_model" local RML_PATH = "luaui/RmlWidgets/gui_territorial_domination/gui_territorial_domination.rml" -local spGetTeamRulesParam = Spring.GetTeamRulesParam -local spGetGameRulesParam = Spring.GetGameRulesParam -local spGetAllyTeamList = Spring.GetAllyTeamList -local spGetTeamList = Spring.GetTeamList -local spGetTeamColor = Spring.GetTeamColor -local spGetSpectatingState = Spring.GetSpectatingState +local spGetTeamRulesParam = SpringShared.GetTeamRulesParam +local spGetGameRulesParam = SpringShared.GetGameRulesParam +local spGetAllyTeamList = SpringShared.GetAllyTeamList +local spGetTeamList = SpringShared.GetTeamList +local spGetTeamColor = SpringUnsynced.GetTeamColor +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local spI18N = Spring.I18N -local spGetGaiaTeamID = Spring.GetGaiaTeamID -local spGetTeamInfo = Spring.GetTeamInfo -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetAIInfo = Spring.GetAIInfo +local spGetGaiaTeamID = SpringShared.GetGaiaTeamID +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetAIInfo = SpringShared.GetAIInfo local ColorString = Spring.Utilities.Color.ToString local DEFAULT_MAX_ROUNDS = 7 @@ -148,7 +148,7 @@ end local function getAIName(teamID) local _, _, _, name, _, options = spGetAIInfo(teamID) - local niceName = Spring.GetGameRulesParam("ainame_" .. teamID) + local niceName = SpringShared.GetGameRulesParam("ainame_" .. teamID) if niceName then name = niceName @@ -171,7 +171,7 @@ local function fetchAllyTeamPlayerNames(allyTeamID) local seenPlayerIDs = {} local myTeamID = Spring.GetMyTeamID() local mySpecStatus = spGetSpectatingState() - local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode + local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode for i = 1, #teamList do local teamID = teamList[i] @@ -181,9 +181,9 @@ local function fetchAllyTeamPlayerNames(allyTeamID) local name = getAIName(teamID) local r, g, b = spGetTeamColor(teamID) if (not mySpecStatus) and anonymousMode ~= "disabled" and teamID ~= myTeamID then - local anonymousColorR = Spring.GetConfigInt("anonymousColorR", COLOR_BYTE_MAX) / COLOR_BYTE_MAX - local anonymousColorG = Spring.GetConfigInt("anonymousColorG", 0) / COLOR_BYTE_MAX - local anonymousColorB = Spring.GetConfigInt("anonymousColorB", 0) / COLOR_BYTE_MAX + local anonymousColorR = SpringUnsynced.GetConfigInt("anonymousColorR", COLOR_BYTE_MAX) / COLOR_BYTE_MAX + local anonymousColorG = SpringUnsynced.GetConfigInt("anonymousColorG", 0) / COLOR_BYTE_MAX + local anonymousColorB = SpringUnsynced.GetConfigInt("anonymousColorB", 0) / COLOR_BYTE_MAX r, g, b = anonymousColorR, anonymousColorG, anonymousColorB end @@ -206,9 +206,9 @@ local function fetchAllyTeamPlayerNames(allyTeamID) local r, g, b = spGetTeamColor(teamID) if (not mySpecStatus) and anonymousMode ~= "disabled" and teamID ~= myTeamID then - local anonymousColorR = Spring.GetConfigInt("anonymousColorR", COLOR_BYTE_MAX) / COLOR_BYTE_MAX - local anonymousColorG = Spring.GetConfigInt("anonymousColorG", 0) / COLOR_BYTE_MAX - local anonymousColorB = Spring.GetConfigInt("anonymousColorB", 0) / COLOR_BYTE_MAX + local anonymousColorR = SpringUnsynced.GetConfigInt("anonymousColorR", COLOR_BYTE_MAX) / COLOR_BYTE_MAX + local anonymousColorG = SpringUnsynced.GetConfigInt("anonymousColorG", 0) / COLOR_BYTE_MAX + local anonymousColorB = SpringUnsynced.GetConfigInt("anonymousColorB", 0) / COLOR_BYTE_MAX r, g, b = anonymousColorR, anonymousColorG, anonymousColorB end @@ -474,8 +474,8 @@ end local function checkDocumentVisibility() local pointsCap = spGetGameRulesParam("territorialDominationPointsCap") or DEFAULT_POINTS_CAP - local currentTime = Spring.GetGameSeconds() - local _, _, isClientPaused, _ = Spring.GetGameState() + local currentTime = SpringShared.GetGameSeconds() + local _, _, isClientPaused, _ = SpringUnsynced.GetGameState() local isGameStarted = currentTime > 0 local shouldShow = pointsCap and pointsCap > 0 and isGameStarted and not isClientPaused and not widgetState.hiddenByLobby and widgetState.hasValidAdvPlayerListPosition @@ -534,7 +534,7 @@ local function calculateUILayout() widgetState.hasValidAdvPlayerListPosition = true - local screenWidth, screenHeight = Spring.GetViewGeometry() + local screenWidth, screenHeight = SpringUnsynced.GetViewGeometry() if not screenWidth or screenWidth <= 0 then return end @@ -658,8 +658,8 @@ local function showRoundEndPopup(roundNumber, isFinalRound) popupElement.class_name = "popup-round-end visible" widgetState.popupState.isVisible = true widgetState.popupState.showTime = os.clock() - Spring.PlaySoundFile("sounds/global-events/scavlootdrop.wav", 0.8, "ui") - Spring.PlaySoundFile("sounds/replies/servlrg3.wav", 1.0, "ui") + SpringUnsynced.PlaySoundFile("sounds/global-events/scavlootdrop.wav", 0.8, "ui") + SpringUnsynced.PlaySoundFile("sounds/replies/servlrg3.wav", 1.0, "ui") end local function hideRoundEndPopup() @@ -803,7 +803,7 @@ local function updateRoundInfo() local isCountdownWarning = false if roundEndTime > 0 then - timeRemainingSeconds = math.max(0, roundEndTime - Spring.GetGameSeconds()) + timeRemainingSeconds = math.max(0, roundEndTime - SpringShared.GetGameSeconds()) timeString = string.format("%d:%02d", math.floor(timeRemainingSeconds / SECONDS_PER_MINUTE), math.floor(timeRemainingSeconds % SECONDS_PER_MINUTE)) if timeRemainingSeconds < 1 then timeString = TIME_ZERO_STRING @@ -1059,7 +1059,7 @@ local function resetCache() end local function shouldSkipUpdate() - local currentTime = Spring.GetGameSeconds() + local currentTime = SpringShared.GetGameSeconds() if currentTime <= 0 then return true @@ -1082,12 +1082,12 @@ local function shouldSkipUpdate() end local function shouldUpdateScores() - local currentTime = Spring.GetGameSeconds() + local currentTime = SpringShared.GetGameSeconds() return currentTime - widgetState.lastScoreUpdateTime >= SCORE_UPDATE_INTERVAL end local function shouldUpdateTime() - local currentTime = Spring.GetGameSeconds() + local currentTime = SpringShared.GetGameSeconds() local roundEndTime = spGetGameRulesParam("territorialDominationRoundEndTimestamp") or 0 if roundEndTime <= 0 then @@ -1102,7 +1102,7 @@ local function shouldUpdateTime() end local function shouldFullUpdate() - local currentTime = Spring.GetGameSeconds() + local currentTime = SpringShared.GetGameSeconds() return currentTime - widgetState.lastUpdateTime >= UPDATE_INTERVAL end @@ -1204,7 +1204,7 @@ function widget:Initialize() widgetState.dmHandle = dmHandle - local language = Spring.GetConfigString("language", "en") + local language = SpringUnsynced.GetConfigString("language", "en") local document = widgetState.rmlContext:LoadDocument(RML_PATH, self) if not document then @@ -1245,12 +1245,12 @@ function widget:Initialize() end resetCache() - widgetState.lastUpdateTime = Spring.GetGameSeconds() - widgetState.lastScoreUpdateTime = Spring.GetGameSeconds() - widgetState.lastTimeUpdateTime = Spring.GetGameSeconds() + widgetState.lastUpdateTime = SpringShared.GetGameSeconds() + widgetState.lastScoreUpdateTime = SpringShared.GetGameSeconds() + widgetState.lastTimeUpdateTime = SpringShared.GetGameSeconds() calculateUILayout() - if Spring.GetGameSeconds() > 0 then + if SpringShared.GetGameSeconds() > 0 then updateDataModel() updateCountdownColor() end @@ -1296,7 +1296,7 @@ function widget:Shutdown() end function widget:Update() - local currentTime = Spring.GetGameSeconds() + local currentTime = SpringShared.GetGameSeconds() local currentOSClock = os.clock() checkDocumentVisibility() @@ -1360,7 +1360,7 @@ function widget:KeyPress(key) end function widget:DrawScreen() - if Spring.GetGameSeconds() <= 0 then + if SpringShared.GetGameSeconds() <= 0 then return end end diff --git a/luaui/RmlWidgets/rml_context_manager.lua b/luaui/RmlWidgets/rml_context_manager.lua index 0fe7b401750..1fc16836eba 100644 --- a/luaui/RmlWidgets/rml_context_manager.lua +++ b/luaui/RmlWidgets/rml_context_manager.lua @@ -17,8 +17,8 @@ function widget:GetInfo() end local function calculateDpRatio() - local viewSizeX, viewSizeY = Spring.GetViewGeometry() - local userScale = Spring.GetConfigFloat("ui_scale", 1) + local viewSizeX, viewSizeY = SpringUnsynced.GetViewGeometry() + local userScale = SpringUnsynced.GetConfigFloat("ui_scale", 1) local baseWidth = 1920 local baseHeight = 1080 local resFactor = math.min(viewSizeX / baseWidth, viewSizeY / baseHeight) @@ -48,5 +48,5 @@ end -- include also a listener for the ui_scale config variable changes function widget:Shutdown() - Spring.Echo("Rml Context Manager shutdown, dynamic context dp ratio updates to contexts disabled.") + SpringShared.Echo("Rml Context Manager shutdown, dynamic context dp ratio updates to contexts disabled.") end diff --git a/luaui/Scenarios/stresstest/circle_attack.lua b/luaui/Scenarios/stresstest/circle_attack.lua index 9a0a85475c4..5f7586d3240 100644 --- a/luaui/Scenarios/stresstest/circle_attack.lua +++ b/luaui/Scenarios/stresstest/circle_attack.lua @@ -1,18 +1,18 @@ VFS.Include("luaui/Scenarios/stresstest/multi_attack.lua") function radius_attack(targetsCenter, nattackers) - local y = Spring.GetGroundHeight(targetsCenter[1], targetsCenter[2]) + local y = SpringShared.GetGroundHeight(targetsCenter[1], targetsCenter[2]) local targetPosition = { targetsCenter[1], y + 5, targetsCenter[2], targetsCenter[3] } local CMD_ATTACK = CMD.ATTACK -- get units - local spGetUnitDefID = Spring.GetUnitDefID + local spGetUnitDefID = SpringShared.GetUnitDefID local attackers = table.new and table.new(nattackers) or {} local attackerDefID = UnitDefNames[Scenario.attackerDef].id - local all_units = Spring.GetAllUnits() + local all_units = SpringShared.GetAllUnits() for _, unitID in ipairs(all_units) do local unitDefID = spGetUnitDefID(unitID) if unitDefID == attackerDefID then @@ -21,9 +21,9 @@ function radius_attack(targetsCenter, nattackers) end -- give order - Spring.SelectUnitArray(attackers) - Spring.GiveOrder(CMD_ATTACK, targetPosition, 0) - Spring.SelectUnitArray({}) + SpringUnsynced.SelectUnitArray(attackers) + SpringUnsynced.GiveOrder(CMD_ATTACK, targetPosition, 0) + SpringUnsynced.SelectUnitArray({}) end function test() @@ -37,11 +37,11 @@ function test() local doCircle = true local circle = SyncedRun(synced_setup) - Spring.Echo("init time preinit:", os.clock() - t0) + SpringShared.Echo("init time preinit:", os.clock() - t0) Test.waitFrames(1) radius_attack(circle, nattackers) - Spring.Echo("total time:", os.clock() - t0) + SpringShared.Echo("total time:", os.clock() - t0) end diff --git a/luaui/Scenarios/stresstest/multi_attack.lua b/luaui/Scenarios/stresstest/multi_attack.lua index 6b516001c00..baf52e38262 100644 --- a/luaui/Scenarios/stresstest/multi_attack.lua +++ b/luaui/Scenarios/stresstest/multi_attack.lua @@ -1,6 +1,6 @@ function skip() - return Spring.GetGameFrame() <= 0 + return SpringShared.GetGameFrame() <= 0 end function scenario_arguments() @@ -11,13 +11,13 @@ function setup() -- test on quicksilver remake 1.24 Test.clearMap() - Spring.SetCameraTarget(Game.mapSizeX / 2, 50, Game.mapSizeZ / 2 - 500, 0.5) + SpringUnsynced.SetCameraTarget(Game.mapSizeX / 2, 50, Game.mapSizeZ / 2 - 500, 0.5) end function synced_setup(locals) local function createUnitAt(unitdefname, x, z, teamID) - local y = Spring.GetGroundHeight(x, z) - return Spring.CreateUnit(unitdefname, x, y, z, 1, teamID) + local y = SpringShared.GetGroundHeight(x, z) + return SpringSynced.CreateUnit(unitdefname, x, y, z, 1, teamID) end local doCircle = locals.doCircle @@ -62,7 +62,7 @@ function synced_setup(locals) end -- make sure the attackers don't have other orders for _, unitID in pairs(attackers) do - Spring.GiveOrderToUnit(unitID, CMD.STOP, 0, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, 0, 0) end return circle end @@ -79,20 +79,20 @@ function run_commands(nattackers, ntargets, attackerDef, targetDef) local shiftOpts = { "shift" } local currOpt local CMD_ATTACK = CMD.ATTACK - local spGiveOrderToUnit = Spring.GiveOrderToUnit + local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit local attackerTeam = 0 local defenderTeam = 1 -- get units - local spGetUnitDefID = Spring.GetUnitDefID - local spGetUnitTeam = Spring.GetUnitTeam + local spGetUnitDefID = SpringShared.GetUnitDefID + local spGetUnitTeam = SpringShared.GetUnitTeam local attackers = table.new and table.new(nattackers) or {} local targets = table.new and table.new(ntargets) or {} local attackerDefID = UnitDefNames[attackerDef].id local targetDefID = UnitDefNames[targetDef].id - local all_units = Spring.GetAllUnits() + local all_units = SpringShared.GetAllUnits() for _, unitID in ipairs(all_units) do local unitDefID = spGetUnitDefID(unitID) local unitTeamID = spGetUnitTeam(unitID) @@ -124,11 +124,11 @@ function test() local radarDef = Scenario.radarDef SyncedRun(synced_setup) - Spring.Echo("init time preinit:", os.clock() - t0) + SpringShared.Echo("init time preinit:", os.clock() - t0) Test.waitFrames(1) SyncedRun(run_commands) - Spring.Echo("total time:", os.clock() - t0) + SpringShared.Echo("total time:", os.clock() - t0) end diff --git a/luaui/Scenarios/stresstest/multi_unsynced_attack.lua b/luaui/Scenarios/stresstest/multi_unsynced_attack.lua index d7b0e129def..acc0aad70ea 100644 --- a/luaui/Scenarios/stresstest/multi_unsynced_attack.lua +++ b/luaui/Scenarios/stresstest/multi_unsynced_attack.lua @@ -10,11 +10,11 @@ function test() local radarDef = Scenario.radarDef SyncedRun(synced_setup) - Spring.Echo("init time preinit:", os.clock() - t0) + SpringShared.Echo("init time preinit:", os.clock() - t0) Test.waitFrames(1) run_commands(nattackers, ntargets, attackerDef, targetDef) - Spring.Echo("total time:", os.clock() - t0) + SpringShared.Echo("total time:", os.clock() - t0) end diff --git a/luaui/Scenarios/stresstest/nano_commands.lua b/luaui/Scenarios/stresstest/nano_commands.lua index 90eff25ad3e..8c5eb51f9ee 100644 --- a/luaui/Scenarios/stresstest/nano_commands.lua +++ b/luaui/Scenarios/stresstest/nano_commands.lua @@ -1,6 +1,6 @@ function skip() - return Spring.GetGameFrame() <= 0 + return SpringShared.GetGameFrame() <= 0 end function scenario_arguments() @@ -11,13 +11,13 @@ function setup() -- test on quicksilver remake 1.24 Test.clearMap() - Spring.SetCameraTarget(Game.mapSizeX / 2 + 500, 50, Game.mapSizeZ / 2 - 500, 0.5) + SpringUnsynced.SetCameraTarget(Game.mapSizeX / 2 + 500, 50, Game.mapSizeZ / 2 - 500, 0.5) end function synced_nano_setup(locals) local function createUnitAt(unitdefname, x, z, teamID) - local y = Spring.GetGroundHeight(x, z) - return Spring.CreateUnit(unitdefname, x, y, z, 1, teamID) + local y = SpringShared.GetGroundHeight(x, z) + return SpringSynced.CreateUnit(unitdefname, x, y, z, 1, teamID) end local colturrets = 5 @@ -48,7 +48,7 @@ function synced_nano_setup(locals) end -- make sure the turrets don't have other orders for _, unitID in pairs(turrets) do - Spring.GiveOrderToUnit(unitID, CMD.STOP, 0, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, 0, 0) end end @@ -63,17 +63,17 @@ function run_nano_commands(nturrets, ntargets, turretDef, targetDef) local shiftOpts = { "shift" } local currOpt local CMD_RECLAIM = CMD.RECLAIM - local spGiveOrderToUnit = Spring.GiveOrderToUnit + local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit -- get units - local spGetUnitDefID = Spring.GetUnitDefID + local spGetUnitDefID = SpringShared.GetUnitDefID local turrets = table.new and table.new(nturrets) or {} local targets = table.new and table.new(ntargets) or {} local turretDefID = UnitDefNames[turretDef].id local targetDefID = UnitDefNames[targetDef].id - local all_units = Spring.GetAllUnits() + local all_units = SpringShared.GetAllUnits() for _, unitID in ipairs(all_units) do local unitDefID = spGetUnitDefID(unitID) if unitDefID == turretDefID then @@ -103,11 +103,11 @@ function test() local targetDef = Scenario.targetDef SyncedRun(synced_nano_setup) - Spring.Echo("init time preinit:", os.clock() - t0) + SpringShared.Echo("init time preinit:", os.clock() - t0) Test.waitFrames(1) SyncedRun(run_nano_commands) - Spring.Echo("total time:", os.clock() - t0) + SpringShared.Echo("total time:", os.clock() - t0) end diff --git a/luaui/Scenarios/stresstest/nano_unsynced_commands.lua b/luaui/Scenarios/stresstest/nano_unsynced_commands.lua index 5207e8ee576..53a865f6561 100644 --- a/luaui/Scenarios/stresstest/nano_unsynced_commands.lua +++ b/luaui/Scenarios/stresstest/nano_unsynced_commands.lua @@ -9,11 +9,11 @@ function test() local targetDef = Scenario.targetDef SyncedRun(synced_nano_setup) - Spring.Echo("init time preinit:", os.clock() - t0) + SpringShared.Echo("init time preinit:", os.clock() - t0) Test.waitFrames(1) run_nano_commands(nturrets, ntargets, turretDef, targetDef) - Spring.Echo("total time:", os.clock() - t0) + SpringShared.Echo("total time:", os.clock() - t0) end diff --git a/luaui/Scenarios/stresstest/unsynced_attack.lua b/luaui/Scenarios/stresstest/unsynced_attack.lua index bebef345353..af51a4c8162 100644 --- a/luaui/Scenarios/stresstest/unsynced_attack.lua +++ b/luaui/Scenarios/stresstest/unsynced_attack.lua @@ -1,14 +1,14 @@ VFS.Include("luaui/Scenarios/stresstest/multi_attack.lua") function radius_attack(attackers, targetsCenter) - local y = Spring.GetGroundHeight(targetsCenter[1], targetsCenter[2]) + local y = SpringShared.GetGroundHeight(targetsCenter[1], targetsCenter[2]) local targetPosition = { targetsCenter[1], y + 5, targetsCenter[2], targetsCenter[3] } local CMD_ATTACK = CMD.ATTACK - local spGiveOrderToUnit = Spring.GiveOrderToUnit + local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit - Spring.SelectUnitArray(attackers) - Spring.GiveOrder(CMD_ATTACK, targetPosition, 0) + SpringUnsynced.SelectUnitArray(attackers) + SpringUnsynced.GiveOrder(CMD_ATTACK, targetPosition, 0) end function test() @@ -26,5 +26,5 @@ function test() radius_attack(attackers, targetsCenter) - Spring.Echo("total time:", os.clock() - t0) + SpringShared.Echo("total time:", os.clock() - t0) end diff --git a/luaui/Tests/cmd_blueprint/test_cmd_blueprint_filter.lua b/luaui/Tests/cmd_blueprint/test_cmd_blueprint_filter.lua index 6d2a2ecf8a2..650de2ab76d 100644 --- a/luaui/Tests/cmd_blueprint/test_cmd_blueprint_filter.lua +++ b/luaui/Tests/cmd_blueprint/test_cmd_blueprint_filter.lua @@ -13,9 +13,9 @@ function setup() widget = Test.prepareWidget(widgetName) - initialCameraState = Spring.GetCameraState() + initialCameraState = SpringUnsynced.GetCameraState() - Spring.SetCameraState({ + SpringUnsynced.SetCameraState({ mode = 5, }) end @@ -23,7 +23,7 @@ end function cleanup() Test.clearMap() - Spring.SetCameraState(initialCameraState) + SpringUnsynced.SetCameraState(initialCameraState) end local delay = 5 @@ -42,18 +42,18 @@ function test() local myTeamID = Spring.GetMyTeamID() local x, z = Game.mapSizeX / 2, Game.mapSizeZ / 2 - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) local facing = 1 local builderUnitID = SyncedRun(function(locals) - return Spring.CreateUnit(locals.builderUnitDefName, locals.x, locals.y, locals.z, locals.facing, locals.myTeamID) + return SpringSynced.CreateUnit(locals.builderUnitDefName, locals.x, locals.y, locals.z, locals.facing, locals.myTeamID) end) - Spring.SelectUnit(builderUnitID) + SpringUnsynced.SelectUnit(builderUnitID) Test.waitFrames(delay) - Spring.SetActiveCommand(Spring.GetCmdDescIndex(GameCMD.BLUEPRINT_PLACE), 1, true, false, false, false, false, false) + SpringUnsynced.SetActiveCommand(SpringUnsynced.GetCmdDescIndex(GameCMD.BLUEPRINT_PLACE), 1, true, false, false, false, false, false) Test.waitFrames(delay) diff --git a/luaui/Tests/cmd_blueprint/test_cmd_blueprint_line.lua b/luaui/Tests/cmd_blueprint/test_cmd_blueprint_line.lua index 1a057eef6ac..d78632e5256 100644 --- a/luaui/Tests/cmd_blueprint/test_cmd_blueprint_line.lua +++ b/luaui/Tests/cmd_blueprint/test_cmd_blueprint_line.lua @@ -14,9 +14,9 @@ function setup() assert(widget) mock_saveBlueprintsToFile = Test.mock(widget, "saveBlueprintsToFile") - initialCameraState = Spring.GetCameraState() + initialCameraState = SpringUnsynced.GetCameraState() - Spring.SetCameraState({ + SpringUnsynced.SetCameraState({ mode = 5, }) end @@ -24,7 +24,7 @@ end function cleanup() Test.clearMap() - Spring.SetCameraState(initialCameraState) + SpringUnsynced.SetCameraState(initialCameraState) end local delay = 5 @@ -42,17 +42,17 @@ function test() local myTeamID = Spring.GetMyTeamID() local x, z = Game.mapSizeX / 2, Game.mapSizeZ / 2 - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) local facing = 1 local bpW, bpH = WG["api_blueprint"].getBuildingDimensions(blueprintUnitDefID, facing) local bpCount = 5 local blueprintUnitID = SyncedRun(function(locals) - return Spring.CreateUnit(locals.blueprintUnitDefName, locals.x, locals.y, locals.z, locals.facing, locals.myTeamID) + return SpringSynced.CreateUnit(locals.blueprintUnitDefName, locals.x, locals.y, locals.z, locals.facing, locals.myTeamID) end) - Spring.SelectUnit(blueprintUnitID) + SpringUnsynced.SelectUnit(blueprintUnitID) Test.waitFrames(delay) @@ -63,14 +63,14 @@ function test() Test.clearMap() local builderUnitID = SyncedRun(function(locals) - return Spring.CreateUnit(locals.builderUnitDefName, locals.x + 100, locals.y, locals.z, locals.facing, locals.myTeamID) + return SpringSynced.CreateUnit(locals.builderUnitDefName, locals.x + 100, locals.y, locals.z, locals.facing, locals.myTeamID) end) - Spring.SelectUnit(builderUnitID) + SpringUnsynced.SelectUnit(builderUnitID) Test.waitFrames(delay) - Spring.SetActiveCommand(Spring.GetCmdDescIndex(GameCMD.BLUEPRINT_PLACE), 1, true, false, false, false, false, false) + SpringUnsynced.SetActiveCommand(SpringUnsynced.GetCmdDescIndex(GameCMD.BLUEPRINT_PLACE), 1, true, false, false, false, false, false) Test.waitFrames(delay) @@ -81,17 +81,17 @@ function test() end) mockSpringGetMouseState = Test.mock(widget, "SpringGetMouseState", function() - local mx, my = Spring.GetMouseState() + local mx, my = SpringUnsynced.GetMouseState() return mx, my, true end) - local sx, sy = Spring.WorldToScreenCoords(x, y, z) - Spring.WarpMouse(sx, sy) + local sx, sy = SpringUnsynced.WorldToScreenCoords(x, y, z) + SpringUnsynced.WarpMouse(sx, sy) Script.LuaUI.MousePress(sx, sy, 1) - sx, sy = Spring.WorldToScreenCoords(x, y, z + bpH * (bpCount - 1)) - Spring.WarpMouse(sx, sy) + sx, sy = SpringUnsynced.WorldToScreenCoords(x, y, z + bpH * (bpCount - 1)) + SpringUnsynced.WarpMouse(sx, sy) Test.waitFrames(delay) @@ -100,7 +100,7 @@ function test() Test.waitFrames(delay) - local builderQueue = Spring.GetUnitCommands(builderUnitID, -1) + local builderQueue = SpringShared.GetUnitCommands(builderUnitID, -1) assert(#builderQueue == bpCount, #builderQueue) assert(builderQueue[1].id == -blueprintUnitDefID) diff --git a/luaui/Tests/cmd_blueprint/test_cmd_blueprint_single.lua b/luaui/Tests/cmd_blueprint/test_cmd_blueprint_single.lua index fffc10a4f67..6715f0f5198 100644 --- a/luaui/Tests/cmd_blueprint/test_cmd_blueprint_single.lua +++ b/luaui/Tests/cmd_blueprint/test_cmd_blueprint_single.lua @@ -9,9 +9,9 @@ function setup() mock_saveBlueprintsToFile = Test.mock(widget, "saveBlueprintsToFile") - initialCameraState = Spring.GetCameraState() + initialCameraState = SpringUnsynced.GetCameraState() - Spring.SetCameraState({ + SpringUnsynced.SetCameraState({ mode = 5, }) end @@ -19,7 +19,7 @@ end function cleanup() Test.clearMap() - Spring.SetCameraState(initialCameraState) + SpringUnsynced.SetCameraState(initialCameraState) end local delay = 5 @@ -37,14 +37,14 @@ function test() local myTeamID = Spring.GetMyTeamID() local x, z = Game.mapSizeX / 2, Game.mapSizeZ / 2 - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) local facing = 1 local blueprintUnitID = SyncedRun(function(locals) - return Spring.CreateUnit(locals.blueprintUnitDefName, locals.x, locals.y, locals.z, locals.facing, locals.myTeamID) + return SpringSynced.CreateUnit(locals.blueprintUnitDefName, locals.x, locals.y, locals.z, locals.facing, locals.myTeamID) end) - Spring.SelectUnit(blueprintUnitID) + SpringUnsynced.SelectUnit(blueprintUnitID) Test.waitFrames(delay) @@ -55,21 +55,21 @@ function test() Test.clearMap() local builderUnitID = SyncedRun(function(locals) - return Spring.CreateUnit(locals.builderUnitDefName, locals.x + 100, locals.y, locals.z, locals.facing, locals.myTeamID) + return SpringSynced.CreateUnit(locals.builderUnitDefName, locals.x + 100, locals.y, locals.z, locals.facing, locals.myTeamID) end) - Spring.SelectUnit(builderUnitID) + SpringUnsynced.SelectUnit(builderUnitID) Test.waitFrames(delay) - Spring.SetActiveCommand(Spring.GetCmdDescIndex(GameCMD.BLUEPRINT_PLACE), 1, true, false, false, false, false, false) + SpringUnsynced.SetActiveCommand(SpringUnsynced.GetCmdDescIndex(GameCMD.BLUEPRINT_PLACE), 1, true, false, false, false, false, false) Test.waitFrames(delay) assert(widget.blueprintPlacementActive) - local sx, sy = Spring.WorldToScreenCoords(x, y, z) - Spring.WarpMouse(sx, sy) + local sx, sy = SpringUnsynced.WorldToScreenCoords(x, y, z) + SpringUnsynced.WarpMouse(sx, sy) Test.waitFrames(delay) @@ -77,7 +77,7 @@ function test() Test.waitFrames(delay) - local builderQueue = Spring.GetUnitCommands(builderUnitID, -1) + local builderQueue = SpringShared.GetUnitCommands(builderUnitID, -1) assert(#builderQueue == 1) assert(builderQueue[1].id == -blueprintUnitDefID) diff --git a/luaui/Tests/cmd_stop_selfd/test_cmd_stop_selfd.lua b/luaui/Tests/cmd_stop_selfd/test_cmd_stop_selfd.lua index f5e23db7010..26830c3633d 100644 --- a/luaui/Tests/cmd_stop_selfd/test_cmd_stop_selfd.lua +++ b/luaui/Tests/cmd_stop_selfd/test_cmd_stop_selfd.lua @@ -1,5 +1,5 @@ function skip() - return Spring.GetGameFrame() <= 0 + return SpringShared.GetGameFrame() <= 0 end function setup() @@ -20,28 +20,28 @@ function test() unitID = SyncedRun(function(locals) local x, z = Game.mapSizeX / 2, Game.mapSizeZ / 2 - local y = Spring.GetGroundHeight(x, z) - return Spring.CreateUnit("armpw", x, y, z, 0, locals.myTeamID) + local y = SpringShared.GetGroundHeight(x, z) + return SpringSynced.CreateUnit("armpw", x, y, z, 0, locals.myTeamID) end) -- issue selfd and then issue stop - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) Test.waitUntilCallinArgs("UnitCommand", { nil, nil, nil, CMD.SELFD, nil, nil, nil }) - assert(Spring.GetUnitSelfDTime(unitID) > 0) + assert(SpringShared.GetUnitSelfDTime(unitID) > 0) - Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) Test.waitUntilCallinArgs("UnitCommand", { nil, nil, nil, CMD.SELFD, nil, nil, nil }) - assert(Spring.GetUnitSelfDTime(unitID) == 0) - assert(Spring.GetUnitCommandCount(unitID) == 0) + assert(SpringShared.GetUnitSelfDTime(unitID) == 0) + assert(SpringShared.GetUnitCommandCount(unitID) == 0) -- issue {move, selfd}, then issue stop - Spring.GiveOrderToUnit(unitID, CMD.MOVE, { 1, 1, 1 }, 0) - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, { "shift" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.MOVE, { 1, 1, 1 }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, { "shift" }) Test.waitUntilCallinArgs("UnitCommand", { nil, nil, nil, CMD.SELFD, nil, nil, nil }) - assert(Spring.GetUnitSelfDTime(unitID) == 0) + assert(SpringShared.GetUnitSelfDTime(unitID) == 0) - Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) Test.waitUntilCallinArgs("UnitCommand", { nil, nil, nil, CMD.STOP, nil, nil, nil }) - assert(Spring.GetUnitSelfDTime(unitID) == 0) - assert(Spring.GetUnitCommandCount(unitID) == 0) + assert(SpringShared.GetUnitSelfDTime(unitID) == 0) + assert(SpringShared.GetUnitCommandCount(unitID) == 0) end diff --git a/luaui/Tests/critters/test_critters.lua b/luaui/Tests/critters/test_critters.lua index 81f560036df..5859c430c1a 100644 --- a/luaui/Tests/critters/test_critters.lua +++ b/luaui/Tests/critters/test_critters.lua @@ -7,13 +7,13 @@ function setup() Test.clearMap() Test.levelHeightMap() - Spring.SendCommands("globallos") - Spring.SendCommands("setspeed 5") + SpringUnsynced.SendCommands("globallos") + SpringUnsynced.SendCommands("setspeed 5") end function cleanup() - Spring.SendCommands("globallos") - Spring.SendCommands("setspeed 1") + SpringUnsynced.SendCommands("globallos") + SpringUnsynced.SendCommands("setspeed 1") Test.clearMap() end @@ -32,13 +32,13 @@ function runCritterTest() end local midX, midZ = Game.mapSizeX / 2, Game.mapSizeZ / 2 - local GaiaTeamID = Spring.GetGaiaTeamID() + local GaiaTeamID = SpringShared.GetGaiaTeamID() -- helper: count living critters local function countAliveCritters() local alive = 0 - for _, unitID in ipairs(Spring.GetAllUnits()) do - local defID = Spring.GetUnitDefID(unitID) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + local defID = SpringShared.GetUnitDefID(unitID) if isCritter[defID] then alive = alive + 1 end @@ -51,15 +51,15 @@ function runCritterTest() ------------------------------------------------------- SyncedRun( function(locals) - local GaiaTeamID = Spring.GetGaiaTeamID() + local GaiaTeamID = SpringShared.GetGaiaTeamID() local critterName = locals.critterName local midX, midZ = locals.midX, locals.midZ local function createUnit(def, x, z) x = midX + x z = midZ + z - local y = Spring.GetGroundHeight(x, z) + 40 - Spring.CreateUnit(def, x, y, z, "south", GaiaTeamID) + local y = SpringShared.GetGroundHeight(x, z) + 40 + SpringSynced.CreateUnit(def, x, y, z, "south", GaiaTeamID) end for i = 0, 5 do @@ -77,7 +77,7 @@ function runCritterTest() ) assertSuccessBefore(5, 5, function() - return #Spring.GetAllUnits() == 36 + return #SpringShared.GetAllUnits() == 36 end) assert(countAliveCritters() == 36) @@ -98,7 +98,7 @@ function runCritterTest() SyncedRun( function(locals) local midX, midZ = locals.midX, locals.midZ - local spCreateUnit = Spring.CreateUnit + local spCreateUnit = SpringSynced.CreateUnit local pressureUnits = locals.pressureUnits local unitName = locals.unitName local sx, sz = locals.sx, locals.sz @@ -108,7 +108,7 @@ function runCritterTest() for j = 0, batchSize - 1 do local x = midX + sx + i * spacing local z = midZ + sz + j * spacing - local y = Spring.GetGroundHeight(x, z) + 40 + local y = SpringShared.GetGroundHeight(x, z) + 40 local unitID = spCreateUnit(unitName, x, y, z, "south", 0) if unitID then pressureUnits[#pressureUnits + 1] = unitID @@ -138,11 +138,11 @@ function runCritterTest() assertSuccessBefore(30, 10, function() local aliveCount = 0 for _, unitID in ipairs(pressureUnits) do - if Spring.ValidUnitID(unitID) then + if SpringShared.ValidUnitID(unitID) then aliveCount = aliveCount + 1 end end - Spring.Echo("Pressure units spawned:", aliveCount) + SpringShared.Echo("Pressure units spawned:", aliveCount) return aliveCount >= 2000 end) @@ -157,8 +157,8 @@ function runCritterTest() SyncedRun( function(locals) for _, unitID in ipairs(locals.pressureUnits) do - if Spring.ValidUnitID(unitID) then - Spring.DestroyUnit(unitID, false, true, nil, true) + if SpringShared.ValidUnitID(unitID) then + SpringSynced.DestroyUnit(unitID, false, true, nil, true) end end end, @@ -173,7 +173,7 @@ function runCritterTest() assertSuccessBefore(15, 5, function() for _, unitID in ipairs(pressureUnits) do - if Spring.ValidUnitID(unitID) then + if SpringShared.ValidUnitID(unitID) then return false end end @@ -183,7 +183,7 @@ function runCritterTest() ------------------------------------------------------- -- 4. Wait for critter restore tick ------------------------------------------------------- - Test.waitFrames(WAIT_FRAMES - (Spring.GetGameFrame() % WAIT_FRAMES)) + Test.waitFrames(WAIT_FRAMES - (SpringShared.GetGameFrame() % WAIT_FRAMES)) assert(countAliveCritters() == 36) end diff --git a/luaui/Tests/gui_pip/test_gui_pip_autostart_maximize.lua b/luaui/Tests/gui_pip/test_gui_pip_autostart_maximize.lua index e43efe4a5a8..380ef3e8913 100644 --- a/luaui/Tests/gui_pip/test_gui_pip_autostart_maximize.lua +++ b/luaui/Tests/gui_pip/test_gui_pip_autostart_maximize.lua @@ -2,13 +2,13 @@ local widgetName = "Picture-in-Picture" local originalGetSpectatingState = nil function skip() - return Spring.GetGameFrame() <= 0 or widgetHandler.knownWidgets[widgetName] == nil + return SpringShared.GetGameFrame() <= 0 or widgetHandler.knownWidgets[widgetName] == nil end function setup() Test.clearMap() - originalGetSpectatingState = Spring.GetSpectatingState - Spring.GetSpectatingState = function() + originalGetSpectatingState = SpringUnsynced.GetSpectatingState + SpringUnsynced.GetSpectatingState = function() return false, false end widget = Test.prepareWidget(widgetName) @@ -17,15 +17,15 @@ end function cleanup() if originalGetSpectatingState ~= nil then - Spring.GetSpectatingState = originalGetSpectatingState + SpringUnsynced.GetSpectatingState = originalGetSpectatingState originalGetSpectatingState = nil end Test.clearMap() end function test() - local vsx, vsy = Spring.GetViewGeometry() - local uiScale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) + local vsx, vsy = SpringUnsynced.GetViewGeometry() + local uiScale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) local widgetScale = (vsy / 2000) * uiScale local minExpandedSize = math.floor(125 * widgetScale) diff --git a/luaui/Tests/gui_selfd_icons/test_gui_selfd_icons_armpw.lua b/luaui/Tests/gui_selfd_icons/test_gui_selfd_icons_armpw.lua index 1345068b2e8..1a77f9af619 100644 --- a/luaui/Tests/gui_selfd_icons/test_gui_selfd_icons_armpw.lua +++ b/luaui/Tests/gui_selfd_icons/test_gui_selfd_icons_armpw.lua @@ -1,7 +1,7 @@ local widgetName = "Self-Destruct Icons" function skip() - return Spring.GetGameFrame() <= 0 + return SpringShared.GetGameFrame() <= 0 end function setup() @@ -19,36 +19,36 @@ function test() assert(widget) local x, z = Game.mapSizeX / 2, Game.mapSizeZ / 2 - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) unitID = SyncedRun(function(locals) - return Spring.CreateUnit("armpw", locals.x, locals.y, locals.z, 0, 0) + return SpringSynced.CreateUnit("armpw", locals.x, locals.y, locals.z, 0, 0) end) assert(table.count(widget.activeSelfD) == 0) assert(table.count(widget.queuedSelfD) == 0) -- standard selfd command - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) Test.waitFrames(1) assert(table.count(widget.activeSelfD) == 1) assert(table.count(widget.queuedSelfD) == 0) -- cancel selfd order - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) Test.waitFrames(1) assert(table.count(widget.activeSelfD) == 0) assert(table.count(widget.queuedSelfD) == 0) -- queued selfd order - Spring.GiveOrderToUnit(unitID, CMD.MOVE, { 1, 1, 1 }, 0) - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, { "shift" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.MOVE, { 1, 1, 1 }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, { "shift" }) Test.waitFrames(1) assert(table.count(widget.activeSelfD) == 0) assert(table.count(widget.queuedSelfD) == 1) -- remove move order - Spring.GiveOrderToUnit(unitID, CMD.REMOVE, { CMD.MOVE }, { "alt" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.REMOVE, { CMD.MOVE }, { "alt" }) Test.waitFrames(1) assert(table.count(widget.activeSelfD) == 1) assert(table.count(widget.queuedSelfD) == 0) diff --git a/luaui/Tests/gui_selfd_icons/test_gui_selfd_icons_armvp.lua b/luaui/Tests/gui_selfd_icons/test_gui_selfd_icons_armvp.lua index 4f31a1d7e85..65b7766d3f1 100644 --- a/luaui/Tests/gui_selfd_icons/test_gui_selfd_icons_armvp.lua +++ b/luaui/Tests/gui_selfd_icons/test_gui_selfd_icons_armvp.lua @@ -1,7 +1,7 @@ local widgetName = "Self-Destruct Icons" function skip() - return Spring.GetGameFrame() <= 0 + return SpringShared.GetGameFrame() <= 0 end function setup() @@ -19,23 +19,23 @@ function test() assert(widget) local x, z = Game.mapSizeX / 2, Game.mapSizeZ / 2 - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) unitID = SyncedRun(function(locals) - return Spring.CreateUnit("armvp", locals.x, locals.y, locals.z, 0, 0) + return SpringSynced.CreateUnit("armvp", locals.x, locals.y, locals.z, 0, 0) end) assert(table.count(widget.activeSelfD) == 0) assert(table.count(widget.queuedSelfD) == 0) -- standard selfd command - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) Test.waitFrames(1) assert(table.count(widget.activeSelfD) == 1) assert(table.count(widget.queuedSelfD) == 0) -- cancel selfd order - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) Test.waitFrames(1) assert(table.count(widget.activeSelfD) == 0) assert(table.count(widget.queuedSelfD) == 0) diff --git a/luaui/Tests/mex-building/pregame_mex_queue.lua b/luaui/Tests/mex-building/pregame_mex_queue.lua index 6bf19a153fc..550f1b1a4d5 100644 --- a/luaui/Tests/mex-building/pregame_mex_queue.lua +++ b/luaui/Tests/mex-building/pregame_mex_queue.lua @@ -1,5 +1,5 @@ function skip() - return Spring.GetGameFrame() > 0 + return SpringShared.GetGameFrame() > 0 end -- Test whether mexes are able to clear queued buildings by shift-clicking @@ -15,9 +15,9 @@ function setup() WG["pregame-build"].setBuildQueue({}) WG["pregame-build"].setPreGamestartDefID(nil) - initialCameraState = Spring.GetCameraState() + initialCameraState = SpringUnsynced.GetCameraState() - Spring.SetCameraState({ + SpringUnsynced.SetCameraState({ mode = 5, }) @@ -31,7 +31,7 @@ function cleanup() WG["pregame-build"].setBuildQueue({}) WG["pregame-build"].setPreGamestartDefID(nil) - Spring.SetCameraState(initialCameraState) + SpringUnsynced.SetCameraState(initialCameraState) end -- tests both pregame mex snap behavior, as well as basic queue and blueprint handling @@ -54,8 +54,8 @@ function test() WG["pregame-build"].setPreGamestartDefID(mexUnitDefId) local activeBlueprint = WG["pregame-build"].getPreGameDefID() assert(activeBlueprint == mexUnitDefId, "Active blueprint should be armmex") - local sx, sy, sz = Spring.WorldToScreenCoords(targetMex.x - 200, targetMex.y, targetMex.z - 200) - Spring.WarpMouse(sx, sy) + local sx, sy, sz = SpringUnsynced.WorldToScreenCoords(targetMex.x - 200, targetMex.y, targetMex.z - 200) + SpringUnsynced.WarpMouse(sx, sy) -- wait for widgets to respond Test.waitTime(10) @@ -75,8 +75,8 @@ function test() Test.waitTime(10) -- move mouse to snapped position - sx, sy, sz = Spring.WorldToScreenCoords(snappedPosition.x, snappedPosition.y, snappedPosition.z) - Spring.WarpMouse(sx, sy) + sx, sy, sz = SpringUnsynced.WorldToScreenCoords(snappedPosition.x, snappedPosition.y, snappedPosition.z) + SpringUnsynced.WarpMouse(sx, sy) -- select mex again WG["pregame-build"].setPreGamestartDefID(mexUnitDefId) diff --git a/luaui/Tests/mex-building/pregame_mex_snap.lua b/luaui/Tests/mex-building/pregame_mex_snap.lua index acf8639eaed..1d4f5095424 100644 --- a/luaui/Tests/mex-building/pregame_mex_snap.lua +++ b/luaui/Tests/mex-building/pregame_mex_snap.lua @@ -1,5 +1,5 @@ function skip() - return Spring.GetGameFrame() > 0 + return SpringShared.GetGameFrame() > 0 end function setup() @@ -14,9 +14,9 @@ function setup() WG["pregame-build"].setBuildQueue({}) WG["pregame-build"].setPreGamestartDefID(nil) - initialCameraState = Spring.GetCameraState() + initialCameraState = SpringUnsynced.GetCameraState() - Spring.SetCameraState({ + SpringUnsynced.SetCameraState({ mode = 5, }) @@ -30,7 +30,7 @@ function cleanup() WG["pregame-build"].setBuildQueue({}) WG["pregame-build"].setPreGamestartDefID(nil) - Spring.SetCameraState(initialCameraState) + SpringUnsynced.SetCameraState(initialCameraState) end function test() @@ -50,8 +50,8 @@ function test() -- Place a mex off of a mex spot - expect mex snap to position it on the spot, as close as possible to cursor position WG["pregame-build"].setPreGamestartDefID(mexUnitDefId) - sx, sy, sz = Spring.WorldToScreenCoords(targetMex.x - 200, targetMex.y, targetMex.z - 200) - Spring.WarpMouse(sx, sy) + sx, sy, sz = SpringUnsynced.WorldToScreenCoords(targetMex.x - 200, targetMex.y, targetMex.z - 200) + SpringUnsynced.WarpMouse(sx, sy) -- wait for widgets to respond Test.waitTime(10) diff --git a/luaui/Tests/select_api/compare_to_spring.lua b/luaui/Tests/select_api/compare_to_spring.lua index 3d04047b68c..3bc38891b56 100644 --- a/luaui/Tests/select_api/compare_to_spring.lua +++ b/luaui/Tests/select_api/compare_to_spring.lua @@ -1,11 +1,11 @@ -- run test using BAR command (in chat): `/runtests select_api` -local spGetUnitDefID = Spring.GetUnitDefID +local spGetUnitDefID = SpringShared.GetUnitDefID local selectApi = VFS.Include("luaui/Include/select_api.lua") local nameLookup = {} local passed = true function skip() - return Spring.GetGameFrame() <= 0 or not Platform.gl + return SpringShared.GetGameFrame() <= 0 or not Platform.gl end function setup() @@ -13,7 +13,7 @@ function setup() end function cleanup() - Spring.SendCommands("setspeed " .. 1) + SpringUnsynced.SendCommands("setspeed " .. 1) end local function printTable(tbl, indent) @@ -95,11 +95,11 @@ local function createAndAddUnit(udefid, name, x, z, uids, group) local z = locals.z local group = locals.group - local y = Spring.GetGroundHeight(x, z) - local unitID = Spring.CreateUnit(udefid, x, y, z, "east", 0) + local y = SpringShared.GetGroundHeight(x, z) + local unitID = SpringSynced.CreateUnit(udefid, x, y, z, "east", 0) if group == 1 then - Spring.SetUnitGroup(unitID, 1) + SpringUnsynced.SetUnitGroup(unitID, 1) end return unitID end) @@ -172,18 +172,18 @@ local function test_command(preSelectedUnitIDs, filter, command, conclusion) -- api command local apiCommand = selectApi.getCommand(command) local apiCommandUnitSet = {} - Spring.SelectUnitArray(preSelectedUnitIDs) + SpringUnsynced.SelectUnitArray(preSelectedUnitIDs) apiCommand() - local apiUnits = Spring.GetSelectedUnits() + local apiUnits = SpringUnsynced.GetSelectedUnits() for _, uid in pairs(apiUnits) do apiCommandUnitSet[uid] = true end -- spring local springUnitSet = {} - Spring.SelectUnitArray(preSelectedUnitIDs) - Spring.SendCommands(springCommand) - local springUnits = Spring.GetSelectedUnits() + SpringUnsynced.SelectUnitArray(preSelectedUnitIDs) + SpringUnsynced.SendCommands(springCommand) + local springUnits = SpringUnsynced.GetSelectedUnits() for _, uid in pairs(springUnits) do springUnitSet[uid] = true end diff --git a/luaui/Tests/selftests/test_assertions.lua b/luaui/Tests/selftests/test_assertions.lua index 242ef050c81..056f5f53de8 100644 --- a/luaui/Tests/selftests/test_assertions.lua +++ b/luaui/Tests/selftests/test_assertions.lua @@ -1,10 +1,10 @@ function sanityChecks() -- Just to make sure some standard methods used here work as expected. - Spring.GiveOrderToUnit(2, CMD.FIRE_STATE, { 0 }, {}) + SpringSynced.GiveOrderToUnit(2, CMD.FIRE_STATE, { 0 }, {}) SyncedProxy.Spring.ValidUnitID(20) local res, err = pcall(function() - Spring.GiveOrderToUnit(2, CMD.FIRE_STATE, { 0 }, {}) + SpringSynced.GiveOrderToUnit(2, CMD.FIRE_STATE, { 0 }, {}) end) assert(err ~= "attempt to yield across metamethod/C-call boundary") end @@ -14,7 +14,7 @@ function failingTests() -- This is something to do with how the test system is structured. local res, err = pcall(function() SyncedRun(function() - Spring.ValidUnitID(20) + SpringShared.ValidUnitID(20) end) end) assert(err ~= "attempt to yield across metamethod/C-call boundary") @@ -119,7 +119,7 @@ function testAssertThrows() end) end) assertThrows(function() - Spring.ValidUnitID(20) + SpringShared.ValidUnitID(20) error("error") end) end @@ -153,7 +153,7 @@ function testAssertThrowsMessage() assert(false, "error") end, "error") assertThrowsMessage(function() - Spring.ValidUnitID(20) + SpringShared.ValidUnitID(20) error("error") end, "error") end diff --git a/luaui/Tests/selftests/test_callins.lua b/luaui/Tests/selftests/test_callins.lua index 038931dbb94..db5f9f7070d 100644 --- a/luaui/Tests/selftests/test_callins.lua +++ b/luaui/Tests/selftests/test_callins.lua @@ -1,5 +1,5 @@ function skip() - return Spring.GetGameFrame() <= 0 + return SpringShared.GetGameFrame() <= 0 end function setup() @@ -49,12 +49,12 @@ function runWaitUntil(countOnly, reallyCountOnly, wait, expect, clear) local unitID = SyncedRun(function(locals) local x, z = Game.mapSizeX / 2, Game.mapSizeZ / 2 - local y = Spring.GetGroundHeight(x, z) - return Spring.CreateUnit("armpw", x, y, z, 0, locals.myTeamID) + local y = SpringShared.GetGroundHeight(x, z) + return SpringSynced.CreateUnit("armpw", x, y, z, 0, locals.myTeamID) end) -- issue selfd - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) -- actual test if wait > 0 then @@ -65,7 +65,7 @@ function runWaitUntil(countOnly, reallyCountOnly, wait, expect, clear) else Test.waitUntilCallinArgs("UnitCommand", { nil, nil, nil, CMD.SELFD, nil, nil, nil }) end - assert(Spring.GetUnitSelfDTime(unitID) > 0) + assert(SpringShared.GetUnitSelfDTime(unitID) > 0) if clear then Test.clearCallins() diff --git a/luaui/Tests/weapondefs/test_flighttime.lua b/luaui/Tests/weapondefs/test_flighttime.lua index 7afa48c68dc..d7c3befbf6a 100644 --- a/luaui/Tests/weapondefs/test_flighttime.lua +++ b/luaui/Tests/weapondefs/test_flighttime.lua @@ -6,17 +6,17 @@ end function setup() Test.clearMap() - Spring.SendCommands("editdefs 1") - Spring.SendCommands("globallos") - Spring.SendCommands("setspeed 5") + SpringUnsynced.SendCommands("editdefs 1") + SpringUnsynced.SendCommands("globallos") + SpringUnsynced.SendCommands("setspeed 5") end function cleanup() Test.clearMap() - Spring.SendCommands("globallos") - Spring.SendCommands("setspeed 1") - Spring.SendCommands("editdefs 0") + SpringUnsynced.SendCommands("globallos") + SpringUnsynced.SendCommands("setspeed 1") + SpringUnsynced.SendCommands("editdefs 0") end function runDistanceTest(flightTime, shouldAlive) @@ -40,8 +40,8 @@ function runDistanceTest(flightTime, shouldAlive) local function createUnit(def, x, z, teamID) local x = midX + x local z = midZ + z - local y = Spring.GetGroundHeight(x, z) - local unitID = Spring.CreateUnit(def, x, y, z, "south", teamID) + local y = SpringShared.GetGroundHeight(x, z) + local unitID = SpringSynced.CreateUnit(def, x, y, z, "south", teamID) units[#units + 1] = unitID unitNames[def] = unitID return unitID @@ -56,14 +56,14 @@ function runDistanceTest(flightTime, shouldAlive) createUnit("armtarg", 700, -500, 0) createUnit("corbuzz", 500, 0, 0) - Spring.GiveOrderToUnitArray(units, CMD.FIRE_STATE, { 0 }, 0) + SpringSynced.GiveOrderToUnitArray(units, CMD.FIRE_STATE, { 0 }, 0) createUnit("armarad", 900, 50, 0) for i = 0, 5 do createUnit("armrock", 850 + i * 50, 100, 0) end createUnit("corstorm", 1150, 100, 0) - Spring.GiveOrderToUnitArray(units, CMD.MOVE_STATE, { 0 }, 0) + SpringSynced.GiveOrderToUnitArray(units, CMD.MOVE_STATE, { 0 }, 0) createUnit("armarad", 400, Game.mapSizeZ / 2.0 - 1200, 0) -- enemies @@ -75,14 +75,14 @@ function runDistanceTest(flightTime, shouldAlive) Test.waitFrames(1) - Spring.GiveOrderToUnit(unitNames["corbuzz"], CMD.ATTACK, { unitNames["armsolar"] }, 0) - Spring.GiveOrderToUnit(unitNames["corstorm"], CMD.ATTACK, { unitNames["armpw"] }, 0) - Spring.GiveOrderToUnit(unitNames["armrock"], CMD.ATTACK, { unitNames["armpw"] }, 0) + SpringSynced.GiveOrderToUnit(unitNames["corbuzz"], CMD.ATTACK, { unitNames["armsolar"] }, 0) + SpringSynced.GiveOrderToUnit(unitNames["corstorm"], CMD.ATTACK, { unitNames["armpw"] }, 0) + SpringSynced.GiveOrderToUnit(unitNames["armrock"], CMD.ATTACK, { unitNames["armpw"] }, 0) Test.waitFrames(300) - local isAlive = Spring.ValidUnitID(unitNames["armsolar"]) - local isAlive2 = Spring.ValidUnitID(unitNames["armpw"]) + local isAlive = SpringShared.ValidUnitID(unitNames["armsolar"]) + local isAlive2 = SpringShared.ValidUnitID(unitNames["armpw"]) assert(isAlive == shouldAlive) assert(isAlive2 == shouldAlive) diff --git a/luaui/TestsExamples/balance/test_arm_vs_cor_fighters.lua b/luaui/TestsExamples/balance/test_arm_vs_cor_fighters.lua index 8b353d69122..379eeacfca2 100644 --- a/luaui/TestsExamples/balance/test_arm_vs_cor_fighters.lua +++ b/luaui/TestsExamples/balance/test_arm_vs_cor_fighters.lua @@ -1,5 +1,5 @@ function skip() - return Spring.GetGameFrame() <= 0 + return SpringShared.GetGameFrame() <= 0 end function setup() @@ -9,7 +9,7 @@ end function cleanup() Test.clearMap() - Spring.SendCommands("setspeed " .. 1) + SpringUnsynced.SendCommands("setspeed " .. 1) end function test() @@ -30,8 +30,8 @@ function test() local x = locals.midX - locals.xOffset for i = 1, locals.n do local z = locals.startZ + locals.zStep * i - local y = Spring.GetGroundHeight(x, z) - local unitID = Spring.CreateUnit(locals.units[0], x, y, z, "east", 0) + local y = SpringShared.GetGroundHeight(x, z) + local unitID = SpringSynced.CreateUnit(locals.units[0], x, y, z, "east", 0) end end @@ -39,8 +39,8 @@ function test() local x = locals.midX + locals.xOffset for i = 1, locals.n do local z = locals.startZ + locals.zStep * i - local y = Spring.GetGroundHeight(x, z) - local unitID = Spring.CreateUnit(locals.units[1], x, y, z, "west", 1) + local y = SpringShared.GetGroundHeight(x, z) + local unitID = SpringSynced.CreateUnit(locals.units[1], x, y, z, "west", 1) end end @@ -49,29 +49,29 @@ function test() Test.waitFrames(1) if false then - Spring.GiveOrderToUnitArray(Spring.GetTeamUnits(0), CMD.FIGHT, { midX, 0, midZ }, 0) - Spring.GiveOrderToUnitArray(Spring.GetTeamUnits(1), CMD.FIGHT, { midX, 0, midZ }, 0) + SpringSynced.GiveOrderToUnitArray(SpringShared.GetTeamUnits(0), CMD.FIGHT, { midX, 0, midZ }, 0) + SpringSynced.GiveOrderToUnitArray(SpringShared.GetTeamUnits(1), CMD.FIGHT, { midX, 0, midZ }, 0) else - for _, unitID in ipairs(Spring.GetAllUnits()) do - local ux, uy, uz = Spring.GetUnitPosition(unitID) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + local ux, uy, uz = SpringShared.GetUnitPosition(unitID) - Spring.GiveOrderToUnit(unitID, CMD.FIGHT, { 2 * midX - ux, 0, uz }, 0) - Spring.GiveOrderToUnit(unitID, CMD.FIGHT, { midX, 0, midZ }, { "shift" }) + SpringSynced.GiveOrderToUnit(unitID, CMD.FIGHT, { 2 * midX - ux, 0, uz }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.FIGHT, { midX, 0, midZ }, { "shift" }) end end - Spring.SendCommands("setspeed " .. 5) + SpringUnsynced.SendCommands("setspeed " .. 5) -- wait until one team has no units left Test.waitUntil(function() - return #(Spring.GetTeamUnits(0)) == 0 or #(Spring.GetTeamUnits(1)) == 0 + return #(SpringShared.GetTeamUnits(0)) == 0 or #(SpringShared.GetTeamUnits(1)) == 0 end, 60 * 30) - Spring.SendCommands("setspeed " .. 1) + SpringUnsynced.SendCommands("setspeed " .. 1) - if #(Spring.GetTeamUnits(0)) > #(Spring.GetTeamUnits(1)) then + if #(SpringShared.GetTeamUnits(0)) > #(SpringShared.GetTeamUnits(1)) then winner = 0 - elseif #(Spring.GetTeamUnits(1)) > #(Spring.GetTeamUnits(0)) then + elseif #(SpringShared.GetTeamUnits(1)) > #(SpringShared.GetTeamUnits(0)) then winner = 1 end @@ -81,7 +81,7 @@ function test() if UnitDefNames and units[winner] and UnitDefNames[units[winner]] then unitName = UnitDefNames[units[winner]].translatedHumanName or units[winner] end - unitsLeft = #(Spring.GetAllUnits()) + unitsLeft = #(SpringShared.GetAllUnits()) resultStr = resultStr .. "team " .. winner .. " wins" resultStr = resultStr .. " with " .. unitsLeft resultStr = resultStr .. " (" .. string.format("%.f%%", 100 * unitsLeft / n) .. ")" @@ -90,7 +90,7 @@ function test() resultStr = resultStr .. "tie" end - Spring.Echo(resultStr) + SpringShared.Echo(resultStr) -- cor fighters should win assert(winner == 1) diff --git a/luaui/TestsExamples/balance/test_grunts_vs_pawns.lua b/luaui/TestsExamples/balance/test_grunts_vs_pawns.lua index c4d2dd08cab..bbe32e48036 100644 --- a/luaui/TestsExamples/balance/test_grunts_vs_pawns.lua +++ b/luaui/TestsExamples/balance/test_grunts_vs_pawns.lua @@ -1,5 +1,5 @@ function skip() - return Spring.GetGameFrame() <= 0 + return SpringShared.GetGameFrame() <= 0 end function setup() @@ -9,7 +9,7 @@ end function cleanup() Test.clearMap() - Spring.SendCommands("setspeed " .. 1) + SpringUnsynced.SendCommands("setspeed " .. 1) end function test() @@ -30,8 +30,8 @@ function test() local x = locals.midX - locals.xOffset for i = 1, locals.n do local z = locals.startZ - local y = Spring.GetGroundHeight(x, z) - Spring.CreateUnit(locals.units[0], x, y, z + locals.zStep * i, "east", 0) + local y = SpringShared.GetGroundHeight(x, z) + SpringSynced.CreateUnit(locals.units[0], x, y, z + locals.zStep * i, "east", 0) end end @@ -39,8 +39,8 @@ function test() local x = locals.midX + locals.xOffset for i = 1, locals.n do local z = locals.startZ - local y = Spring.GetGroundHeight(x, z) - Spring.CreateUnit(locals.units[1], x, y, z + locals.zStep * i, "west", 1) + local y = SpringShared.GetGroundHeight(x, z) + SpringSynced.CreateUnit(locals.units[1], x, y, z + locals.zStep * i, "west", 1) end end @@ -48,21 +48,21 @@ function test() Test.waitFrames(1) - Spring.GiveOrderToUnitArray(Spring.GetTeamUnits(0), CMD.FIGHT, { midX, 0, midZ }, 0) - Spring.GiveOrderToUnitArray(Spring.GetTeamUnits(1), CMD.FIGHT, { midX, 0, midZ }, 0) + SpringSynced.GiveOrderToUnitArray(SpringShared.GetTeamUnits(0), CMD.FIGHT, { midX, 0, midZ }, 0) + SpringSynced.GiveOrderToUnitArray(SpringShared.GetTeamUnits(1), CMD.FIGHT, { midX, 0, midZ }, 0) - Spring.SendCommands("setspeed " .. 20) + SpringUnsynced.SendCommands("setspeed " .. 20) -- wait until one team has no units left Test.waitUntil(function() - return #(Spring.GetTeamUnits(0)) == 0 or #(Spring.GetTeamUnits(1)) == 0 + return #(SpringShared.GetTeamUnits(0)) == 0 or #(SpringShared.GetTeamUnits(1)) == 0 end, 30 * 30) - Spring.SendCommands("setspeed " .. 1) + SpringUnsynced.SendCommands("setspeed " .. 1) - if #(Spring.GetTeamUnits(0)) > #(Spring.GetTeamUnits(1)) then + if #(SpringShared.GetTeamUnits(0)) > #(SpringShared.GetTeamUnits(1)) then winner = 0 - elseif #(Spring.GetTeamUnits(1)) > #(Spring.GetTeamUnits(0)) then + elseif #(SpringShared.GetTeamUnits(1)) > #(SpringShared.GetTeamUnits(0)) then winner = 1 end @@ -73,12 +73,12 @@ function test() unitName = UnitDefNames[units[winner]].translatedHumanName or units[winner] end resultStr = resultStr .. "team " .. winner .. " wins" - resultStr = resultStr .. " with " .. #(Spring.GetAllUnits()) .. " " .. unitName .. " left" + resultStr = resultStr .. " with " .. #(SpringShared.GetAllUnits()) .. " " .. unitName .. " left" else resultStr = resultStr .. "tie" end - Spring.Echo(resultStr) + SpringShared.Echo(resultStr) -- pawns should win assert(winner == 0) diff --git a/luaui/TestsExamples/gui_battle_resource_tracker/test_gui_battle_resource_tracker.lua b/luaui/TestsExamples/gui_battle_resource_tracker/test_gui_battle_resource_tracker.lua index a0171c3ea27..01ec015ef66 100644 --- a/luaui/TestsExamples/gui_battle_resource_tracker/test_gui_battle_resource_tracker.lua +++ b/luaui/TestsExamples/gui_battle_resource_tracker/test_gui_battle_resource_tracker.lua @@ -1,7 +1,7 @@ local widgetName = "Battle Resource Tracker" function skip() - return Spring.GetGameFrame() <= 0 + return SpringShared.GetGameFrame() <= 0 end function setup() @@ -25,7 +25,7 @@ function test() combineEventsSpy = Test.spy(widget, "combineEvents") local x, z = Game.mapSizeX / 2, Game.mapSizeZ / 2 - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) local n = 5 local unit = "armpw" @@ -35,7 +35,7 @@ function test() SyncedRun(function(locals) for i = 1, locals.n do - Spring.CreateUnit(locals.unit, locals.x, locals.y, locals.z + 10 * i, 0, 0) + SpringSynced.CreateUnit(locals.unit, locals.x, locals.y, locals.z + 10 * i, 0, 0) end end) diff --git a/luaui/TestsExamples/test_utilities/test_mock.lua b/luaui/TestsExamples/test_utilities/test_mock.lua index 32a895b5184..a9d0f7ef997 100644 --- a/luaui/TestsExamples/test_utilities/test_mock.lua +++ b/luaui/TestsExamples/test_utilities/test_mock.lua @@ -3,7 +3,7 @@ function test() return true, false, true, false end) - assertTablesEqual(pack(Spring.GetModKeyState()), { true, false, true, false }) + assertTablesEqual(pack(SpringUnsynced.GetModKeyState()), { true, false, true, false }) assert(#mock_SpringGetModKeyState.calls == 1) end diff --git a/luaui/TestsExamples/test_utilities/test_wait.lua b/luaui/TestsExamples/test_utilities/test_wait.lua index 78140bea0c3..3c157050611 100644 --- a/luaui/TestsExamples/test_utilities/test_wait.lua +++ b/luaui/TestsExamples/test_utilities/test_wait.lua @@ -8,29 +8,29 @@ function cleanup() end function test() - Spring.Echo("[test_wait] waiting 5 frames") + SpringShared.Echo("[test_wait] waiting 5 frames") Test.waitFrames(5) local x, z = Game.mapSizeX / 2, Game.mapSizeZ / 2 - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) createdUnitID = SyncedRun(function(locals) - return Spring.CreateUnit("armpw", locals.x, locals.y, locals.z, 0, 0) + return SpringSynced.CreateUnit("armpw", locals.x, locals.y, locals.z, 0, 0) end) - Spring.Echo("[test_wait] waiting for UnitCreated on unitID=" .. createdUnitID) + SpringShared.Echo("[test_wait] waiting for UnitCreated on unitID=" .. createdUnitID) Test.waitUntilCallin("UnitCreated", function(unitID, unitDefID, unitTeam, builderID) - Spring.Echo("Saw UnitCreated for unitID=" .. unitID) + SpringShared.Echo("Saw UnitCreated for unitID=" .. unitID) return unitID == createdUnitID end, 10) startFrame = SyncedProxy.Spring.GetGameFrame() - Spring.Echo("[test_wait] waiting 3 frames, but the hard way") + SpringShared.Echo("[test_wait] waiting 3 frames, but the hard way") Test.waitUntil(function() - return (Spring.GetGameFrame() - startFrame > 3) + return (SpringShared.GetGameFrame() - startFrame > 3) end) - Spring.Echo("[test_wait] waiting 1000 ms") + SpringShared.Echo("[test_wait] waiting 1000 ms") Test.waitTime(1000) end diff --git a/luaui/Widgets/__defs_write.lua b/luaui/Widgets/__defs_write.lua index e7648f84f31..e3e393e654b 100644 --- a/luaui/Widgets/__defs_write.lua +++ b/luaui/Widgets/__defs_write.lua @@ -25,7 +25,7 @@ if customparamDefsDetected then end -- Localized Spring API for performance - local spEcho = Spring.Echo + local spEcho = SpringShared.Echo local savedTables = {} @@ -263,7 +263,7 @@ if customparamDefsDetected then local subfolder = "" if folder == "baked_defs/units" and v.customParams and v.customParams.subfolder then subfolder = v.customParams.subfolder .. "/" - Spring.CreateDir(folder .. "/" .. subfolder) + SpringUnsynced.CreateDir(folder .. "/" .. subfolder) end save2(ud_table, folder .. "/" .. subfolder .. v.name .. ".lua") @@ -296,8 +296,8 @@ if customparamDefsDetected then function widget:Initialize() -- make folder if does not already exist - Spring.CreateDir("baked_defs/units") - Spring.CreateDir("baked_defs/weapons") + SpringUnsynced.CreateDir("baked_defs/units") + SpringUnsynced.CreateDir("baked_defs/weapons") --Spring.CreateDir("baked_defs/features") --Spring.CreateDir("baked_defs/armordefs") --Spring.CreateDir("baked_defs/movedefs") diff --git a/luaui/Widgets/ai_ruins_blueprint_generator.lua b/luaui/Widgets/ai_ruins_blueprint_generator.lua index b817175249c..68e9e9475e8 100644 --- a/luaui/Widgets/ai_ruins_blueprint_generator.lua +++ b/luaui/Widgets/ai_ruins_blueprint_generator.lua @@ -17,7 +17,7 @@ local mathCeil = math.ceil local tableInsert = table.insert -- Localized Spring API for performance -local spGetSelectedUnits = Spring.GetSelectedUnits +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits local outputFile = "ruins_blueprints_temp.txt" local blueprintCounter = 0 @@ -39,14 +39,14 @@ local function getBlueprintCenter() for i = 1, #selectedunits do local unit = selectedunits[i] - centerposx[unit], centerposy[unit], centerposz[unit] = Spring.GetUnitPosition(unit) + centerposx[unit], centerposy[unit], centerposz[unit] = SpringShared.GetUnitPosition(unit) blueprintposx = blueprintposx + centerposx[unit] blueprintposz = blueprintposz + centerposz[unit] end blueprintCenterX = blueprintposx / #selectedunits blueprintCenterZ = blueprintposz / #selectedunits - blueprintCenterY = Spring.GetGroundHeight(blueprintCenterX, blueprintCenterZ) + blueprintCenterY = SpringShared.GetGroundHeight(blueprintCenterX, blueprintCenterZ) end local function clearValues() @@ -99,12 +99,12 @@ local function generateCode(type) local buildings = {} for _, unitID in ipairs(selectedUnits) do - local unitDirection = Spring.GetUnitBuildFacing(unitID) + local unitDirection = SpringShared.GetUnitBuildFacing(unitID) local xOffset = mathCeil(centerposx[unitID] - blueprintCenterX) local zOffset = mathCeil(centerposz[unitID] - blueprintCenterZ) blueprintRadius = math.max(blueprintRadius, xOffset, zOffset) - local unitDefID = Spring.GetUnitDefID(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) local unitName = UnitDefs[unitDefID].name local unitDef = UnitDefNames[unitName] @@ -142,7 +142,7 @@ local function generateCode(type) blueprintCounter = blueprintCounter + 1 - Spring.Echo(blueprintName .. " written to " .. outputFile) + SpringShared.Echo(blueprintName .. " written to " .. outputFile) end function widget:TextCommand(command) diff --git a/luaui/Widgets/ana_report_widgets.lua b/luaui/Widgets/ana_report_widgets.lua index 93e97f28116..8660b7d1ec6 100644 --- a/luaui/Widgets/ana_report_widgets.lua +++ b/luaui/Widgets/ana_report_widgets.lua @@ -14,7 +14,7 @@ function widget:GetInfo() end function widget:Initialize() - local isReplay = Spring.IsReplay() + local isReplay = SpringUnsynced.IsReplay() if not WG.Analytics or isReplay then widgetHandler:RemoveWidget(self) return diff --git a/luaui/Widgets/api_analytics.lua b/luaui/Widgets/api_analytics.lua index a6b1eb1e466..eda6ff70c39 100644 --- a/luaui/Widgets/api_analytics.lua +++ b/luaui/Widgets/api_analytics.lua @@ -12,11 +12,11 @@ function widget:GetInfo() } end -local spGetPlayerInfo = Spring.GetPlayerInfo +local spGetPlayerInfo = SpringShared.GetPlayerInfo local spGetMyPlayerID = Spring.GetMyPlayerID -local spGetGameFrame = Spring.GetGameFrame -local spLog = Spring.Log -local spSendLuaUIMsg = Spring.SendLuaUIMsg +local spGetGameFrame = SpringShared.GetGameFrame +local spLog = SpringShared.Log +local spSendLuaUIMsg = SpringUnsynced.SendLuaUIMsg local pendingAnalytics = {} diff --git a/luaui/Widgets/api_blueprint.lua b/luaui/Widgets/api_blueprint.lua index 0ec3d1a123b..20fd421c1ce 100644 --- a/luaui/Widgets/api_blueprint.lua +++ b/luaui/Widgets/api_blueprint.lua @@ -11,7 +11,7 @@ local reportFunctions = nil local activeBlueprint = nil -- makes the intent of our usage of Spring.Echo clear -local FeedbackForUser = Spring.Echo +local FeedbackForUser = SpringShared.Echo local activeBuildPositions = {} local activeBuilderBuildOptions = {} @@ -60,12 +60,12 @@ local tableInsert = table.insert -- optimization -- ============ -local SpringGetUnitDefID = Spring.GetUnitDefID -local SpringGetUnitBuildFacing = Spring.GetUnitBuildFacing -local SpringGetUnitPosition = Spring.GetUnitPosition -local SpringGetGroundHeight = Spring.GetGroundHeight -local SpringPos2BuildPos = Spring.Pos2BuildPos -local SpringTestBuildOrder = Spring.TestBuildOrder +local SpringGetUnitDefID = SpringShared.GetUnitDefID +local SpringGetUnitBuildFacing = SpringShared.GetUnitBuildFacing +local SpringGetUnitPosition = SpringShared.GetUnitPosition +local SpringGetGroundHeight = SpringShared.GetGroundHeight +local SpringPos2BuildPos = SpringShared.Pos2BuildPos +local SpringTestBuildOrder = SpringShared.TestBuildOrder local SpringGetMyTeamID = Spring.GetMyTeamID local isHeadless = not Platform.gl @@ -707,9 +707,9 @@ local function setActiveBlueprint(bp) local resultTable = SubLogic.processBlueprintSubstitution(blueprintToProcess, determinedTargetSide) if resultTable.substitutionFailed then - Spring.Log("BlueprintAPI", LOG.WARNING, resultTable.summaryMessage) + SpringShared.Log("BlueprintAPI", LOG.WARNING, resultTable.summaryMessage) else - Spring.Log("BlueprintAPI", LOG.INFO, resultTable.summaryMessage) + SpringShared.Log("BlueprintAPI", LOG.INFO, resultTable.summaryMessage) end -- This allows partial substitutions to work even when some units fail to map @@ -763,9 +763,9 @@ local function setActiveBuilders(unitIDs) if firstBuilderDef and firstBuilderDef.name then if SubLogic and SubLogic.getSideFromUnitName then currentAPITargetSide = SubLogic.getSideFromUnitName(firstBuilderDef.name) - Spring.Log("BlueprintAPI", LOG.DEBUG, string.format("setActiveBuilders determined currentAPITargetSide: %s from %s", tostring(currentAPITargetSide), firstBuilderDef.name)) + SpringShared.Log("BlueprintAPI", LOG.DEBUG, string.format("setActiveBuilders determined currentAPITargetSide: %s from %s", tostring(currentAPITargetSide), firstBuilderDef.name)) else - Spring.Log("BlueprintAPI", LOG.WARNING, "setActiveBuilders: SubLogic or getSideFromUnitName not available for side detection.") + SpringShared.Log("BlueprintAPI", LOG.WARNING, "setActiveBuilders: SubLogic or getSideFromUnitName not available for side detection.") end end end @@ -802,7 +802,7 @@ local function createBlueprintFromSerialized(serializedBlueprint) end function widget:Initialize() - Spring.Log(widget:GetInfo().name, LOG.INFO, "Blueprint API Initializing. Local SubLogic is assumed loaded and valid.") + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "Blueprint API Initializing. Local SubLogic is assumed loaded and valid.") if not isHeadless then if not initGL4() then @@ -812,22 +812,22 @@ function widget:Initialize() end if ENABLE_REPORTS then - Spring.Log("BlueprintAPI", LOG.INFO, "Reports ARE enabled.") + SpringShared.Log("BlueprintAPI", LOG.INFO, "Reports ARE enabled.") local reportPath = "luaui/Include/blueprint_substitution/reports.lua" if VFS.FileExists(reportPath) then local includedReports = VFS.Include(reportPath) if includedReports and type(includedReports.SetDependencies) == "function" then includedReports.SetDependencies(SubLogic) reportFunctions = includedReports - Spring.Log("BlueprintAPI", LOG.INFO, "Report functions loaded and dependencies set using local SubLogic.") + SpringShared.Log("BlueprintAPI", LOG.INFO, "Report functions loaded and dependencies set using local SubLogic.") else - Spring.Log("BlueprintAPI", LOG.ERROR, "Failed to load reports or SetDependencies is missing: " .. reportPath) + SpringShared.Log("BlueprintAPI", LOG.ERROR, "Failed to load reports or SetDependencies is missing: " .. reportPath) end else - Spring.Log("BlueprintAPI", LOG.WARNING, "Report file not found: " .. reportPath) + SpringShared.Log("BlueprintAPI", LOG.WARNING, "Report file not found: " .. reportPath) end else - Spring.Log("BlueprintAPI", LOG.INFO, "Reports are DISABLED.") + SpringShared.Log("BlueprintAPI", LOG.INFO, "Reports are DISABLED.") end WG["api_blueprint"] = { @@ -850,17 +850,17 @@ function widget:Initialize() } if reportFunctions then - Spring.Log("BlueprintAPI", LOG.INFO, "Adding report actions...") + SpringShared.Log("BlueprintAPI", LOG.INFO, "Adding report actions...") widgetHandler:AddAction("blueprintmapreport", reportFunctions.generateMappingReport, nil, "t") widgetHandler:AddAction("blueprintcategorylist", reportFunctions.generateCategoryListReport, nil, "t") else - Spring.Log("BlueprintAPI", LOG.INFO, "Skipping report action registration (reportFunctions not loaded).") + SpringShared.Log("BlueprintAPI", LOG.INFO, "Skipping report action registration (reportFunctions not loaded).") end end function widget:Shutdown() WG["api_blueprint"] = nil - Spring.Log(widget:GetInfo().name, LOG.INFO, "Blueprint API shutdown.") + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "Blueprint API shutdown.") if isHeadless then return diff --git a/luaui/Widgets/api_builder_queue.lua b/luaui/Widgets/api_builder_queue.lua index 921f1bd40aa..52699c00ac9 100644 --- a/luaui/Widgets/api_builder_queue.lua +++ b/luaui/Widgets/api_builder_queue.lua @@ -17,13 +17,13 @@ end -- Spring API Imports -------------------------------------------------------------------------------- -local spGetUnitCommands = Spring.GetUnitCommands -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitPosition = Spring.GetUnitPosition -local spGetAllUnits = Spring.GetAllUnits -local spEcho = Spring.Echo +local spGetUnitCommands = SpringShared.GetUnitCommands +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetAllUnits = SpringShared.GetAllUnits +local spEcho = SpringShared.Echo -- Localize frequently used functions local mathFloor = math.floor diff --git a/luaui/Widgets/api_chili_draw_gl4.lua b/luaui/Widgets/api_chili_draw_gl4.lua index 36acb4cb5a3..85290a0ae28 100644 --- a/luaui/Widgets/api_chili_draw_gl4.lua +++ b/luaui/Widgets/api_chili_draw_gl4.lua @@ -17,7 +17,7 @@ local mathFloor = math.floor local mathRandom = math.random -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -- Notes and TODO -- what parts should be atlassed? the correct answer is all parts should be atlassed @@ -639,7 +639,7 @@ function widget:Initialize() math.randomseed(1) local grid = 32 local gs = 64 - local vsx, vsy = Spring.GetViewGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() for i = 0, grid * grid - 1 do local tex1 = randtablechoice(atlassedImagesUVs) local tex2 = randtablechoice(atlassedImagesUVs) diff --git a/luaui/Widgets/api_ignore.lua b/luaui/Widgets/api_ignore.lua index 9961cba0748..e2eeba96561 100644 --- a/luaui/Widgets/api_ignore.lua +++ b/luaui/Widgets/api_ignore.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local playernames = {} -- current game: playername to playerID local validAccounts = {} -- current game: accountID to playername @@ -23,9 +23,9 @@ local ignoredPlayers = {} -- old playernames method, we'll keep storing and try -- late rejoined/added spectators dont get a their own accountid but the last assigned playerID one instead so we'll have to ignore those -- THIS IS FUCKED UP BUT IT IS WHAT IT IS SOMEHOW -local playerList = Spring.GetPlayerList() +local playerList = SpringShared.GetPlayerList() for _, playerID in ipairs(playerList) do - local name, _, _, _, _, _, _, _, _, _, playerInfo = Spring.GetPlayerInfo(playerID) + local name, _, _, _, _, _, _, _, _, _, playerInfo = SpringShared.GetPlayerInfo(playerID) accountID = (playerInfo and playerInfo.accountid) and tonumber(playerInfo.accountid) if accountID and not validAccounts[accountID] then validAccounts[accountID] = name @@ -33,9 +33,9 @@ for _, playerID in ipairs(playerList) do end local function processPlayerlist() - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for _, playerID in ipairs(playerList) do - local name, _, _, _, _, _, _, _, _, _, playerInfo = Spring.GetPlayerInfo(playerID) + local name, _, _, _, _, _, _, _, _, _, playerInfo = SpringShared.GetPlayerInfo(playerID) if name and name ~= "" then playernames[name] = playerID end @@ -147,7 +147,7 @@ function widget:PlayerChanged() end function widget:MapDrawCmd(playerID, cmdType, startx, starty, startz, a, b, c) - local _, _, _, _, _, _, _, _, _, _, playerInfo = Spring.GetPlayerInfo(playerID, false) + local _, _, _, _, _, _, _, _, _, _, playerInfo = SpringShared.GetPlayerInfo(playerID, false) local accountID = (playerInfo and playerInfo.accountid) and tonumber(playerInfo.accountid) or nil if accountID and ignoredAccounts[accountID] then return true diff --git a/luaui/Widgets/api_los_combiner_gl4.lua b/luaui/Widgets/api_los_combiner_gl4.lua index 76ac24a1d16..7400c970b2f 100644 --- a/luaui/Widgets/api_los_combiner_gl4.lua +++ b/luaui/Widgets/api_los_combiner_gl4.lua @@ -17,7 +17,7 @@ end local mathMax = math.max -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -154,9 +154,9 @@ local function UpdateInfoLOSTexture(count) infoShader:SetUniformFloat("outputAlpha", outputAlpha) for i = 1, count do if i == count then - infoShader:SetUniformFloat("time", (Spring.GetDrawFrame() + 0) / 1000) + infoShader:SetUniformFloat("time", (SpringUnsynced.GetDrawFrame() + 0) / 1000) else - infoShader:SetUniformFloat("time", (Spring.GetDrawFrame() + math.random()) / 1000) + infoShader:SetUniformFloat("time", (SpringUnsynced.GetDrawFrame() + math.random()) / 1000) end gl.RenderToTexture(infoTextures[currentAllyTeam], renderToTextureFunc) end @@ -189,7 +189,7 @@ function widget:Initialize() end currentAllyTeam = Spring.GetMyAllyTeamID() - for _, a in ipairs(Spring.GetAllyTeamList()) do + for _, a in ipairs(SpringShared.GetAllyTeamList()) do infoTextures[a] = CreateLosTexture() end @@ -227,7 +227,7 @@ function widget:GameFrame(n) updateInfoLOSTexture = mathMax(1, updateInfoLOSTexture) end end -local lastUpdate = Spring.GetTimer() +local lastUpdate = SpringUnsynced.GetTimer() function widget:DrawGenesis() -- local nowtime = Spring.GetTimer() diff --git a/luaui/Widgets/api_object_spotlight.lua b/luaui/Widgets/api_object_spotlight.lua index 904ef31a201..14bdab787b2 100644 --- a/luaui/Widgets/api_object_spotlight.lua +++ b/luaui/Widgets/api_object_spotlight.lua @@ -25,22 +25,22 @@ local spotlightTypes = { if not unitID then return nil end - local unitDefID = Spring.GetUnitDefID(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) if not unitDefID then return nil end return UnitDefs[unitDefID].radius end, isValid = function(unitID) - return Spring.ValidUnitID(unitID) + return SpringShared.ValidUnitID(unitID) end, }, feature = { getDefaultRadius = function(featureID) - return FeatureDefs[Spring.GetFeatureDefID(featureID)].radius + return FeatureDefs[SpringShared.GetFeatureDefID(featureID)].radius end, isValid = function(featureID) - return Spring.ValidFeatureID(featureID) + return SpringShared.ValidFeatureID(featureID) end, postProcessVBO = function(vbo) vbo.featureIDs = true @@ -316,7 +316,7 @@ local function addSpotlight(objectType, owner, objectID, color, options) end if not spotlightTypes[objectType].isValid(objectID) then - Spring.Echo("invalid spotlight object id: " .. (objectID or "")) + SpringShared.Echo("invalid spotlight object id: " .. (objectID or "")) return end @@ -332,7 +332,7 @@ local function addSpotlight(objectType, owner, objectID, color, options) local startTime local expireTime if options.duration ~= nil then - startTime = Spring.GetDrawSeconds() + startTime = SpringUnsynced.GetDrawSeconds() expireTime = startTime + options.duration end @@ -457,7 +457,7 @@ function widget:Update(dt) -- remove expired spotlights local toRemove = {} - local gs = Spring.GetDrawSeconds() + local gs = SpringUnsynced.GetDrawSeconds() for objectType, objectOwnerTimes in pairs(objectExpireTimes) do for objectID, ownerTimes in pairs(objectOwnerTimes) do for owner, expireTime in pairs(ownerTimes) do @@ -474,7 +474,7 @@ function widget:Update(dt) end function widget:DrawWorld() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end diff --git a/luaui/Widgets/api_playernames.lua b/luaui/Widgets/api_playernames.lua index 2b7e416a57f..b794a0ca2f3 100644 --- a/luaui/Widgets/api_playernames.lua +++ b/luaui/Widgets/api_playernames.lua @@ -16,7 +16,7 @@ end local tableInsert = table.insert -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local applyFirstEncounteredName = false local maxHistorySize = 3000 -- max number of accounts in history @@ -30,7 +30,7 @@ local currentAccounts = {} -- accountID to name local reconnected = false -- flag to track if this is a reconnection/reload -local spGetPlayerInfo = Spring.GetPlayerInfo +local spGetPlayerInfo = SpringShared.GetPlayerInfo local function getPlayername(playerID, accountID, skipAlias) if playerID then @@ -195,7 +195,7 @@ local function setaliasCmd(_, _, params) end -- reload the whole UI -- TODO: add a small delay to allow the echo to be readable - Spring.SendCommands("luaui reload") + SpringUnsynced.SendCommands("luaui reload") end else @@ -205,7 +205,7 @@ local function setaliasCmd(_, _, params) end function widget:Initialize() - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for _, playerID in ipairs(playerList) do local _, _, _, _, _, _, _, _, _, _, playerInfo = spGetPlayerInfo(playerID) local accountID = (playerInfo and playerInfo.accountid) and tonumber(playerInfo.accountid) @@ -251,7 +251,7 @@ end function widget:GetConfigData() return { - gameID = Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID"), + gameID = Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID"), applyFirstEncounteredName = applyFirstEncounteredName, history = history, currentNames = currentNames, @@ -261,7 +261,7 @@ end function widget:SetConfigData(data) history = data.history or {} - if data.gameID and data.gameID == (Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID")) then + if data.gameID and data.gameID == (Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID")) then currentNames = data.currentNames or {} currentAccounts = data.currentAccounts or {} reconnected = true diff --git a/luaui/Widgets/api_resource_spot_builder.lua b/luaui/Widgets/api_resource_spot_builder.lua index da6e6523aff..f43796f475c 100644 --- a/luaui/Widgets/api_resource_spot_builder.lua +++ b/luaui/Widgets/api_resource_spot_builder.lua @@ -18,29 +18,29 @@ local mathAbs = math.abs local mathMax = math.max -- Localized Spring API for performance -local spGetUnitTeam = Spring.GetUnitTeam +local spGetUnitTeam = SpringShared.GetUnitTeam ------------------------------------------------------------ -- Speedups ------------------------------------------------------------ local CMD_GUARD = CMD.GUARD -local spGetBuildFacing = Spring.GetBuildFacing -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetGroundHeight = Spring.GetGroundHeight -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spPos2BuildPos = Spring.Pos2BuildPos -local spGetTeamUnits = Spring.GetTeamUnits +local spGetBuildFacing = SpringUnsynced.GetBuildFacing +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spPos2BuildPos = SpringShared.Pos2BuildPos +local spGetTeamUnits = SpringShared.GetTeamUnits local spGetMyTeamID = Spring.GetMyTeamID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitDefID = Spring.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitDefID = SpringShared.GetUnitDefID local selectedUnits = spGetSelectedUnits() local Game_extractorRadius = Game.extractorRadius -local isPregame = Spring.GetGameFrame() == 0 and not Spring.GetSpectatingState() +local isPregame = SpringShared.GetGameFrame() == 0 and not SpringUnsynced.GetSpectatingState() ------------------------------------------------------------ -- unit tables @@ -101,7 +101,7 @@ end ---Checks if there is an existing extractor (mex or geo) in the given spot ---@param spot table local function spotHasExtractor(spot) - local units = Spring.GetUnitsInCylinder(spot.x, spot.z, Game_extractorRadius) + local units = SpringShared.GetUnitsInCylinder(spot.x, spot.z, Game_extractorRadius) local type = spot.isMex and mexBuildings or geoBuildings for j = 1, #units do if type[spGetUnitDefID(units[j])] then @@ -143,7 +143,7 @@ local function spotHasExtractorQueued(spot, builders) else for i = 1, #builders do - local hasOrder = checkQueue(Spring.GetUnitCommands(builders[i], 100)) + local hasOrder = checkQueue(SpringShared.GetUnitCommands(builders[i], 100)) if hasOrder then return true end @@ -180,7 +180,7 @@ end ---@param currentExtractorUuid number uuid of current extractor ---@param newExtractorId number unitDefID of new extractor local function extractorCanBeUpgraded(currentExtractorUuid, newExtractorId) - local isAllied = Spring.AreTeamsAllied(spGetMyTeamID(), spGetUnitTeam(currentExtractorUuid)) + local isAllied = SpringShared.AreTeamsAllied(spGetMyTeamID(), spGetUnitTeam(currentExtractorUuid)) if not isAllied then return false end @@ -214,7 +214,7 @@ end ---@param extractorId table ---@return boolean local function extractorCanBeBuiltOnSpot(spot, extractorId) - local units = Spring.GetUnitsInCylinder(spot.x, spot.z, Game_extractorRadius) + local units = SpringShared.GetUnitsInCylinder(spot.x, spot.z, Game_extractorRadius) if #units == 0 then return true @@ -301,7 +301,7 @@ local function sortBuilders(units, constructorIds, buildingId, shift) end local function hasExistingGuardOrder(uid) - local queue = Spring.GetUnitCommands(uid, 10) + local queue = SpringShared.GetUnitCommands(uid, 10) for i = 1, #queue do local cmd = queue[i] if cmd.id == CMD_GUARD and (cmd.params and cmd.params[1] and isMainBuilderOfId(cmd.params[1])) then @@ -403,7 +403,7 @@ local function ApplyPreviewCmds(cmds, constructorIds, shift) return end - local _, _, meta, _ = Spring.GetModKeyState() + local _, _, meta, _ = SpringUnsynced.GetModKeyState() local unitArray = {} -- make unit array to avoid extra work for i = 1, #mainBuilders do @@ -418,7 +418,7 @@ local function ApplyPreviewCmds(cmds, constructorIds, shift) -- cmd insert layout is really weird, it needs to be formatted like: -- { CMD.INSERT, { queue_pos, cmd_id, opt, params_flattened, }, { "alt }} -- this an engine command so index starts at 0. Increment position by command count - Spring.GiveOrderToUnitArray(unitArray, CMD.INSERT, { i - 1, -buildingId, 0, unpack(orderParams) }, { "alt" }) + SpringSynced.GiveOrderToUnitArray(unitArray, CMD.INSERT, { i - 1, -buildingId, 0, unpack(orderParams) }, { "alt" }) else -- we don't want to give a stop command to clear queue because it plays an unwanted sound -- issuing any command without shift will clear the queue for us, @@ -432,7 +432,7 @@ local function ApplyPreviewCmds(cmds, constructorIds, shift) fakeShift = true end local opt = fakeShift and { "shift" } or {} - Spring.GiveOrderToUnitArray(unitArray, -buildingId, orderParams, opt) + SpringSynced.GiveOrderToUnitArray(unitArray, -buildingId, orderParams, opt) end end end diff --git a/luaui/Widgets/api_screencopy_manager.lua b/luaui/Widgets/api_screencopy_manager.lua index 901d474ebe1..9fd8c7f6ea2 100644 --- a/luaui/Widgets/api_screencopy_manager.lua +++ b/luaui/Widgets/api_screencopy_manager.lua @@ -14,8 +14,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry -- So in total about 168/162 fps delta just going from 1 to 2 screencopies! @@ -87,7 +87,7 @@ function widget:ViewResize() end local function GetScreenCopy() - local df = Spring.GetDrawFrame() + local df = SpringUnsynced.GetDrawFrame() --spEcho("GetScreenCopy", df) if df ~= lastScreenCopyFrame then gl.CopyToTexture(ScreenCopy, 0, 0, vpx, vpy, vsx, vsy) @@ -101,7 +101,7 @@ local function GetScreenCopy() end local function GetDepthCopy() - local df = Spring.GetDrawFrame() + local df = SpringUnsynced.GetDrawFrame() --spEcho("GetScreenCopy", df) if df ~= lastDepthCopyFrame then gl.CopyToTexture(DepthCopy, 0, 0, vpx, vpy, vsx, vsy) diff --git a/luaui/Widgets/api_shared_state.lua b/luaui/Widgets/api_shared_state.lua index b8bac12bfed..f3be71d9c22 100644 --- a/luaui/Widgets/api_shared_state.lua +++ b/luaui/Widgets/api_shared_state.lua @@ -17,12 +17,12 @@ end local spGetMyTeamID = Spring.GetMyTeamID local spGetMyAllyTeamID = Spring.GetMyAllyTeamID local spGetMyPlayerID = Spring.GetMyPlayerID -local spGetSpectatingState = Spring.GetSpectatingState -local spGetGameFrame = Spring.GetGameFrame -local spIsGUIHidden = Spring.IsGUIHidden -local spGetViewGeometry = Spring.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetGameFrame = SpringShared.GetGameFrame +local spIsGUIHidden = SpringUnsynced.IsGUIHidden +local spGetViewGeometry = SpringUnsynced.GetViewGeometry -local isReplay = Spring.IsReplay() +local isReplay = SpringUnsynced.IsReplay() -- The shared state table local state = { diff --git a/luaui/Widgets/api_unit_tracker_gl4.lua b/luaui/Widgets/api_unit_tracker_gl4.lua index 5144c7d0ced..aae785a5974 100644 --- a/luaui/Widgets/api_unit_tracker_gl4.lua +++ b/luaui/Widgets/api_unit_tracker_gl4.lua @@ -15,11 +15,11 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spEcho = Spring.Echo -local spGetAllUnits = Spring.GetAllUnits -local spGetSpectatingState = Spring.GetSpectatingState +local spEcho = SpringShared.Echo +local spGetAllUnits = SpringShared.GetAllUnits +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local debuglevel = 0 -- debuglevel 0 is no debugging @@ -107,14 +107,14 @@ local function initGL4() end -- speedups -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spValidUnitID = Spring.ValidUnitID -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetUnitLosState = Spring.GetUnitLosState -local spAreTeamsAllied = Spring.AreTeamsAllied -local spGetUnitHealth = Spring.GetUnitHealth +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spValidUnitID = SpringShared.ValidUnitID +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetUnitLosState = SpringShared.GetUnitLosState +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spGetUnitHealth = SpringShared.GetUnitHealth -- scriptproxies: --[[ NB: these are proxies, not the actual lua functions currently linked LuaUI-side, @@ -138,14 +138,14 @@ local function Scream(reason, unitID) -- This will pause the game and play some spEcho("API Unit Tracker error unitID", unitID, unitDefID and UnitDefs[unitDefID].name or "nil", unitTeam, px, pz) end if lastknownunitpos[unitID] then - Spring.MarkerAddPoint(lastknownunitpos[unitID][1], lastknownunitpos[unitID][2], lastknownunitpos[unitID][3], lastknownunitpos[unitID][4], true) + SpringUnsynced.MarkerAddPoint(lastknownunitpos[unitID][1], lastknownunitpos[unitID][2], lastknownunitpos[unitID][3], lastknownunitpos[unitID][4], true) end Spring.Debug.TraceFullEcho() local unittrackerapinil = nil unittrackerapinil = unittrackerapinil + 1 -- this intentionally crashes this widget so that it will show up in analytics if debuglevel >= 3 then - Spring.SendCommands({ "pause 1" }) - Spring.PlaySoundFile("commanderspawn", 1.0, "ui") + SpringUnsynced.SendCommands({ "pause 1" }) + SpringUnsynced.PlaySoundFile("commanderspawn", 1.0, "ui") end end @@ -599,7 +599,7 @@ function widget:GameFrame() end function widget:DrawWorldPreUnit() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end @@ -771,7 +771,7 @@ function widget:GameStart() local function LobbyInfo() local test = false if not test then - if Spring.IsReplay() then + if SpringUnsynced.IsReplay() then return end if Spring.Utilities.GetPlayerCount() < 2 then @@ -783,8 +783,8 @@ function widget:GameStart() end local pnl = { a = "a" } - for ct, id in ipairs(Spring.GetPlayerList()) do - local playername, _, spec = Spring.GetPlayerInfo(id, false) + for ct, id in ipairs(SpringShared.GetPlayerList()) do + local playername, _, spec = SpringShared.GetPlayerInfo(id, false) pnl[ct] = playername if (not test) and spec and (string.find(playername, "[teh]cluster", nil, true) or string.find(playername, "Host[", nil, true)) then return @@ -857,18 +857,18 @@ function widget:AddConsoleLine(lines, priority) end local username, frameNumber, gotChecksum, correctChecksum = lines:match(syncerrorpattern) if username and frameNumber and gotChecksum and correctChecksum then - local myPlayerName = Spring.GetPlayerInfo(Spring.GetMyPlayerID()) + local myPlayerName = SpringShared.GetPlayerInfo(Spring.GetMyPlayerID()) if myPlayerName == username then -- Yes, we have desynced, time to send a LuaUIMsg to notify the server -- desyncee, gameID, frame, gameversion, engine version, map, chobby version? local jsondict = { eventtype = "syncerror", username = username, -- desyncee - lobbyName = tostring(Spring.GetMenuName and Spring.GetMenuName()), -- this returns rapid://byar-chobby:test, which is completely useless + lobbyName = tostring(SpringUnsynced.GetMenuName and SpringUnsynced.GetMenuName()), -- this returns rapid://byar-chobby:test, which is completely useless gameVersion = tostring(Game.gameVersion), -- this better not be the rapid tag engineVersion = tostring(Engine.versionFull), -- full complete engine version string mapName = tostring(Game.mapName), -- full map name - gameID = tostring(Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID")), -- gameID parameter, not the same as server_match_id, we will match that in teiserver + gameID = tostring(Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID")), -- gameID parameter, not the same as server_match_id, we will match that in teiserver frame = frameNumber, -- the frame where it happened. gotChecksum = gotChecksum, correctChecksum = correctChecksum, @@ -880,7 +880,7 @@ function widget:AddConsoleLine(lines, priority) -- We will be forwarding this as a complex event: -- sayPrivate complex-match-event <67> -- !sendLobby SAYPRIVATE AutohostMonitor 'complex-match-event <[teh]Beherith> <67> ' - Spring.SendLuaUIMsg(complex_match_event) + SpringUnsynced.SendLuaUIMsg(complex_match_event) -- then remove ourselves, no point to keep running after the first desync is detected iHaveDesynced = true diff --git a/luaui/Widgets/api_unit_tracker_tester_gl4.lua b/luaui/Widgets/api_unit_tracker_tester_gl4.lua index 5921dbd68bb..99293e8e13f 100644 --- a/luaui/Widgets/api_unit_tracker_tester_gl4.lua +++ b/luaui/Widgets/api_unit_tracker_tester_gl4.lua @@ -13,8 +13,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetUnitTeam = Spring.GetUnitTeam +local spEcho = SpringShared.Echo +local spGetUnitTeam = SpringShared.GetUnitTeam local myvisibleUnits = {} -- table of unitID : unitDefID @@ -44,7 +44,7 @@ end function widget:VisibleUnitAdded(unitID, unitDefID, unitTeam) spEcho("widget:VisibleUnitAdded", unitID, unitDefID, unitTeam) local teamID = spGetUnitTeam(unitID) or 0 - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() myvisibleUnits[unitID] = unitDefID pushElementInstance( unitTrackerVBO, -- push into this Instance VBO Table @@ -92,7 +92,7 @@ function widget:VisibleUnitRemoved(unitID) end function widget:DrawWorldPreUnit() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end diff --git a/luaui/Widgets/api_unitbufferuniform_copy.lua b/luaui/Widgets/api_unitbufferuniform_copy.lua index 8d2509e8c64..4b322363634 100644 --- a/luaui/Widgets/api_unitbufferuniform_copy.lua +++ b/luaui/Widgets/api_unitbufferuniform_copy.lua @@ -12,8 +12,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo local LuaShader = gl.LuaShader diff --git a/luaui/Widgets/camera_flip.lua b/luaui/Widgets/camera_flip.lua index e13eda05b6c..12592603907 100644 --- a/luaui/Widgets/camera_flip.lua +++ b/luaui/Widgets/camera_flip.lua @@ -18,7 +18,7 @@ local mathPi = math.pi local halfpi = mathPi / 2 local function cameraFlipHandler() - local camState = Spring.GetCameraState() + local camState = SpringUnsynced.GetCameraState() if camState.mode ~= 1 and camState.mode ~= 2 then return false @@ -27,7 +27,7 @@ local function cameraFlipHandler() if camState.flipped then -- camera is overhead cam camState.flipped = camState.flipped * -1 - Spring.SetCameraState(camState, 0) + SpringUnsynced.SetCameraState(camState, 0) return true end @@ -52,7 +52,7 @@ local function cameraFlipHandler() The interpolation formula is at `static float GetRotationWithCardinalLock(float rot)` in `SpringController.cpp` ]] - local cardinalLock = Spring.GetConfigInt("CamSpringLockCardinalDirections") + local cardinalLock = SpringUnsynced.GetConfigInt("CamSpringLockCardinalDirections") local lockCorrection = 0 if cardinalLock == 1 and math.abs(camState.ry) < 0.1 * halfpi then -- Edge case around 0.0f: camera ry's with absolute value less than 0.1 * halfpi @@ -65,7 +65,7 @@ local function cameraFlipHandler() camState.ry = camState.ry - mathPi - lockCorrection end - Spring.SetCameraState(camState, 0) + SpringUnsynced.SetCameraState(camState, 0) return true end diff --git a/luaui/Widgets/camera_fov_changer.lua b/luaui/Widgets/camera_fov_changer.lua index dd0d147bfc3..895496566d8 100644 --- a/luaui/Widgets/camera_fov_changer.lua +++ b/luaui/Widgets/camera_fov_changer.lua @@ -16,7 +16,7 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local fovStep = 5 local FOVminus = 111 -- CTRL+O @@ -27,7 +27,7 @@ local FOVplus2 = 263 --KP7 function widget:KeyRelease(key, modifier) --spEcho(key) if (key == FOVplus and modifier.ctrl) or key == FOVplus2 or (key == FOVminus and modifier.ctrl) or key == FOVminus2 then - local current_cam_state = Spring.GetCameraState() + local current_cam_state = SpringUnsynced.GetCameraState() if key == FOVplus or key == FOVplus2 then current_cam_state.fov = mathFloor(current_cam_state.fov + fovStep) if current_cam_state.fov > 100 then -- glitches beyond 100 @@ -40,6 +40,6 @@ function widget:KeyRelease(key, modifier) end end spEcho("target FOV: " .. current_cam_state.fov) - Spring.SetCameraState(current_cam_state, WG["options"] and WG["options"].getCameraSmoothness() or 2) + SpringUnsynced.SetCameraState(current_cam_state, WG["options"] and WG["options"].getCameraSmoothness() or 2) end end diff --git a/luaui/Widgets/camera_goto.lua b/luaui/Widgets/camera_goto.lua index b441c71f927..d4b21daa1a9 100644 --- a/luaui/Widgets/camera_goto.lua +++ b/luaui/Widgets/camera_goto.lua @@ -20,7 +20,7 @@ local function handleGoto(_, _, args) if not x or not z then return end - Spring.SetCameraTarget(x, Spring.GetGroundHeight(x, z), z) + SpringUnsynced.SetCameraTarget(x, SpringShared.GetGroundHeight(x, z), z) end function widget:Shutdown() diff --git a/luaui/Widgets/camera_joystick.lua b/luaui/Widgets/camera_joystick.lua index 782342c4133..17ac7e3d7f5 100644 --- a/luaui/Widgets/camera_joystick.lua +++ b/luaui/Widgets/camera_joystick.lua @@ -17,7 +17,7 @@ local mathMax = math.max local mathPi = math.pi -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo ---------------------INFO------------------------ -- 1. Start your joystick server: https://github.com/Beherith/camera_joystick_springrts @@ -196,19 +196,19 @@ local function togglePlayback() end ------------- BIND COMMANDS TO BUTTONS DEBOUNCED! ------------------------------- local buttonCommands = { -- key is button number, value is command like you would type into console without the beginning / [Abutton[2]] = function() - Spring.SendCommands("pause") + SpringUnsynced.SendCommands("pause") end, [Bbutton[2]] = function() - Spring.SendCommands("hideinterface") + SpringUnsynced.SendCommands("hideinterface") end, [Xbutton[2]] = function() - Spring.SendCommands("togglelos") + SpringUnsynced.SendCommands("togglelos") end, [LShoulderbutton[2]] = function() - Spring.SendCommands("slowdown") + SpringUnsynced.SendCommands("slowdown") end, [RShoulderbutton[2]] = function() - Spring.SendCommands("speedup") + SpringUnsynced.SendCommands("speedup") end, --[RStickButton[2]] = function() Spring.SendCommands("MiniMap Maximize") end, --[LStickButton[2]] = function() Spring.SendCommands("luaui togglewidget Defense Range GL4") end, @@ -223,8 +223,8 @@ local buttonCommands = { -- key is button number, value is command like you woul } -------------------------------------------------------------------------------- -local spGetCameraState = Spring.GetCameraState -local spSetCameraState = Spring.SetCameraState +local spGetCameraState = SpringUnsynced.GetCameraState +local spSetCameraState = SpringUnsynced.SetCameraState -------------------------------------------------------------------------------- local host = "127.0.0.1" @@ -300,7 +300,7 @@ end local function dumpConfig() -- dump all luasocket related config settings to console for _, conf in ipairs({ "TCPAllowConnect", "TCPAllowListen", "UDPAllowConnect", "UDPAllowListen" }) do - spEcho(conf .. " = " .. Spring.GetConfigString(conf, "")) + spEcho(conf .. " = " .. SpringUnsynced.GetConfigString(conf, "")) end end @@ -371,14 +371,14 @@ function widget:TextCommand(command) end function widget:Initialize() - Spring.SendCommands({ "set SmoothTimeOffset 2" }) + SpringUnsynced.SendCommands({ "set SmoothTimeOffset 2" }) spEcho("Started Camera Joystick, make sure you are running the joystick server, and switch camera to Ctrl+F4") if debugMode then dumpConfig() end local connected = SocketConnect(host, port) if connected then - Spring.SetConfigInt("RotOverheadClampMap", 0) + SpringUnsynced.SetConfigInt("RotOverheadClampMap", 0) else widgetHandler:RemoveWidget() end @@ -563,7 +563,7 @@ function widget:Update(dt) -- dt in seconds end local ndx, ndz = norm2d(cs.dx, cs.dz) - if debugMode and Spring.GetGameFrame() % 60 == 0 then + if debugMode and SpringShared.GetGameFrame() % 60 == 0 then spEcho(ndx, ndz, cs.dx, cs.dy, cs.dz) end @@ -614,7 +614,7 @@ function widget:Update(dt) -- dt in seconds end -- Prevent the camera from going too low - local gh = Spring.GetGroundHeight(cs.px, cs.pz) + local gh = SpringShared.GetGroundHeight(cs.px, cs.pz) cs.py = mathMax(mincameraheight, mathMax(cs.py, gh + 32)) --if cs.py < gh + 32 then cs.py =gh + 32 end diff --git a/luaui/Widgets/camera_lockcamera.lua b/luaui/Widgets/camera_lockcamera.lua index 02e15c3fd3d..1c58af37cb4 100644 --- a/luaui/Widgets/camera_lockcamera.lua +++ b/luaui/Widgets/camera_lockcamera.lua @@ -27,17 +27,17 @@ local newBroadcaster = false local desiredLosmodeChanged = 0 local desiredLosmode, myLastCameraState -local spGetCameraState = Spring.GetCameraState -local spSetCameraState = Spring.SetCameraState -local spGetPlayerInfo = Spring.GetPlayerInfo -local spSendCommands = Spring.SendCommands -local spGetSpectatingState = Spring.GetSpectatingState -local spGetMapDrawMode = Spring.GetMapDrawMode +local spGetCameraState = SpringUnsynced.GetCameraState +local spSetCameraState = SpringUnsynced.SetCameraState +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spSendCommands = SpringUnsynced.SendCommands +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetMapDrawMode = SpringUnsynced.GetMapDrawMode local spGetMyPlayerID = Spring.GetMyPlayerID -local spGetLocalAllyTeamID = Spring.GetLocalAllyTeamID -local spGetLocalTeamID = Spring.GetLocalTeamID -local spGetTeamInfo = Spring.GetTeamInfo -local spGetGameFrame = Spring.GetGameFrame +local spGetLocalAllyTeamID = SpringUnsynced.GetLocalAllyTeamID +local spGetLocalTeamID = SpringUnsynced.GetLocalTeamID +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetGameFrame = SpringShared.GetGameFrame local os_clock = os.clock local math_pi = math.pi diff --git a/luaui/Widgets/camera_middle_mouse_alternate.lua b/luaui/Widgets/camera_middle_mouse_alternate.lua index 90d826edae2..802c9793f48 100644 --- a/luaui/Widgets/camera_middle_mouse_alternate.lua +++ b/luaui/Widgets/camera_middle_mouse_alternate.lua @@ -16,17 +16,17 @@ end local mathSqrt = math.sqrt -- Localized Spring API for performance -local spGetMouseState = Spring.GetMouseState +local spGetMouseState = SpringUnsynced.GetMouseState -local spGetCameraState = Spring.GetCameraState -local spGetCameraVectors = Spring.GetCameraVectors -local spGetModKeyState = Spring.GetModKeyState +local spGetCameraState = SpringUnsynced.GetCameraState +local spGetCameraVectors = SpringUnsynced.GetCameraVectors +local spGetModKeyState = SpringUnsynced.GetModKeyState local spGetMouseState = spGetMouseState -local spIsAboveMiniMap = Spring.IsAboveMiniMap -local spSendCommands = Spring.SendCommands -local spSetCameraState = Spring.SetCameraState -local spSetMouseCursor = Spring.SetMouseCursor -local spWarpMouse = Spring.WarpMouse +local spIsAboveMiniMap = SpringUnsynced.IsAboveMiniMap +local spSendCommands = SpringUnsynced.SendCommands +local spSetCameraState = SpringUnsynced.SetCameraState +local spSetMouseCursor = SpringUnsynced.SetMouseCursor +local spWarpMouse = SpringUnsynced.WarpMouse local blockModeSwitching = true @@ -43,7 +43,7 @@ local drawing = false function widget:Update(dt) if active then - local speedFactor = Spring.GetConfigInt("OverheadScrollSpeed", 10) + local speedFactor = SpringUnsynced.GetConfigInt("OverheadScrollSpeed", 10) local x, y, lmb, mmb, rmb = spGetMouseState() local cs = spGetCameraState() local speed = dt * speedFactor @@ -131,8 +131,8 @@ end -- Adjust the camera position when the user scrolls the mouse wheel function widget:MouseWheel(up, value) -- Get the current camera state and mod key state - local cameraState = Spring.GetCameraState() - local altDown, ctrlDown, metaDown, shiftDown = Spring.GetModKeyState() + local cameraState = SpringUnsynced.GetCameraState() + local altDown, ctrlDown, metaDown, shiftDown = SpringUnsynced.GetModKeyState() -- If the Alt key is down, adjust the camera height if altDown then @@ -143,7 +143,7 @@ function widget:MouseWheel(up, value) py = absCameraY + cameraYDelta, } - Spring.SetCameraState(newCameraState, 0) + SpringUnsynced.SetCameraState(newCameraState, 0) return true end @@ -154,12 +154,12 @@ function widget:MouseWheel(up, value) -- Get the mouse position and position on ground local mouseX, mouseY = spGetMouseState() - local _, groundPos = Spring.TraceScreenRay(mouseX, mouseY, true) + local _, groundPos = SpringUnsynced.TraceScreenRay(mouseX, mouseY, true) -- If there is no ground position, adjust the camera vertically if not groundPos then local cameraYDelta = value * 10 - Spring.SetCameraState({ + SpringUnsynced.SetCameraState({ vy = cameraState.vy + cameraYDelta, }, 0) else @@ -183,7 +183,7 @@ function widget:MouseWheel(up, value) vz = 0, } - Spring.SetCameraState(newCameraState, 0) + SpringUnsynced.SetCameraState(newCameraState, 0) end return true diff --git a/luaui/Widgets/camera_player_tv.lua b/luaui/Widgets/camera_player_tv.lua index 8ad74cfb945..82a3aa28567 100644 --- a/luaui/Widgets/camera_player_tv.lua +++ b/luaui/Widgets/camera_player_tv.lua @@ -17,11 +17,11 @@ local mathFloor = math.floor local mathRandom = math.random -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spGetMouseState = Spring.GetMouseState -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState --[[ Commands /playerview #playerID (playerID is optional) @@ -50,10 +50,10 @@ local nextTrackingPlayerChange = os.clock() - 200 local tsOrderedPlayers = {} -local teamList = Spring.GetTeamList() +local teamList = SpringShared.GetTeamList() local isSpec, fullview = spGetSpectatingState() local myTeamID = spGetMyTeamID() -local myTeamPlayerID = select(2, Spring.GetTeamInfo(myTeamID)) +local myTeamPlayerID = select(2, SpringShared.GetTeamInfo(myTeamID)) local vsx, vsy = spGetViewGeometry() local widgetScale = (0.7 + (vsx * vsy / 5000000)) @@ -64,9 +64,9 @@ local desiredLosmodeChanged = 0 local math_isInRect = math.isInRect -local playersList = Spring.GetPlayerList() -local spGetTeamColor = Spring.GetTeamColor -local spGetPlayerInfo = Spring.GetPlayerInfo +local playersList = SpringShared.GetPlayerList() +local spGetTeamColor = SpringUnsynced.GetTeamColor +local spGetPlayerInfo = SpringShared.GetPlayerInfo local ColorIsDark = Spring.Utilities.Color.ColorIsDark @@ -75,7 +75,7 @@ local teamColorKeys = {} for i = 1, #teamList do local r, g, b, a = spGetTeamColor(teamList[i]) teamColorKeys[teamList[i]] = r .. "_" .. g .. "_" .. b - local _, _, _, isAiTeam = Spring.GetTeamInfo(teamList[i], false) + local _, _, _, isAiTeam = SpringShared.GetTeamInfo(teamList[i], false) if isAiTeam then aiTeams[teamList[i]] = true end @@ -85,8 +85,8 @@ local font, font2, lockPlayerID, prevLockPlayerID, toggleButton, toggleButton2, local RectRound, elementCorner, bgpadding local guishaderWasActive = false -local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode -local anonymousTeamColor = { Spring.GetConfigInt("anonymousColorR", 255) / 255, Spring.GetConfigInt("anonymousColorG", 0) / 255, Spring.GetConfigInt("anonymousColorB", 0) / 255 } +local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode +local anonymousTeamColor = { SpringUnsynced.GetConfigInt("anonymousColorR", 255) / 255, SpringUnsynced.GetConfigInt("anonymousColorG", 0) / 255, SpringUnsynced.GetConfigInt("anonymousColorB", 0) / 255 } local function tsOrderPlayers() tsOrderedPlayers = {} @@ -335,7 +335,7 @@ local function updatePosition() elseif WG["advplayerlist_api"] ~= nil then parentPos = WG["advplayerlist_api"].GetPosition() -- returns {top,left,bottom,right,widgetScale} else - local scale = (vsy / 880) * (1 + (Spring.GetConfigFloat("ui_scale", 1) - 1) / 1.25) + local scale = (vsy / 880) * (1 + (SpringUnsynced.GetConfigFloat("ui_scale", 1) - 1) / 1.25) parentPos = { 0, vsx - (220 * scale), 0, vsx, scale } end if parentPos[5] ~= nil then @@ -364,7 +364,7 @@ end function widget:PlayerChanged(playerID) myTeamID = spGetMyTeamID() - myTeamPlayerID = select(2, Spring.GetTeamInfo(myTeamID)) + myTeamPlayerID = select(2, SpringShared.GetTeamInfo(myTeamID)) isSpec, fullview = spGetSpectatingState() tsOrderPlayers() local receateLists = false @@ -376,9 +376,9 @@ function widget:PlayerChanged(playerID) end local name = spGetPlayerInfo(playerID, false) name = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerID)) or name - if select(4, Spring.GetTeamInfo(myTeamID, false)) then -- is AI? - local _, _, _, aiName = Spring.GetAIInfo(myTeamID) - local niceName = Spring.GetGameRulesParam("ainame_" .. myTeamID) + if select(4, SpringShared.GetTeamInfo(myTeamID, false)) then -- is AI? + local _, _, _, aiName = SpringShared.GetAIInfo(myTeamID) + local niceName = SpringShared.GetGameRulesParam("ainame_" .. myTeamID) name = niceName or aiName end if name and drawlistsPlayername[name] then @@ -461,16 +461,16 @@ function widget:Update(dt) if scheduledSpecFullView ~= nil then -- this is needed else the minimap/world doesnt update properly - Spring.SendCommands("specfullview") + SpringUnsynced.SendCommands("specfullview") scheduledSpecFullView = scheduledSpecFullView - 1 if scheduledSpecFullView == 0 then scheduledSpecFullView = nil end end if desiredLosmodeChanged + 0.3 > os.clock() then - if desiredLosmode ~= Spring.GetMapDrawMode() then + if desiredLosmode ~= SpringUnsynced.GetMapDrawMode() then -- this is needed else the minimap/world doesnt update properly - Spring.SendCommands("togglelos") + SpringUnsynced.SendCommands("togglelos") end end @@ -522,15 +522,15 @@ function widget:Update(dt) if (isSpec or lockPlayerID) and not rejoining then if WG["tooltip"] and not toggled and not lockPlayerID then if buttonHovered and buttonHovered == 1 then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") WG["tooltip"].ShowTooltip("playertv", Spring.I18N("ui.playerTV.tooltip")) end if buttonHovered and buttonHovered == 2 then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") WG["tooltip"].ShowTooltip("playertv", Spring.I18N("ui.playerTV.playerViewTooltip")) end if buttonHovered and buttonHovered == 3 then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") WG["tooltip"].ShowTooltip("playertv", Spring.I18N("ui.playerTV.playerCameraTooltip")) end end @@ -595,9 +595,9 @@ local function drawContent() end local name, _, spec, teamID, _, _, _, _, _ = spGetPlayerInfo(myTeamPlayerID, false) name = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(myTeamPlayerID)) or name - if select(4, Spring.GetTeamInfo(myTeamID, false)) then -- is AI? - local _, _, _, aiName = Spring.GetAIInfo(myTeamID) - local niceName = Spring.GetGameRulesParam("ainame_" .. myTeamID) + if select(4, SpringShared.GetTeamInfo(myTeamID, false)) then -- is AI? + local _, _, _, aiName = SpringShared.GetAIInfo(myTeamID) + local niceName = SpringShared.GetGameRulesParam("ainame_" .. myTeamID) name = niceName or aiName name = Spring.I18N("ui.playersList.aiName", { name = name }) end @@ -707,18 +707,18 @@ local function togglePlayerView(state) if not toggled2 then -- global viewpoint if not fullview then - Spring.SendCommands("specfullview") + SpringUnsynced.SendCommands("specfullview") end - if Spring.GetMapDrawMode() == "los" then - Spring.SendCommands("togglelos") + if SpringUnsynced.GetMapDrawMode() == "los" then + SpringUnsynced.SendCommands("togglelos") end else -- player viewpoint if fullview then scheduledSpecFullView = 2 -- this is needed else the minimap/world doesnt update properly - Spring.SendCommands("specfullview") + SpringUnsynced.SendCommands("specfullview") end - if Spring.GetMapDrawMode() ~= "los" then + if SpringUnsynced.GetMapDrawMode() ~= "los" then desiredLosmode = "los" desiredLosmodeChanged = os.clock() end @@ -731,7 +731,7 @@ local function playerviewCmd(_, _, params) local playerID = tonumber(params[1]) local teamID = select(4, spGetPlayerInfo(playerID)) if teamID then - Spring.SendCommands("specteam " .. teamID) + SpringUnsynced.SendCommands("specteam " .. teamID) end end togglePlayerView() @@ -746,7 +746,7 @@ local function playertvCmd(_, _, params) local playerID = tonumber(params[1]) local teamID = select(4, spGetPlayerInfo(playerID)) if teamID and WG.lockcamera and WG.lockcamera.SetPlayerID then - Spring.SendCommands("specteam " .. teamID) + SpringUnsynced.SendCommands("specteam " .. teamID) WG.lockcamera.SetPlayerID(playerID) else togglePlayerTV() @@ -773,7 +773,7 @@ function widget:Initialize() local _, _, spec, team = spGetPlayerInfo(playerID, false) if not spec then playersTS[playerID] = GetSkill(playerID) - local isDestroyable, isDead = select(3, Spring.GetTeamInfo(team, false)) + local isDestroyable, isDead = select(3, SpringShared.GetTeamInfo(team, false)) if not isDestroyable and not isDead then humanPlayers = humanPlayers + 1 end diff --git a/luaui/Widgets/camera_remember_mode.lua b/luaui/Widgets/camera_remember_mode.lua index e2dda213fc8..3f6a04db49c 100644 --- a/luaui/Widgets/camera_remember_mode.lua +++ b/luaui/Widgets/camera_remember_mode.lua @@ -14,7 +14,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local savedCamState local defaultCamState = { mode = 2, rx = 2.677, ry = 0.0, rz = 0.0 } --spring @@ -29,22 +29,22 @@ function widget:Initialize() --spEcho("wanted", camName) if savedCamState then - Spring.SetCameraState(savedCamState, 0) + SpringUnsynced.SetCameraState(savedCamState, 0) end avoidOverviewCam() -- and we don't want to switch to overview at game start anyway end function avoidOverviewCam() - local camState = Spring.GetCameraState() + local camState = SpringUnsynced.GetCameraState() if camState.mode == 5 then -- dirty workaround for https://springrts.com/mantis/view.php?id=5028 spEcho("Warning: you have Overview camera as default. This camera is not intended to start game with. Switching to Spring camera.") - Spring.SetCameraState(defaultCamState, 0) + SpringUnsynced.SetCameraState(defaultCamState, 0) end end function widget:GetConfigData() - local camState = Spring.GetCameraState() + local camState = SpringUnsynced.GetCameraState() local data = {} data = table.copy(camState) if data.ry then diff --git a/luaui/Widgets/camera_shake.lua b/luaui/Widgets/camera_shake.lua index e2351b93960..89766a4e5d2 100644 --- a/luaui/Widgets/camera_shake.lua +++ b/luaui/Widgets/camera_shake.lua @@ -28,8 +28,8 @@ end -- Localized functions for performance local mathFloor = math.floor -local spSetCameraOffset = Spring.SetCameraOffset -local spSetShockFrontFactors = Spring.SetShockFrontFactors +local spSetCameraOffset = SpringUnsynced.SetCameraOffset +local spSetShockFrontFactors = SpringShared.SetShockFrontFactors local math_random = math.random local exps = 0 diff --git a/luaui/Widgets/cmd_area_commands_filter.lua b/luaui/Widgets/cmd_area_commands_filter.lua index b880183460d..4fb590a4059 100644 --- a/luaui/Widgets/cmd_area_commands_filter.lua +++ b/luaui/Widgets/cmd_area_commands_filter.lua @@ -24,26 +24,26 @@ local tableSort = table.sort local mathFloor = math.floor local mathMax = math.max -local spGiveOrderToUnitArray = Spring.GiveOrderToUnitArray -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetUnitTeam = Spring.GetUnitTeam -local spGetFeatureDefID = Spring.GetFeatureDefID -local spGetFeaturesInCylinder = Spring.GetFeaturesInCylinder -local spGetSpectatingState = Spring.GetSpectatingState +local spGiveOrderToUnitArray = SpringSynced.GiveOrderToUnitArray +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetFeatureDefID = SpringShared.GetFeatureDefID +local spGetFeaturesInCylinder = SpringShared.GetFeaturesInCylinder +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local spGetMyAllyTeamID = Spring.GetMyAllyTeamID -local spGetUnitIsTransporting = Spring.GetUnitIsTransporting -local spGetUnitPosition = Spring.GetUnitPosition -local spGetFeaturePosition = Spring.GetFeaturePosition -local spGetUnitArrayCentroid = Spring.GetUnitArrayCentroid -local spGetFeatureResurrect = Spring.GetFeatureResurrect +local spGetUnitIsTransporting = SpringShared.GetUnitIsTransporting +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spGetUnitArrayCentroid = SpringShared.GetUnitArrayCentroid +local spGetFeatureResurrect = SpringShared.GetFeatureResurrect local spGetMyTeamID = Spring.GetMyTeamID -local ENEMY_UNITS = Spring.ENEMY_UNITS -local ALLY_UNITS = Spring.ALLY_UNITS -local ALL_UNITS = Spring.ALL_UNITS +local ENEMY_UNITS = SpringShared.ENEMY_UNITS +local ALLY_UNITS = SpringShared.ALLY_UNITS +local ALL_UNITS = SpringShared.ALL_UNITS local FEATURE = "feature" local UNIT = "unit" diff --git a/luaui/Widgets/cmd_area_mex.lua b/luaui/Widgets/cmd_area_mex.lua index dd256a572c2..a392ccdeaa0 100644 --- a/luaui/Widgets/cmd_area_mex.lua +++ b/luaui/Widgets/cmd_area_mex.lua @@ -15,11 +15,11 @@ end local CMD_AREA_MEX = GameCMD.AREA_MEX -local spGetActiveCommand = Spring.GetActiveCommand -local spGetUnitCommands = Spring.GetUnitCommands -local spGetMapDrawMode = Spring.GetMapDrawMode -local spGetUnitPosition = Spring.GetUnitPosition -local spSendCommands = Spring.SendCommands +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetUnitCommands = SpringShared.GetUnitCommands +local spGetMapDrawMode = SpringUnsynced.GetMapDrawMode +local spGetUnitPosition = SpringShared.GetUnitPosition +local spSendCommands = SpringUnsynced.SendCommands local taremove = table.remove local toggledMetal, retoggleLos @@ -182,7 +182,7 @@ function widget:CommandNotify(id, params, options) selectedMex = WG["resource_spot_builder"].GetBestExtractorFromBuilders(selectedUnits, mexConstructors, mexBuildings) end - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() local cmds = getCmdsForValidSpots(spots, shift) local sortedCmds = calculateCmdOrder(cmds, spots, shift) @@ -203,7 +203,7 @@ function widget:Update(dt) local _, cmd, _ = spGetActiveCommand() if cmd == CMD_AREA_MEX then if spGetMapDrawMode() ~= "metal" then - if Spring.GetMapDrawMode() == "los" then + if SpringUnsynced.GetMapDrawMode() == "los" then retoggleLos = true end spSendCommands("ShowMetalMap") @@ -213,7 +213,7 @@ function widget:Update(dt) if toggledMetal then spSendCommands("ShowStandard") if retoggleLos then - Spring.SendCommands("togglelos") + SpringUnsynced.SendCommands("togglelos") retoggleLos = nil end toggledMetal = false diff --git a/luaui/Widgets/cmd_area_unload.lua b/luaui/Widgets/cmd_area_unload.lua index 86406ba6183..397a57749fd 100644 --- a/luaui/Widgets/cmd_area_unload.lua +++ b/luaui/Widgets/cmd_area_unload.lua @@ -16,7 +16,7 @@ end local mathPi = math.pi -- Localized Spring API for performance -local spGiveOrderToUnit = Spring.GiveOrderToUnit +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit local math_sqrt = math.sqrt local CMD_UNLOAD_UNITS = CMD.UNLOAD_UNITS @@ -25,12 +25,12 @@ local function CanUnitExecute(uID, cmdID) if cmdID == CMD.UNLOAD_UNIT then -- should not happen since here we're working with area cmds but, better be safe then sorry i guess cmdID = CMD_UNLOAD_UNITS end - return (Spring.FindUnitCmdDesc(uID, cmdID) ~= nil) + return (SpringShared.FindUnitCmdDesc(uID, cmdID) ~= nil) end local function GetExecutingUnits(cmdID) local units = {} - local selUnits = Spring.GetSelectedUnits() + local selUnits = SpringUnsynced.GetSelectedUnits() for i = 1, #selUnits do local uID = selUnits[i] if CanUnitExecute(uID, cmdID) then @@ -53,7 +53,7 @@ end function widget:CommandNotify(id, params, options) if id == CMD.UNLOAD_UNITS then if params[4] and params[4] >= 64 then - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() local ray = params[4] local units = GetExecutingUnits(id) --if (2 * mathPi * ray*ray)/(#units) >= 128*128 then -- Surface check to prevent clumping (needs GUI before enabling check) @@ -69,7 +69,7 @@ function widget:CommandNotify(id, params, options) theta = 2 * mathPi * k / (phi * phi) x = params[1] + r * math.cos(theta) * ray z = params[3] + r * math.sin(theta) * ray - y = Spring.GetGroundHeight(x, z) + y = SpringShared.GetGroundHeight(x, z) spGiveOrderToUnit(units[k], CMD.UNLOAD_UNIT, { x, y, z }, { "shift" }) end --end diff --git a/luaui/Widgets/cmd_attack_no_ally.lua b/luaui/Widgets/cmd_attack_no_ally.lua index f594d74b0bc..bffb4403c25 100644 --- a/luaui/Widgets/cmd_attack_no_ally.lua +++ b/luaui/Widgets/cmd_attack_no_ally.lua @@ -27,18 +27,18 @@ local function GetAllyTarget(cmdParams) return nil end local targetUnitID = cmdParams[1] - if Spring.IsUnitAllied(targetUnitID) then + if SpringUnsynced.IsUnitAllied(targetUnitID) then return targetUnitID end return nil end local function IssueGroundCommand(cmdID, cmdOptions) - local mx, my = Spring.GetMouseState() - local _, pos = Spring.TraceScreenRay(mx, my, true) + local mx, my = SpringUnsynced.GetMouseState() + local _, pos = SpringUnsynced.TraceScreenRay(mx, my, true) if pos and pos[1] then - Spring.GiveOrder(cmdID, { pos[1], pos[2], pos[3] }, cmdOptions or {}) + SpringUnsynced.GiveOrder(cmdID, { pos[1], pos[2], pos[3] }, cmdOptions or {}) return true end return false @@ -59,13 +59,13 @@ function widget:MousePress(x, y, button) end if WG["attacknoally"] then - local _, activeCmdID = Spring.GetActiveCommand() + local _, activeCmdID = SpringUnsynced.GetActiveCommand() if activeCmdID and hasRightClickAttack[activeCmdID] then rmbCancelPending = true rmbDragTracking = true rmbDragged = false rmbStartX, rmbStartY = x, y - local dragThreshold = Spring.GetConfigInt("MouseDragFrontCommandThreshold") or 20 + local dragThreshold = SpringUnsynced.GetConfigInt("MouseDragFrontCommandThreshold") or 20 rmbDragThresholdSq = dragThreshold * dragThreshold end end @@ -108,7 +108,7 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOptions) rmbCancelPending = false rmbDragTracking = false rmbDragged = false - Spring.SetActiveCommand(nil) + SpringUnsynced.SetActiveCommand(nil) return true end @@ -119,7 +119,7 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOptions) return false end if not IssueGroundCommand(cmdID, cmdOptions) then - Spring.SetActiveCommand(nil) + SpringUnsynced.SetActiveCommand(nil) end return true end diff --git a/luaui/Widgets/cmd_autoquit.lua b/luaui/Widgets/cmd_autoquit.lua index 328d8796f68..1454760e0f2 100644 --- a/luaui/Widgets/cmd_autoquit.lua +++ b/luaui/Widgets/cmd_autoquit.lua @@ -12,11 +12,11 @@ local mousemoved = false ---------------------------------------------------------------- -- speedups ---------------------------------------------------------------- -local DiffTimers = Spring.DiffTimers -local GetTimer = Spring.GetTimer -local SendCommands = Spring.SendCommands -local Echo = Spring.Echo -local GetMouseState = Spring.GetMouseState +local DiffTimers = SpringUnsynced.DiffTimers +local GetTimer = SpringUnsynced.GetTimer +local SendCommands = SpringUnsynced.SendCommands +local Echo = SpringShared.Echo +local GetMouseState = SpringUnsynced.GetMouseState ---------------------------------------------------------------- -- callins @@ -37,7 +37,7 @@ function widget:GetInfo() end local chobbyLoaded = false -if Spring.GetMenuName and string.find(string.lower(Spring.GetMenuName()), "chobby") ~= nil then +if SpringUnsynced.GetMenuName and string.find(string.lower(SpringUnsynced.GetMenuName()), "chobby") ~= nil then chobbyLoaded = true end @@ -61,14 +61,14 @@ function widget:Update(dt) elseif not mousemoved and DiffTimers(GetTimer(), endTime) > delay then Echo(" Autoquit sending quit command.") if chobbyLoaded then - Spring.Reload("") + SpringUnsynced.Reload("") else SendCommands("quitforce") end elseif mousemoved and DiffTimers(GetTimer(), endTime) > mousemovedDelay then Echo(" Autoquit sending quit command.") if chobbyLoaded then - Spring.Reload("") + SpringUnsynced.Reload("") else SendCommands("quitforce") end diff --git a/luaui/Widgets/cmd_bar_hotkeys.lua b/luaui/Widgets/cmd_bar_hotkeys.lua index 1972727c0e9..00a75ef0763 100644 --- a/luaui/Widgets/cmd_bar_hotkeys.lua +++ b/luaui/Widgets/cmd_bar_hotkeys.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local currentLayout local currentKeybindingsFile @@ -42,15 +42,15 @@ end local function fallbackToDefault(currentKeys) local default = keyConfig.keybindingLayoutFiles[1] spEcho("BAR Hotkeys: Did not find keybindings file " .. currentKeys .. ". Loading grid keys") - Spring.SendCommands("keyreload " .. default) + SpringUnsynced.SendCommands("keyreload " .. default) return default end local function reloadBindings() -- Second parameter here is just a fallback if this config is undefined - currentLayout = Spring.GetConfigString("KeyboardLayout", "qwerty") + currentLayout = SpringUnsynced.GetConfigString("KeyboardLayout", "qwerty") - currentKeybindingsFile = Spring.GetConfigString("KeybindingFile", keyConfig.keybindingLayoutFiles[1]) + currentKeybindingsFile = SpringUnsynced.GetConfigString("KeybindingFile", keyConfig.keybindingLayoutFiles[1]) -- detect if old "default" settings are present, replace with "legacy" local usingOldPreset = string.find(currentKeybindingsFile, "default") and true or false @@ -64,11 +64,11 @@ local function reloadBindings() end if VFS.FileExists(currentKeybindingsFile) then - Spring.SendCommands("keyreload " .. currentKeybindingsFile) + SpringUnsynced.SendCommands("keyreload " .. currentKeybindingsFile) spEcho("BAR Hotkeys: Loaded hotkeys from " .. currentKeybindingsFile) if usingOldPreset then -- resolve upgrading from old "default" to "legacy" - Spring.SetConfigString("KeybindingFile", currentKeybindingsFile) + SpringUnsynced.SetConfigString("KeybindingFile", currentKeybindingsFile) end else spEcho("BAR Hotkeys: No hotkey file found") @@ -85,6 +85,6 @@ function widget:Initialize() end function widget:Shutdown() - Spring.SendCommands("keyreload") + SpringUnsynced.SendCommands("keyreload") reloadWidgetsBindings() end diff --git a/luaui/Widgets/cmd_blueprint.lua b/luaui/Widgets/cmd_blueprint.lua index 4830a5fb870..df13b7bd995 100644 --- a/luaui/Widgets/cmd_blueprint.lua +++ b/luaui/Widgets/cmd_blueprint.lua @@ -1,7 +1,7 @@ local widget = widget ---@type Widget -- makes the intent of our usage of Spring.Echo clear -local FeedbackForUser = Spring.Echo +local FeedbackForUser = SpringShared.Echo local SIDES = VFS.Include("gamedata/sides_enum.lua") local SubLogic = VFS.Include("luaui/Include/blueprint_substitution/logic.lua") @@ -28,8 +28,8 @@ local tableInsert = table.insert local tableSort = table.sort -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spGetSelectedUnits = Spring.GetSelectedUnits +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits -- types -- ===== @@ -49,11 +49,11 @@ local spGetSelectedUnits = Spring.GetSelectedUnits -- optimization -- ============ -local SpringGetMouseState = Spring.GetMouseState -local SpringGetModKeyState = Spring.GetModKeyState -local SpringGetActiveCommand = Spring.GetActiveCommand -local SpringTraceScreenRay = Spring.TraceScreenRay -local SpringGetUnitPosition = Spring.GetUnitPosition +local SpringGetMouseState = SpringUnsynced.GetMouseState +local SpringGetModKeyState = SpringUnsynced.GetModKeyState +local SpringGetActiveCommand = SpringUnsynced.GetActiveCommand +local SpringTraceScreenRay = SpringUnsynced.TraceScreenRay +local SpringGetUnitPosition = SpringShared.GetUnitPosition -- util -- ==== @@ -435,7 +435,7 @@ local function createBlueprint(unitIDs, ordered) blueprintUnitID = nextBlueprintUnitID(), unitDefID = unitDefID, position = { x, y, z }, - facing = Spring.GetUnitBuildFacing(unitID), + facing = SpringShared.GetUnitBuildFacing(unitID), originalName = unitName, } end), @@ -539,7 +539,7 @@ local function setBlueprintPlacementActive(active) if active then widget:SelectionChanged(spGetSelectedUnits()) - Spring.PlaySoundFile(sounds.activateBlueprint, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sounds.activateBlueprint, 0.75, "ui") else WG["api_blueprint"].setActiveBlueprint(nil) WG["api_blueprint"].setBlueprintPositions({}) @@ -608,7 +608,7 @@ function widget:Update(dt) end t = 0 - if pendingBoxSelect and not Spring.GetSelectionBox() then + if pendingBoxSelect and not SpringUnsynced.GetSelectionBox() then updateSelectedUnits(spGetSelectedUnits()) pendingBoxSelect = false end @@ -725,7 +725,7 @@ local drawCursorText = glListCache(function(index) end) local function reloadBindings() - currentLayout = Spring.GetConfigString("KeyboardLayout", "qwerty") + currentLayout = SpringUnsynced.GetConfigString("KeyboardLayout", "qwerty") actionHotkeys = VFS.Include("luaui/Include/action_hotkeys.lua") drawCursorText.invalidate() end @@ -759,7 +759,7 @@ function widget:SelectionChanged(selection) end -- track selection order (skip if we're still box selecting) - if Spring.GetSelectionBox() then + if SpringUnsynced.GetSelectionBox() then pendingBoxSelect = true else updateSelectedUnits(selection) @@ -808,7 +808,7 @@ local function handleBlueprintNextAction() setSelectedBlueprintIndex(getNextFilteredBlueprintIndex()) lastExplicitlySelectedBlueprintIndex = selectedBlueprintIndex - Spring.PlaySoundFile(sounds.selectBlueprint, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sounds.selectBlueprint, 0.75, "ui") return true end @@ -826,7 +826,7 @@ local function handleBlueprintPrevAction() setSelectedBlueprintIndex(getPrevFilteredBlueprintIndex()) lastExplicitlySelectedBlueprintIndex = selectedBlueprintIndex - Spring.PlaySoundFile(sounds.selectBlueprint, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sounds.selectBlueprint, 0.75, "ui") return true end @@ -837,7 +837,7 @@ local function handleBlueprintCreateAction() createBlueprint(unitIDs, true) setSelectedBlueprintIndex(#blueprints) - Spring.PlaySoundFile(sounds.createBlueprint, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sounds.createBlueprint, 0.75, "ui") return true end @@ -859,7 +859,7 @@ local function handleBlueprintDeleteAction() deleteBlueprint(selectedBlueprintIndex) - Spring.PlaySoundFile(sounds.deleteBlueprint, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sounds.deleteBlueprint, 0.75, "ui") return true end @@ -883,7 +883,7 @@ local function handleFacingAction(_, _, args) if newFacing then setBlueprintFacing(newFacing) - Spring.PlaySoundFile(sounds.facing, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sounds.facing, 0.75, "ui") return true end @@ -909,7 +909,7 @@ local function handleSpacingAction(_, _, args) if newSpacing then setBlueprintSpacing(newSpacing) - Spring.PlaySoundFile(sounds.spacing, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sounds.spacing, 0.75, "ui") return true end @@ -958,8 +958,8 @@ end local function createBuildingComparator(sortSpec) return function(a, b) - a = pack(Spring.Pos2BuildPos(a.unitDefID, a.position[1], a.position[2], a.position[3], a.facing)) - b = pack(Spring.Pos2BuildPos(b.unitDefID, b.position[1], b.position[2], b.position[3], b.facing)) + a = pack(SpringShared.Pos2BuildPos(a.unitDefID, a.position[1], a.position[2], a.position[3], a.facing)) + b = pack(SpringShared.Pos2BuildPos(b.unitDefID, b.position[1], b.position[2], b.position[3], b.facing)) for _, index in ipairs(sortSpec) do local ascending = index > 0 index = mathAbs(index) @@ -1030,9 +1030,9 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOpts) table.map(blueprint.units, function(bpu) local x = pos[1] + bpu.position[1] local z = pos[3] + bpu.position[3] - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) - local sx, sy, sz = Spring.Pos2BuildPos(bpu.unitDefID, x, y, z, bpu.facing) + local sx, sy, sz = SpringShared.Pos2BuildPos(bpu.unitDefID, x, y, z, bpu.facing) return { blueprintUnitID = bpu.blueprintUnitID, @@ -1059,7 +1059,7 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOpts) } end) - Spring.GiveOrderArrayToUnitArray(builders, orders, false) + SpringSynced.GiveOrderArrayToUnitArray(builders, orders, false) local alt, ctrl, meta, shift = unpack(state.modKeys) if not shift then diff --git a/luaui/Widgets/cmd_bomber_attack_building_ground.lua b/luaui/Widgets/cmd_bomber_attack_building_ground.lua index ae373e44856..5cd11c5c46e 100644 --- a/luaui/Widgets/cmd_bomber_attack_building_ground.lua +++ b/luaui/Widgets/cmd_bomber_attack_building_ground.lua @@ -16,12 +16,12 @@ local losGraceRadius = 75 local monitorTargets = {} local CMD_ATTACK = CMD.ATTACK local CMD_STOP = CMD.STOP -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitDefID = Spring.GetUnitDefID -local spGiveOrder = Spring.GiveOrder -local spGetUnitCommands = Spring.GetUnitCommands -local spIsPosInLos = Spring.IsPosInLos -local spValidUnitID = Spring.ValidUnitID +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGiveOrder = SpringUnsynced.GiveOrder +local spGetUnitCommands = SpringShared.GetUnitCommands +local spIsPosInLos = SpringShared.IsPosInLos +local spValidUnitID = SpringShared.ValidUnitID local isBuilding = {} local isBomber = {} @@ -91,9 +91,9 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOptions) if not isBuilding[spGetUnitDefID(targetBuildingID)] then return false end - local targetBuildingPosX, targetBuildingPosY, targetBuildingPosZ = Spring.GetUnitPosition(targetBuildingID) + local targetBuildingPosX, targetBuildingPosY, targetBuildingPosZ = SpringShared.GetUnitPosition(targetBuildingID) - local units = Spring.GetSelectedUnits() + local units = SpringUnsynced.GetSelectedUnits() local hasBomber = false for i = 1, #units do local unitID = units[i] diff --git a/luaui/Widgets/cmd_buildsplit.lua b/luaui/Widgets/cmd_buildsplit.lua index f98b9cef307..e98ba3de79c 100644 --- a/luaui/Widgets/cmd_buildsplit.lua +++ b/luaui/Widgets/cmd_buildsplit.lua @@ -14,15 +14,15 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local floor = math.floor -local spTestBuildOrder = Spring.TestBuildOrder -local spGetSelUnitCount = Spring.GetSelectedUnitsCount -local spGetSelUnitsSorted = Spring.GetSelectedUnitsSorted -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGiveOrderToUnitArray = Spring.GiveOrderToUnitArray +local spTestBuildOrder = SpringShared.TestBuildOrder +local spGetSelUnitCount = SpringUnsynced.GetSelectedUnitsCount +local spGetSelUnitsSorted = SpringUnsynced.GetSelectedUnitsSorted +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGiveOrderToUnitArray = SpringSynced.GiveOrderToUnitArray local activeModifier = false local unitBuildOptions = {} @@ -62,7 +62,7 @@ local function handleSetModifier(_, _, _, data) end function widget:Initialize() - gameStarted = Spring.GetGameFrame() > 0 + gameStarted = SpringShared.GetGameFrame() > 0 isSpec = spGetSpectatingState() if maybeRemoveSelf() then diff --git a/luaui/Widgets/cmd_chainactions.lua b/luaui/Widgets/cmd_chainactions.lua index fdc1069bbbb..87384e20e71 100644 --- a/luaui/Widgets/cmd_chainactions.lua +++ b/luaui/Widgets/cmd_chainactions.lua @@ -47,7 +47,7 @@ local function tryRawCmd(rawCmd, isRepeat, isRelease) end -- Attempt text command (for engine cmds) - Spring.SendCommands(rawCmd) + SpringUnsynced.SendCommands(rawCmd) return false end diff --git a/luaui/Widgets/cmd_commandinsert.lua b/luaui/Widgets/cmd_commandinsert.lua index e9de3bc34f8..2766920413d 100644 --- a/luaui/Widgets/cmd_commandinsert.lua +++ b/luaui/Widgets/cmd_commandinsert.lua @@ -19,10 +19,10 @@ end local tableInsert = table.insert -- Localized Spring API for performance -local spGetUnitPosition = Spring.GetUnitPosition -local spGetGameFrame = Spring.GetGameFrame -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spEcho = Spring.Echo +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetGameFrame = SpringShared.GetGameFrame +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spEcho = SpringShared.Echo local math_sqrt = math.sqrt @@ -39,7 +39,7 @@ function widget:GameStart() end function widget:PlayerChanged() - if Spring.GetSpectatingState() and spGetGameFrame() > 0 then + if SpringUnsynced.GetSpectatingState() and spGetGameFrame() > 0 then widgetHandler:RemoveWidget() end end @@ -73,7 +73,7 @@ local function releaseHandler(_, _, args) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then widget:PlayerChanged() end @@ -124,7 +124,7 @@ local function GetUnitOrFeaturePosition(id) if id < Game.maxUnits then return spGetUnitPosition(id) else - return Spring.GetFeaturePosition(id - Game.maxUnits) + return SpringShared.GetFeaturePosition(id - Game.maxUnits) end end @@ -160,14 +160,14 @@ function widget:CommandNotify(id, params, options) opt = opt + CMD.OPT_SHIFT if modifiers.prepend_queue then - Spring.GiveOrder(CMD.INSERT, { prependPos, id, opt, unpack(params) }, { "alt" }) + SpringUnsynced.GiveOrder(CMD.INSERT, { prependPos, id, opt, unpack(params) }, { "alt" }) prependPos = prependPos + 1 return true end else - Spring.GiveOrder(CMD.INSERT, { 0, id, opt, unpack(params) }, { "alt" }) + SpringUnsynced.GiveOrder(CMD.INSERT, { 0, id, opt, unpack(params) }, { "alt" }) return true end @@ -179,10 +179,10 @@ function widget:CommandNotify(id, params, options) return false end - local units = Spring.GetSelectedUnits() + local units = SpringUnsynced.GetSelectedUnits() for i = 1, #units do local unit_id = units[i] - local commands = Spring.GetUnitCommands(unit_id, 100) + local commands = SpringShared.GetUnitCommands(unit_id, 100) local px, py, pz = spGetUnitPosition(unit_id) local min_dlen = 1000000 local insert_pos = 0 @@ -214,7 +214,7 @@ function widget:CommandNotify(id, params, options) -- When we are editing the build order we want to keep same active command after unset by engine if id < 0 then - Spring.SetActiveCommand(Spring.GetCmdDescIndex(id), 1, true, false, options.alt, options.ctrl, false, false) + SpringUnsynced.SetActiveCommand(SpringUnsynced.GetCmdDescIndex(id), 1, true, false, options.alt, options.ctrl, false, false) end return true diff --git a/luaui/Widgets/cmd_commandq_manager.lua b/luaui/Widgets/cmd_commandq_manager.lua index dad189c02e1..163d6530c0a 100644 --- a/luaui/Widgets/cmd_commandq_manager.lua +++ b/luaui/Widgets/cmd_commandq_manager.lua @@ -19,12 +19,12 @@ function widget:Initialize() end -- Locals -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitCommands = Spring.GetUnitCommands -local spGetGameFrame = Spring.GetGameFrame +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitCommands = SpringShared.GetUnitCommands +local spGetGameFrame = SpringShared.GetGameFrame local CMDREPAIR = CMD.REPAIR local CMDRECLAIM = CMD.RECLAIM diff --git a/luaui/Widgets/cmd_comselect.lua b/luaui/Widgets/cmd_comselect.lua index 2c595ce0b72..f865a54e0cf 100644 --- a/luaui/Widgets/cmd_comselect.lua +++ b/luaui/Widgets/cmd_comselect.lua @@ -54,7 +54,7 @@ local function handleSelectComm(_, _, args) if not includeSelected then -- Fetch the current selected units that are commanders, we dont want to -- select an already selected unit if includeSelected is not passed - for unitDefID, selUnits in pairs(Spring.GetSelectedUnitsSorted()) do + for unitDefID, selUnits in pairs(SpringUnsynced.GetSelectedUnitsSorted()) do if commanderDefIDs[unitDefID] then for _, unitID in ipairs(selUnits) do selectedUnits[unitID] = true @@ -65,7 +65,7 @@ local function handleSelectComm(_, _, args) -- Fetch all current commander units local units = {} - local teamUnits = Spring.GetTeamUnitsByDefs(myTeamID, commanderDefIDsList) + local teamUnits = SpringShared.GetTeamUnitsByDefs(myTeamID, commanderDefIDsList) for _, unitID in ipairs(teamUnits) do if not selectedUnits[unitID] then tableInsert(units, unitID) @@ -95,11 +95,11 @@ local function handleSelectComm(_, _, args) local unitID = units[unitIndex] - Spring.SelectUnit(unitID, appendSelection) + SpringUnsynced.SelectUnit(unitID, appendSelection) if focusCamera then - local x, y, z = Spring.GetUnitPosition(unitID) - Spring.SetCameraTarget(x, y, z) + local x, y, z = SpringShared.GetUnitPosition(unitID) + SpringUnsynced.SetCameraTarget(x, y, z) end -- Halt the action chain, subsequent actions are not triggered diff --git a/luaui/Widgets/cmd_context_build.lua b/luaui/Widgets/cmd_context_build.lua index bac9b21e5fb..f19932459a0 100644 --- a/luaui/Widgets/cmd_context_build.lua +++ b/luaui/Widgets/cmd_context_build.lua @@ -1,8 +1,8 @@ local voidWater = false -local waterLevel = Spring.GetModOptions().map_waterlevel +local waterLevel = SpringShared.GetModOptions().map_waterlevel local waterIsLava = Spring.Lava.isLavaMap -local minHeight, _, _, _ = Spring.GetGroundExtremes() +local minHeight, _, _, _ = SpringShared.GetGroundExtremes() local success, mapinfo = pcall(VFS.Include, "mapinfo.lua") -- load mapinfo.lua confs if success and mapinfo then voidWater = mapinfo.voidwater @@ -26,16 +26,16 @@ end local tableInsert = table.insert -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local isPregame = spGetGameFrame() == 0 and not isSpec local uDefNames = UnitDefNames -local GetActiveCommand = Spring.GetActiveCommand -local SetActiveCommand = Spring.SetActiveCommand -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay +local GetActiveCommand = SpringUnsynced.GetActiveCommand +local SetActiveCommand = SpringUnsynced.SetActiveCommand +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay local currentTime = os.clock --- Human friendly list. Automatically converted to unitdef IDs on init @@ -147,7 +147,7 @@ end -- returns true if the given unitDefID can be built by the pregame start unit local function canSelectPreGameDef(uDefID) local myTeamID = Spring.GetMyTeamID() - local startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") + local startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") if not startDefID or not UnitDefs[startDefID] or not UnitDefs[startDefID].buildOptions then return false end @@ -282,7 +282,7 @@ local function addUnitDefPair(firstUnitName, lastUnitName) local lastUnitDef = uDefNames[lastUnitName] if not (firstUnitDef and lastUnitDef and firstUnitDef.id and lastUnitDef.id) then - Spring.Echo(string.format("%s: can't add %s/%s pair", "cmd_context_build", firstUnitName, lastUnitName)) + SpringShared.Echo(string.format("%s: can't add %s/%s pair", "cmd_context_build", firstUnitName, lastUnitName)) return end @@ -300,11 +300,11 @@ local function addUnitDefPair(firstUnitName, lastUnitName) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end - if Spring.GetModOptions().experimentallegionfaction then + if SpringShared.GetModOptions().experimentallegionfaction then for _, v in ipairs(legionUnitlist) do tableInsert(unitlist, v) end diff --git a/luaui/Widgets/cmd_customformations2.lua b/luaui/Widgets/cmd_customformations2.lua index 86d6b19f310..fda7077f6ac 100644 --- a/luaui/Widgets/cmd_customformations2.lua +++ b/luaui/Widgets/cmd_customformations2.lua @@ -16,8 +16,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetSelectedUnitsCount = Spring.GetSelectedUnitsCount +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetSelectedUnitsCount = SpringUnsynced.GetSelectedUnitsCount -- Behavior: -- To give a line command: select command, then right click & drag @@ -133,7 +133,7 @@ local usingRMB = false -- All commands use right mouse + drag to do a formation local inMinimap = false -- Is the line being drawn in the minimap local endShift = false -- True to reset command when shift is released -local MiniMapFullProxy = (Spring.GetConfigInt("MiniMapFullProxy", 0) == 1) +local MiniMapFullProxy = (SpringUnsynced.GetConfigInt("MiniMapFullProxy", 0) == 1) -------------------------------------------------------------------------------- -- Speedups @@ -150,22 +150,22 @@ local glScale = gl.Scale local glTranslate = gl.Translate local glLoadIdentity = gl.LoadIdentity -local spGetActiveCommand = Spring.GetActiveCommand -local spSetActiveCommand = Spring.SetActiveCommand -local spGetDefaultCommand = Spring.GetDefaultCommand -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc -local spGetModKeyState = Spring.GetModKeyState -local spGetInvertQueueKey = Spring.GetInvertQueueKey -local spIsAboveMiniMap = Spring.IsAboveMiniMap -local spGiveOrder = Spring.GiveOrder -local spGetUnitIsTransporting = Spring.GetUnitIsTransporting -local spGetUnitCommands = Spring.GetUnitCommands -local spGetUnitPosition = Spring.GetUnitPosition -local spGetGroundHeight = Spring.GetGroundHeight -local spGetFeaturePosition = Spring.GetFeaturePosition -local spGetCameraPosition = Spring.GetCameraPosition -local spGetViewGeometry = Spring.GetViewGeometry -local spTraceScreenRay = Spring.TraceScreenRay +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spSetActiveCommand = SpringUnsynced.SetActiveCommand +local spGetDefaultCommand = SpringUnsynced.GetDefaultCommand +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc +local spGetModKeyState = SpringUnsynced.GetModKeyState +local spGetInvertQueueKey = SpringUnsynced.GetInvertQueueKey +local spIsAboveMiniMap = SpringUnsynced.IsAboveMiniMap +local spGiveOrder = SpringUnsynced.GiveOrder +local spGetUnitIsTransporting = SpringShared.GetUnitIsTransporting +local spGetUnitCommands = SpringShared.GetUnitCommands +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spTraceScreenRay = SpringUnsynced.TraceScreenRay local mapSizeX, mapSizeZ = Game.mapSizeX, Game.mapSizeZ local maxUnits = Game.maxUnits @@ -651,7 +651,7 @@ function widget:MouseRelease(mx, my, mButton) -- we add the drag threshold code here -- tracing to a point with a drag threshold pixel delta added to mouse coord, to get world distance - local selectionThreshold = Spring.GetConfigInt("MouseDragFrontCommandThreshold") + local selectionThreshold = SpringUnsynced.GetConfigInt("MouseDragFrontCommandThreshold") local _, dragDeltaPos = spTraceScreenRay(mx, my + selectionThreshold, true, false, false, true) local _, pos = spTraceScreenRay(mx, my, true, false, false, true) local dragDelta = 0 @@ -710,7 +710,7 @@ function widget:MouseRelease(mx, my, mButton) local orderPos = orderPair[2] GiveNotifyingOrderToUnit(unitArr, orderArr, orderPair[1], CMD_INSERT, { 0, usingCmd, cmdOpts.coded, orderPos[1], orderPos[2], orderPos[3] }, altOpts) if (i == #orders and #unitArr > 0) or #unitArr >= 100 then - Spring.GiveOrderArrayToUnitArray(unitArr, orderArr, true) + SpringSynced.GiveOrderArrayToUnitArray(unitArr, orderArr, true) unitArr = {} orderArr = {} end @@ -720,14 +720,14 @@ function widget:MouseRelease(mx, my, mButton) local orderPair = orders[i] GiveNotifyingOrderToUnit(unitArr, orderArr, orderPair[1], usingCmd, orderPair[2], cmdOpts) if (i == #orders and #unitArr > 0) or #unitArr >= 100 then - Spring.GiveOrderArrayToUnitArray(unitArr, orderArr, true) + SpringSynced.GiveOrderArrayToUnitArray(unitArr, orderArr, true) unitArr = {} orderArr = {} end end end if usingCmd == CMD_SETTARGET then - Spring.SendLuaRulesMsg("settarget_line") + SpringUnsynced.SendLuaRulesMsg("settarget_line") end spSetActiveCommand(0) -- Deselect command end @@ -1525,7 +1525,7 @@ function widget:Initialize() local cmdOpts = GetCmdOpts(alt, ctrl, meta, shift, usingRMB) -- Get drag threshold - local selectionThreshold = Spring.GetConfigInt("MouseDragFrontCommandThreshold") or 20 + local selectionThreshold = SpringUnsynced.GetConfigInt("MouseDragFrontCommandThreshold") or 20 local dragDelta = selectionThreshold -- Approximate for external callers local adjustedMinFormationLength = max(dragDelta, minFormationLength) @@ -1556,7 +1556,7 @@ function widget:Initialize() local orderPos = orderPair[2] GiveNotifyingOrderToUnit(unitArr, orderArr, orderPair[1], CMD_INSERT, { 0, usingCmd, cmdOpts.coded, orderPos[1], orderPos[2], orderPos[3] }, altOpts) if (i == #orders and #unitArr > 0) or #unitArr >= 100 then - Spring.GiveOrderArrayToUnitArray(unitArr, orderArr, true) + SpringSynced.GiveOrderArrayToUnitArray(unitArr, orderArr, true) unitArr = {} orderArr = {} end @@ -1566,7 +1566,7 @@ function widget:Initialize() local orderPair = orders[i] GiveNotifyingOrderToUnit(unitArr, orderArr, orderPair[1], usingCmd, orderPair[2], cmdOpts) if (i == #orders and #unitArr > 0) or #unitArr >= 100 then - Spring.GiveOrderArrayToUnitArray(unitArr, orderArr, true) + SpringSynced.GiveOrderArrayToUnitArray(unitArr, orderArr, true) unitArr = {} orderArr = {} end diff --git a/luaui/Widgets/cmd_dance.lua b/luaui/Widgets/cmd_dance.lua index 84bc5bde192..5df6119a1cd 100644 --- a/luaui/Widgets/cmd_dance.lua +++ b/luaui/Widgets/cmd_dance.lua @@ -23,21 +23,21 @@ function widget:Initialize() end end widgetHandler:AddAction("dance", function() - local selected = Spring.GetSelectedUnits() + local selected = SpringUnsynced.GetSelectedUnits() local ids = {} for i = 1, #selected do - local unitDefID = Spring.GetUnitDefID(selected[i]) + local unitDefID = SpringShared.GetUnitDefID(selected[i]) if unitDefID and commanderDefs[unitDefID] then ids[#ids + 1] = selected[i] end end if #ids == 0 then - Spring.Echo("[Dance] Select a commander first!") + SpringShared.Echo("[Dance] Select a commander first!") return true end - Spring.SendLuaRulesMsg(REQUEST_HEADER .. table.concat(ids, ",")) + SpringUnsynced.SendLuaRulesMsg(REQUEST_HEADER .. table.concat(ids, ",")) return true end, nil, "t") end diff --git a/luaui/Widgets/cmd_default_set_target.lua b/luaui/Widgets/cmd_default_set_target.lua index efb686fd1e8..797c32bb848 100644 --- a/luaui/Widgets/cmd_default_set_target.lua +++ b/luaui/Widgets/cmd_default_set_target.lua @@ -13,16 +13,16 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local rebindKeys = false local CMD_UNIT_SET_TARGET = GameCMD.UNIT_SET_TARGET -local IsUnitAllied = Spring.IsUnitAllied -local GetSelectedUnitsCounts = Spring.GetSelectedUnitsCounts -local GetActionHotKeys = Spring.GetActionHotKeys -local SendCommmands = Spring.SendCommands +local IsUnitAllied = SpringUnsynced.IsUnitAllied +local GetSelectedUnitsCounts = SpringUnsynced.GetSelectedUnitsCounts +local GetActionHotKeys = SpringUnsynced.GetActionHotKeys +local SendCommmands = SpringUnsynced.SendCommands local hotKeys = {} local gameStarted @@ -35,7 +35,7 @@ for udid, ud in pairs(UnitDefs) do end local function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() return true end @@ -51,7 +51,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then if maybeRemoveSelf() then return end diff --git a/luaui/Widgets/cmd_dgun_no_ally.lua b/luaui/Widgets/cmd_dgun_no_ally.lua index 2b19758931b..06dea58fcba 100644 --- a/luaui/Widgets/cmd_dgun_no_ally.lua +++ b/luaui/Widgets/cmd_dgun_no_ally.lua @@ -31,18 +31,18 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOptions) if #cmdParams ~= 1 then return false end -- dgun is already aimed at ground - if cmdParams[1] > 0 and not Spring.IsUnitAllied(cmdParams[1]) then + if cmdParams[1] > 0 and not SpringUnsynced.IsUnitAllied(cmdParams[1]) then return false end -- still snap aim at enemy units -- get map position behind cursor - local mouseX, mouseY = Spring.GetMouseState() - local desc, cmdParams = Spring.TraceScreenRay(mouseX, mouseY, true) + local mouseX, mouseY = SpringUnsynced.GetMouseState() + local desc, cmdParams = SpringUnsynced.TraceScreenRay(mouseX, mouseY, true) if nil == desc then return false end -- off map, can not handle this properly here -- replace dgun order - Spring.GiveOrder(cmdID, cmdParams, cmdOptions) + SpringUnsynced.GiveOrder(cmdID, cmdParams, cmdOptions) return true end diff --git a/luaui/Widgets/cmd_dgun_no_ground enemies.lua b/luaui/Widgets/cmd_dgun_no_ground enemies.lua index 8d0cc703971..73ecd6cd7ed 100644 --- a/luaui/Widgets/cmd_dgun_no_ground enemies.lua +++ b/luaui/Widgets/cmd_dgun_no_ground enemies.lua @@ -48,25 +48,25 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOptions) -- number of cmdParams should either be -- 1 (unitID) or -- 3 (map coordinates) - if #cmdParams ~= 1 or select(4, Spring.GetModKeyState()) then -- dgun is already aimed at ground, or when you hold SHIFT + if #cmdParams ~= 1 or select(4, SpringUnsynced.GetModKeyState()) then -- dgun is already aimed at ground, or when you hold SHIFT return false end - local mouseX, mouseY = Spring.GetMouseState() - local desc, cmdParams2 = Spring.TraceScreenRay(mouseX, mouseY, true) + local mouseX, mouseY = SpringUnsynced.GetMouseState() + local desc, cmdParams2 = SpringUnsynced.TraceScreenRay(mouseX, mouseY, true) if nil == desc then -- off map, can not handle this properly here return false end - if cmdParams2[1] > 0 and not Spring.IsUnitAllied(cmdParams2[1]) then -- still snap aim at enemy units - local unitDefID = Spring.GetUnitDefID(cmdParams[1]) + if cmdParams2[1] > 0 and not SpringUnsynced.IsUnitAllied(cmdParams2[1]) then -- still snap aim at enemy units + local unitDefID = SpringShared.GetUnitDefID(cmdParams[1]) -- exclude air and ships, also hovers when on water - if isAirUnit[unitDefID] or isShip[unitDefID] or isUnderwater[unitDefID] or (Spring.GetGroundHeight(cmdParams2[1], cmdParams2[3]) < 0 and isHover[unitDefID]) then + if isAirUnit[unitDefID] or isShip[unitDefID] or isUnderwater[unitDefID] or (SpringShared.GetGroundHeight(cmdParams2[1], cmdParams2[3]) < 0 and isHover[unitDefID]) then return false end end -- replace dgun order - Spring.GiveOrder(cmdID, cmdParams2, cmdOptions) + SpringUnsynced.GiveOrder(cmdID, cmdParams2, cmdOptions) return true end diff --git a/luaui/Widgets/cmd_exclude_walls_area_attacks.lua b/luaui/Widgets/cmd_exclude_walls_area_attacks.lua index 2ef380e7e74..1f40e04d065 100644 --- a/luaui/Widgets/cmd_exclude_walls_area_attacks.lua +++ b/luaui/Widgets/cmd_exclude_walls_area_attacks.lua @@ -19,8 +19,8 @@ local CMD_STOP = CMD.STOP local excludedUnitsDefID = {} -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitNeutral = Spring.GetUnitNeutral +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitNeutral = SpringShared.GetUnitNeutral for id, unitDef in pairs(UnitDefs) do if unitDef.customParams.objectify then @@ -44,7 +44,7 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOpts) end local cmdX, _, cmdZ, cmdRadius = unpack(cmdParams) - local areaUnits = Spring.GetUnitsInCylinder(cmdX, cmdZ, cmdRadius, Spring.ENEMY_UNITS) + local areaUnits = SpringShared.GetUnitsInCylinder(cmdX, cmdZ, cmdRadius, SpringShared.ENEMY_UNITS) local newCmds = {} local somethingWasExcluded = false @@ -61,7 +61,7 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOpts) end end if #newCmds > 0 and somethingWasExcluded then - Spring.GiveOrderArrayToUnitArray(Spring.GetSelectedUnits(), newCmds) + SpringSynced.GiveOrderArrayToUnitArray(SpringUnsynced.GetSelectedUnits(), newCmds) return true end end diff --git a/luaui/Widgets/cmd_extractor_snap.lua b/luaui/Widgets/cmd_extractor_snap.lua index b5708d69289..7c15d454556 100644 --- a/luaui/Widgets/cmd_extractor_snap.lua +++ b/luaui/Widgets/cmd_extractor_snap.lua @@ -18,10 +18,10 @@ local mathAbs = math.abs include("keysym.h.lua") -local spGetActiveCommand = Spring.GetActiveCommand -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay -local spPos2BuildPos = Spring.Pos2BuildPos +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spPos2BuildPos = SpringShared.Pos2BuildPos local mexConstructors local geoConstructors @@ -39,7 +39,7 @@ local metalMap = false local metalSpots = {} local geoSpots = {} -local isPregame = Spring.GetGameFrame() == 0 and not Spring.GetSpectatingState() +local isPregame = SpringShared.GetGameFrame() == 0 and not SpringUnsynced.GetSpectatingState() local function MakeLine(x1, y1, z1, x2, y2, z2) gl.Vertex(x1, y1, z1) @@ -89,7 +89,7 @@ end ---@param uid table unitDefID ---@param pos table position in format { x, y, z } local function clashesWithBuildQueue(uid, pos) - local units = Spring.GetSelectedUnits() + local units = SpringUnsynced.GetSelectedUnits() -- local building test functions taken from pregame_build local function GetBuildingDimensions(uDefID, facing) @@ -111,7 +111,7 @@ local function clashesWithBuildQueue(uid, pos) return mathAbs(buildData1[2] - buildData2[2]) < w1 + w2 and mathAbs(buildData1[4] - buildData2[4]) < h1 + h2 end - local buildFacing = Spring.GetBuildFacing() + local buildFacing = SpringUnsynced.GetBuildFacing() local newBuildData = { uid, pos.x, pos.y, pos.z, buildFacing } if isPregame then local queue = WG["pregame-build"].getBuildQueue() @@ -122,7 +122,7 @@ local function clashesWithBuildQueue(uid, pos) end else for i = 1, #units do - local queue = Spring.GetUnitCommands(units[i], 100) + local queue = SpringShared.GetUnitCommands(units[i], 100) if queue then for j = 1, #queue do local command = queue[j] @@ -183,7 +183,7 @@ function widget:Update() -- Attempt to get position of command local buildingId = -activeCmdID local mx, my, mb, mmb, mrb = spGetMouseState() - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() local _, pos = spTraceScreenRay(mx, my, true) if not pos or not pos[1] then clear() @@ -262,7 +262,7 @@ local endShift = false local function handleBuildMenu(shift) endShift = shift if not shift then - Spring.SetActiveCommand(0) + SpringUnsynced.SetActiveCommand(0) end local grid = WG["gridmenu"] if not grid or not grid.clearCategory or not grid.getAlwaysReturn or not grid.setCurrentCategory then @@ -282,8 +282,8 @@ function widget:MousePress(x, y, button) end if button == 1 and buildCmd and buildCmd[1] then - local alt, ctrl, meta, shift = Spring.GetModKeyState() - shift = Spring.GetInvertQueueKey() and not shift or shift + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() + shift = SpringUnsynced.GetInvertQueueKey() and not shift or shift if selectedMex then WG["resource_spot_builder"].ApplyPreviewCmds(buildCmd, mexConstructors, shift) handleBuildMenu(shift) @@ -300,7 +300,7 @@ end -- I really hate that I have to do this, but something is hardcoding shift behavior with mouse clicks, and I need to override it function widget:KeyRelease(code) if endShift and (code == KEYSYMS.LSHIFT or code == KEYSYMS.RSHIFT) then - Spring.SetActiveCommand(0) + SpringUnsynced.SetActiveCommand(0) endShift = false end end diff --git a/luaui/Widgets/cmd_fac_holdposition.lua b/luaui/Widgets/cmd_fac_holdposition.lua index c09156a21a4..80b72e4bc72 100644 --- a/luaui/Widgets/cmd_fac_holdposition.lua +++ b/luaui/Widgets/cmd_fac_holdposition.lua @@ -29,7 +29,7 @@ end function widget:UnitCreated(unitID, unitDefID, unitTeam, builderID) if unitTeam == myTeamID then if landFactories[unitDefID] then - Spring.GiveOrderToUnit(unitID, CMD.MOVE_STATE, { 0 }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.MOVE_STATE, { 0 }, 0) end end end @@ -38,7 +38,7 @@ end ---------------------------------------------- local function maybeRemoveSelf() - if Spring.IsReplay() or Spring.GetSpectatingState() then + if SpringUnsynced.IsReplay() or SpringUnsynced.GetSpectatingState() then widgetHandler.RemoveWidget() end end diff --git a/luaui/Widgets/cmd_factory_guard_pref.lua b/luaui/Widgets/cmd_factory_guard_pref.lua index 96a223bebec..855d75ab496 100644 --- a/luaui/Widgets/cmd_factory_guard_pref.lua +++ b/luaui/Widgets/cmd_factory_guard_pref.lua @@ -34,6 +34,6 @@ end function widget:UnitCreated(unitID, unitDefID, unitTeam, builderID) if isFactory[unitDefID] then - Spring.GiveOrderToUnit(unitID, CMD_FACTORY_GUARD, { 1 }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD_FACTORY_GUARD, { 1 }, 0) end end diff --git a/luaui/Widgets/cmd_factory_repeat.lua b/luaui/Widgets/cmd_factory_repeat.lua index 3121b89f3aa..a4cb3f125c6 100644 --- a/luaui/Widgets/cmd_factory_repeat.lua +++ b/luaui/Widgets/cmd_factory_repeat.lua @@ -26,7 +26,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -41,7 +41,7 @@ for udid, ud in pairs(UnitDefs) do end function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -56,14 +56,14 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end end function widget:UnitCreated(unitID, unitDefID, unitTeam) if isFactory[unitDefID] then - Spring.GiveOrderToUnit(unitID, CMD.REPEAT, { 1 }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.REPEAT, { 1 }, 0) end end diff --git a/luaui/Widgets/cmd_factoryqmanager.lua b/luaui/Widgets/cmd_factoryqmanager.lua index 7a7cc046963..6290d1fa8b6 100644 --- a/luaui/Widgets/cmd_factoryqmanager.lua +++ b/luaui/Widgets/cmd_factoryqmanager.lua @@ -21,11 +21,11 @@ local mathMax = math.max local mathMin = math.min -- Localized Spring API for performance -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetGameFrame = Spring.GetGameFrame -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSelectedUnitsSorted = Spring.GetSelectedUnitsSorted +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetGameFrame = SpringShared.GetGameFrame +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSelectedUnitsSorted = SpringUnsynced.GetSelectedUnitsSorted --Changelog --1.5: added repeat icon and bindable keybind actions to activate @@ -129,9 +129,9 @@ local SortQueueToUnits local CalcDrawCoords local UiUnit, UiElement -local spEcho = Spring.Echo -local spGetModKeyState = Spring.GetModKeyState -local lastGameSeconds = Spring.GetGameSeconds() +local spEcho = SpringShared.Echo +local spGetModKeyState = SpringUnsynced.GetModKeyState +local lastGameSeconds = SpringShared.GetGameSeconds() local font, gameStarted, selUnits @@ -193,7 +193,7 @@ function widget:ViewResize() end function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -279,7 +279,7 @@ function ClearFactoryQueues() for udidFac, uTable in pairs(udTable) do if isFactory[udidFac] then for _, uid in ipairs(uTable) do - local queue = Spring.GetRealBuildQueue(uid) + local queue = SpringShared.GetRealBuildQueue(uid) if queue ~= nil then for udid, buildPair in ipairs(queue) do local udid, count = next(buildPair, nil) @@ -300,7 +300,7 @@ function getSingleFactory() return nil, nil end - local unitDefID = Spring.GetUnitDefID(selUnits[1]) + local unitDefID = SpringShared.GetUnitDefID(selUnits[1]) if not isFactory[unitDefID] then return nil, nil else @@ -310,7 +310,7 @@ function getSingleFactory() end function saveQueue(unitId, unitDef, groupNo) - local unitQ = Spring.GetFactoryCommands(unitId, -1) + local unitQ = SpringShared.GetFactoryCommands(unitId, -1) if #unitQ <= 0 then --queue is empty -> signal to delete preset savedQueues[curModId][unitDef.id][groupNo] = nil @@ -325,10 +325,10 @@ function saveQueue(unitId, unitDef, groupNo) end savedQueues[curModId][unitDef.id][groupNo] = unitQ - savedQueues[curModId][unitDef.id][groupNo][facRepeatIdx] = select(4, Spring.GetUnitStates(unitId, false, true)) -- 4=repeat + savedQueues[curModId][unitDef.id][groupNo][facRepeatIdx] = select(4, SpringShared.GetUnitStates(unitId, false, true)) -- 4=repeat modifiedGroup = groupNo - modifiedGroupTime = Spring.GetGameSeconds() + modifiedGroupTime = SpringShared.GetGameSeconds() modifiedSaved = true --force box coords table refresh @@ -346,7 +346,7 @@ function loadQueue(unitId, unitDef, groupNo) if queue ~= nil and #queue > 0 then ClearFactoryQueues() modifiedGroup = groupNo - modifiedGroupTime = Spring.GetGameSeconds() + modifiedGroupTime = SpringShared.GetGameSeconds() modifiedSaved = false --set factory to repeat on/off @@ -393,8 +393,8 @@ local function factoryPresetRender(_, _, _, data) end function CalcDrawCoords(unitId, heightAll) - local xw, yw, zw = Spring.GetUnitViewPosition(unitId) - local x, y, _ = Spring.WorldToScreenCoords(xw, yw, zw) + local xw, yw, zw = SpringUnsynced.GetUnitViewPosition(unitId) + local x, y, _ = SpringUnsynced.WorldToScreenCoords(xw, yw, zw) if x + boxWidth - 1 > vsx then x = x - boxWidth @@ -459,7 +459,7 @@ function DrawBoxGroup(x, y, yOffset, unitDef, selUnit, alpha, groupNo, queue) local units = SortQueueToUnits(queue) --end --Draw "loaded" border - if modifiedGroup == groupNo and modifiedGroupTime > Spring.GetGameSeconds() - loadedBorderDisplayTime then + if modifiedGroup == groupNo and modifiedGroupTime > SpringShared.GetGameSeconds() - loadedBorderDisplayTime then if modifiedSaved == true then gl.Color(1, 0, 0, mathMin(alpha, 1.0)) else @@ -516,7 +516,7 @@ function DrawBoxGroup(x, y, yOffset, unitDef, selUnit, alpha, groupNo, queue) end --draw "loaded" text - if modifiedGroup == groupNo and modifiedGroupTime > Spring.GetGameSeconds() - loadedBorderDisplayTime then + if modifiedGroup == groupNo and modifiedGroupTime > SpringShared.GetGameSeconds() - loadedBorderDisplayTime then local lText = "Loaded" if modifiedSaved == true then lText = "Saved" @@ -594,7 +594,7 @@ function DrawBoxes() end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end widget:ViewResize() @@ -607,7 +607,7 @@ function widget:Initialize() end function widget:Update() - local now = Spring.GetGameSeconds() + local now = SpringShared.GetGameSeconds() local timediff = now - lastGameSeconds if renderPresets then diff --git a/luaui/Widgets/cmd_gamespeed.lua b/luaui/Widgets/cmd_gamespeed.lua index 95daf2c0699..5660fb269aa 100644 --- a/luaui/Widgets/cmd_gamespeed.lua +++ b/luaui/Widgets/cmd_gamespeed.lua @@ -31,13 +31,13 @@ local speedLevels = { } local function setGameSpeed(speed) - if Spring.Utilities.Gametype.IsSinglePlayer() or Spring.IsCheatingEnabled() or Spring.IsReplay() then - Spring.SendCommands("setspeed " .. speed) + if Spring.Utilities.Gametype.IsSinglePlayer() or SpringShared.IsCheatingEnabled() or SpringUnsynced.IsReplay() then + SpringUnsynced.SendCommands("setspeed " .. speed) end end local function increaseSpeed() - local currentSpeed = Spring.GetGameSpeed() + local currentSpeed = SpringUnsynced.GetGameSpeed() if currentSpeed >= speedLevels[#speedLevels] then return @@ -52,7 +52,7 @@ local function increaseSpeed() end local function decreaseSpeed() - local currentSpeed = Spring.GetGameSpeed() + local currentSpeed = SpringUnsynced.GetGameSpeed() if currentSpeed <= speedLevels[1] then return diff --git a/luaui/Widgets/cmd_guard_damaged_constructors.lua b/luaui/Widgets/cmd_guard_damaged_constructors.lua index aa050009cd4..18860fca7ea 100644 --- a/luaui/Widgets/cmd_guard_damaged_constructors.lua +++ b/luaui/Widgets/cmd_guard_damaged_constructors.lua @@ -29,11 +29,11 @@ function widget:DefaultCommand(targetType, targetID, engineCmd) end if engineCmd == CMD.REPAIR then - if Spring.GetUnitIsBeingBuilt(targetID) then + if SpringShared.GetUnitIsBeingBuilt(targetID) then return end - local unitDefID = Spring.GetUnitDefID(targetID) + local unitDefID = SpringShared.GetUnitDefID(targetID) if (isConstructor[unitDefID] and guardConstructors) or (isFactory[unitDefID] and guardFactories) then return CMD.GUARD end diff --git a/luaui/Widgets/cmd_guard_remove.lua b/luaui/Widgets/cmd_guard_remove.lua index b6f8b4b4b4b..f9ac2908047 100644 --- a/luaui/Widgets/cmd_guard_remove.lua +++ b/luaui/Widgets/cmd_guard_remove.lua @@ -29,11 +29,11 @@ include("keysym.h.lua") local math_distsq = math.distance3dSquared -local spGetCmdDescIndex = Spring.GetCmdDescIndex -local spGetActiveCmdDesc = Spring.GetActiveCmdDesc -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGiveOrderToUnit = Spring.GiveOrderToUnit +local spGetCmdDescIndex = SpringUnsynced.GetCmdDescIndex +local spGetActiveCmdDesc = SpringUnsynced.GetActiveCmdDesc +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit local CMD_REMOVE = CMD.REMOVE local CMDTYPE_ICON_MODE = CMDTYPE.ICON_MODE @@ -45,7 +45,7 @@ local recentUnits = {} local updateTime = 0 local gameTime = 0 -- Regardless of the preference above, we don't need to go any lower than the double-click speed. -safeguardDuration = math.max(safeguardDuration, Spring.GetConfigInt("DoubleClickTime", 200) / 1000) +safeguardDuration = math.max(safeguardDuration, SpringUnsynced.GetConfigInt("DoubleClickTime", 200) / 1000) local validUnit = {} for udid, ud in pairs(UnitDefs) do diff --git a/luaui/Widgets/cmd_guard_transport_factory.lua b/luaui/Widgets/cmd_guard_transport_factory.lua index 0d9c4346ee9..9861c632279 100644 --- a/luaui/Widgets/cmd_guard_transport_factory.lua +++ b/luaui/Widgets/cmd_guard_transport_factory.lua @@ -77,17 +77,17 @@ for id, def in pairs(UnitDefs) do } end -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGiveOrderToUnit = Spring.GiveOrderToUnit +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit local CMD_REMOVE = CMD.REMOVE local function isFactory(unitID) - return cachedUnitDefs[Spring.GetUnitDefID(unitID)].isFactory + return cachedUnitDefs[SpringShared.GetUnitDefID(unitID)].isFactory end local function isTransport(unitID) - return cachedUnitDefs[Spring.GetUnitDefID(unitID)].isTransport + return cachedUnitDefs[SpringShared.GetUnitDefID(unitID)].isTransport end local function distance(point1, point2) @@ -104,7 +104,7 @@ local function timeToTarget(start, endpoint, speed) end local function getValidRallyCommandDestination(unitID) - local cmdID, options, tag, targetX, targetY, targetZ = Spring.GetUnitCurrentCommand(unitID, 2) + local cmdID, options, tag, targetX, targetY, targetZ = SpringShared.GetUnitCurrentCommand(unitID, 2) local cmdValid = cmdID == CMD.MOVE or cmdID < 0 if cmdID == nil or not cmdValid then return nil @@ -114,24 +114,24 @@ local function getValidRallyCommandDestination(unitID) end local function isWaiting(unitID) - local cmdID = Spring.GetUnitCurrentCommand(unitID, 1) + local cmdID = SpringShared.GetUnitCurrentCommand(unitID, 1) return cmdID and cmdID == CMD.WAIT end local function tryDeactivateWait(unitID) if isWaiting(unitID) then - Spring.GiveOrderToUnit(unitID, CMD.WAIT, {}, CMD.OPT_ALT) + SpringSynced.GiveOrderToUnit(unitID, CMD.WAIT, {}, CMD.OPT_ALT) end end local function tryActivateWait(unitID) if not isWaiting(unitID) then - Spring.GiveOrderToUnit(unitID, CMD.WAIT, {}, CMD.OPT_ALT) + SpringSynced.GiveOrderToUnit(unitID, CMD.WAIT, {}, CMD.OPT_ALT) end end local function IsUnitAlive(unitID) - return Spring.ValidUnitID(unitID) and not Spring.GetUnitIsDead(unitID) + return SpringShared.ValidUnitID(unitID) and not SpringShared.GetUnitIsDead(unitID) end local function registerTransport(transportID, factoryID) @@ -146,19 +146,19 @@ local function activateTransportGuard(transportID, factoryID) registerTransport(transportID, factoryID) -- If carrying a unit, unload it at current position before guarding - local carriedUnits = Spring.GetUnitIsTransporting(transportID) + local carriedUnits = SpringShared.GetUnitIsTransporting(transportID) if carriedUnits and #carriedUnits > 0 then - local x, _, z = Spring.GetUnitPosition(transportID) + local x, _, z = SpringShared.GetUnitPosition(transportID) transportState[transportID] = transport_states.picking_up activeTransportToUnit[transportID] = carriedUnits[1] - unitToDestination[carriedUnits[1]] = { x, Spring.GetGroundHeight(x, z), z } + unitToDestination[carriedUnits[1]] = { x, SpringShared.GetGroundHeight(x, z), z } else transportState[transportID] = transport_states.idle end end function widget:Initialize() - if Spring.GetSpectatingState() or Spring.IsReplay() then + if SpringUnsynced.GetSpectatingState() or SpringUnsynced.IsReplay() then widgetHandler:RemoveWidget() return end @@ -170,8 +170,8 @@ function widget:Initialize() blacklistOrderedUnits = value end - for _, unitID in ipairs(Spring.GetTeamUnits(Spring.GetLocalTeamID())) do - local cmdID, _, _, targetUnitID = Spring.GetUnitCurrentCommand(unitID, 1) + for _, unitID in ipairs(SpringShared.GetTeamUnits(SpringUnsynced.GetLocalTeamID())) do + local cmdID, _, _, targetUnitID = SpringShared.GetUnitCurrentCommand(unitID, 1) local isGuarding = cmdID == CMD.GUARD if isGuarding and isTransport(unitID) and isFactory(targetUnitID) then @@ -182,7 +182,7 @@ function widget:Initialize() end local function isTransportingUnit(transportID, unitID) - local transported = Spring.GetUnitIsTransporting(transportID) or {} + local transported = SpringShared.GetUnitIsTransporting(transportID) or {} for _, id in ipairs(transported) do if unitID == id then return true @@ -196,20 +196,20 @@ local function handleTransport(transportID, target) -- unit has been blown up, reset to unloaded transportState[transportID] = transport_states.unloaded activeTransportToUnit[transportID] = nil - Spring.GiveOrderToUnit(transportID, CMD.GUARD, transportToFactory[transportID], CMD.OPT_SHIFT) -- go back to base + SpringSynced.GiveOrderToUnit(transportID, CMD.GUARD, transportToFactory[transportID], CMD.OPT_SHIFT) -- go back to base return else -- Order the built unit to stop if it's out of the factory if transportState[transportID] == transport_states.picking_up then - local factoryLocation = { Spring.GetUnitPosition(transportToFactory[transportID]) } - local unitLocation = { Spring.GetUnitPosition(target) } + local factoryLocation = { SpringShared.GetUnitPosition(transportToFactory[transportID]) } + local unitLocation = { SpringShared.GetUnitPosition(target) } local isFarFromFactory = distance(factoryLocation, unitLocation) > FACTORY_CLEARANCE_DISTANCE -- Check if we picked up the unit already if isTransportingUnit(transportID, target) then transportState[transportID] = transport_states.loaded tryDeactivateWait(target) - Spring.GiveOrderToUnit(transportID, CMD.UNLOAD_UNIT, unitToDestination[target], CMD.OPT_RIGHT) + SpringSynced.GiveOrderToUnit(transportID, CMD.UNLOAD_UNIT, unitToDestination[target], CMD.OPT_RIGHT) return end @@ -230,10 +230,10 @@ local function handleTransport(transportID, target) -- Check if unit has left transport -- TODO: In order to support transports with capacity > 1, we need to add logic for the -- transport to keep waiting until it sees a unit that it can't pick up. - local carriedUnits = Spring.GetUnitIsTransporting(transportID) + local carriedUnits = SpringShared.GetUnitIsTransporting(transportID) if carriedUnits == nil or #carriedUnits == 0 and transportState[transportID] == transport_states.loaded then transportState[transportID] = transport_states.unloaded - Spring.GiveOrderToUnit(transportID, CMD.GUARD, transportToFactory[transportID], CMD.OPT_SHIFT) -- go back to base + SpringSynced.GiveOrderToUnit(transportID, CMD.GUARD, transportToFactory[transportID], CMD.OPT_SHIFT) -- go back to base tryDeactivateWait(target) return end @@ -242,11 +242,11 @@ local function handleTransport(transportID, target) if transportState[transportID] == transport_states.approaching then if isWaiting(target) then transportState[transportID] = transport_states.picking_up - Spring.GiveOrderToUnit(transportID, CMD.LOAD_UNITS, target, CMD.OPT_RIGHT) --Load Unit + SpringSynced.GiveOrderToUnit(transportID, CMD.LOAD_UNITS, target, CMD.OPT_RIGHT) --Load Unit end - local factoryLocation = { Spring.GetUnitPosition(transportToFactory[transportID]) } - local unitLocation = { Spring.GetUnitPosition(target) } + local factoryLocation = { SpringShared.GetUnitPosition(transportToFactory[transportID]) } + local unitLocation = { SpringShared.GetUnitPosition(target) } local isFarFromFactory = distance(factoryLocation, unitLocation) > FACTORY_CLEARANCE_DISTANCE if isFarFromFactory then @@ -302,8 +302,8 @@ local function inactivateTransport(unitID) end local function canTransport(transportID, unitID) - local udef = Spring.GetUnitDefID(unitID) - local tdef = Spring.GetUnitDefID(transportID) + local udef = SpringShared.GetUnitDefID(unitID) + local tdef = SpringShared.GetUnitDefID(transportID) if not udef or not tdef then return false @@ -316,7 +316,7 @@ local function canTransport(transportID, unitID) return false end - local trans = Spring.GetUnitIsTransporting(transportID) -- capacity check + local trans = SpringShared.GetUnitIsTransporting(transportID) -- capacity check if tDefObj.transportCapacity <= #trans then return false end @@ -327,7 +327,7 @@ local function canTransport(transportID, unitID) local mass = 0 -- mass check for _, a in ipairs(trans) do - local aDefID = Spring.GetUnitDefID(a) + local aDefID = SpringShared.GetUnitDefID(a) if aDefID then mass = mass + cachedUnitDefs[aDefID].mass end @@ -368,10 +368,10 @@ end function widget:UnitFromFactory(unitID, unitDefID, unitTeam, factID, factDefID, userOrders) local createdUnitID = unitID - if Spring.AreTeamsAllied(unitTeam, Spring.GetLocalTeamID()) then + if SpringShared.AreTeamsAllied(unitTeam, SpringUnsynced.GetLocalTeamID()) then if isTransport(createdUnitID) then -- Handle case where transport is rallied to another lab - local cmdID, _, _, targetUnitID = Spring.GetUnitCurrentCommand(createdUnitID, 1) + local cmdID, _, _, targetUnitID = SpringShared.GetUnitCurrentCommand(createdUnitID, 1) if cmdID == nil or cmdID ~= CMD.GUARD then return end @@ -393,15 +393,15 @@ function widget:UnitFromFactory(unitID, unitDefID, unitTeam, factID, factDefID, local bestTransportID = -1 local bestTransportTime = math.huge - local unitDefID_created = Spring.GetUnitDefID(createdUnitID) + local unitDefID_created = SpringShared.GetUnitDefID(createdUnitID) local createdSpeed = unitDefID_created and cachedUnitDefs[unitDefID_created] and cachedUnitDefs[unitDefID_created].speed or 0 for transportID, _ in pairs(factoryToGuardingTransports[factID]) do if transportState[transportID] == transport_states.idle and canTransport(transportID, createdUnitID) then - local unitLocation = { Spring.GetUnitPosition(unitID) } - local transportLocation = { Spring.GetUnitPosition(transportID) } + local unitLocation = { SpringShared.GetUnitPosition(unitID) } + local transportLocation = { SpringShared.GetUnitPosition(transportID) } - local tDefID = Spring.GetUnitDefID(transportID) + local tDefID = SpringShared.GetUnitDefID(transportID) local tSpeed = tDefID and cachedUnitDefs[tDefID] and cachedUnitDefs[tDefID].speed or 0 local pickupTime = timeToTarget(transportLocation, unitLocation, tSpeed) local transportTime = timeToTarget(unitLocation, destination, tSpeed) @@ -420,9 +420,9 @@ function widget:UnitFromFactory(unitID, unitDefID, unitTeam, factID, factDefID, if bestTransportID > -1 then transportState[bestTransportID] = transport_states.approaching - local unitWaitDestination = { Spring.GetUnitPosition(createdUnitID) } - Spring.GiveOrderToUnit(bestTransportID, CMD.MOVE, unitWaitDestination, CMD.OPT_RIGHT) - Spring.GiveOrderToUnit(bestTransportID, CMD.GUARD, factID, CMD.OPT_SHIFT) + local unitWaitDestination = { SpringShared.GetUnitPosition(createdUnitID) } + SpringSynced.GiveOrderToUnit(bestTransportID, CMD.MOVE, unitWaitDestination, CMD.OPT_RIGHT) + SpringSynced.GiveOrderToUnit(bestTransportID, CMD.GUARD, factID, CMD.OPT_SHIFT) activeTransportToUnit[bestTransportID] = createdUnitID unitToDestination[createdUnitID] = getValidRallyCommandDestination(createdUnitID) @@ -446,7 +446,7 @@ function widget:UnitCommandNotify(unitID, cmdID, cmdParams, cmdOpts) end function widget:CommandNotify(cmdID, cmdParams, cmdOpts) - local selectedUnits = Spring.GetSelectedUnits() + local selectedUnits = SpringUnsynced.GetSelectedUnits() for _, orderedUnit in ipairs(selectedUnits) do if isTransport(orderedUnit) then diff --git a/luaui/Widgets/cmd_holdfire_fix.lua b/luaui/Widgets/cmd_holdfire_fix.lua index d484d4e3e1c..2c3588055d1 100644 --- a/luaui/Widgets/cmd_holdfire_fix.lua +++ b/luaui/Widgets/cmd_holdfire_fix.lua @@ -14,14 +14,14 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID local CMD_FIRE_STATE = CMD.FIRE_STATE local CMD_INSERT = CMD.INSERT local CMD_STOP = CMD.STOP local CMD_UNIT_CANCEL_TARGET = GameCMD.UNIT_CANCEL_TARGET -local spGiveOrderToUnit = Spring.GiveOrderToUnit +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit local gameStarted local myTeam @@ -32,7 +32,7 @@ local function DropCurrentTarget(unitID) end function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -49,7 +49,7 @@ end function widget:Initialize() myTeam = spGetMyTeamID() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end end diff --git a/luaui/Widgets/cmd_limit_build_spacing.lua b/luaui/Widgets/cmd_limit_build_spacing.lua index 95efc1e05f7..c20538e505d 100644 --- a/luaui/Widgets/cmd_limit_build_spacing.lua +++ b/luaui/Widgets/cmd_limit_build_spacing.lua @@ -14,10 +14,10 @@ end local limit = 16 function widget:Update() - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if cmdID and cmdID < 0 then - if Spring.GetBuildSpacing() > limit then - Spring.SetBuildSpacing(limit) + if SpringUnsynced.GetBuildSpacing() > limit then + SpringUnsynced.SetBuildSpacing(limit) end end end diff --git a/luaui/Widgets/cmd_line-build_hotkey_ignore.lua b/luaui/Widgets/cmd_line-build_hotkey_ignore.lua index 4b6322a1b05..080efdba8b9 100644 --- a/luaui/Widgets/cmd_line-build_hotkey_ignore.lua +++ b/luaui/Widgets/cmd_line-build_hotkey_ignore.lua @@ -19,10 +19,10 @@ function widget:KeyPress(key, mods, isRepeat) if key ~= KEYSYMS["UP"] and key ~= KEYSYMS["DOWN"] and key ~= KEYSYMS["LEFT"] and key ~= KEYSYMS["RIGHT"] then -- Don't ignore arrow keys - local x, y, leftPressed, middlePressed, rightPressed, offscreen = Spring.GetMouseState() + local x, y, leftPressed, middlePressed, rightPressed, offscreen = SpringUnsynced.GetMouseState() if leftPressed then - local idx, cmd_id, cmd_type, cmd_name = Spring.GetActiveCommand() + local idx, cmd_id, cmd_type, cmd_name = SpringUnsynced.GetActiveCommand() if cmd_id and cmd_id < 0 then return true end diff --git a/luaui/Widgets/cmd_nanoturrets_assist_priority.lua b/luaui/Widgets/cmd_nanoturrets_assist_priority.lua index 9c396c294fb..b61cbf7d7ce 100644 --- a/luaui/Widgets/cmd_nanoturrets_assist_priority.lua +++ b/luaui/Widgets/cmd_nanoturrets_assist_priority.lua @@ -11,11 +11,11 @@ function widget:GetInfo() } end -local GetUnitPosition = Spring.GetUnitPosition -local GetUnitsInSphere = Spring.GetUnitsInSphere -local GetUnitCommands = Spring.GetUnitCommands -local GiveOrderToUnit = Spring.GiveOrderToUnit -local GetUnitDefID = Spring.GetUnitDefID +local GetUnitPosition = SpringShared.GetUnitPosition +local GetUnitsInSphere = SpringShared.GetUnitsInSphere +local GetUnitCommands = SpringShared.GetUnitCommands +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit +local GetUnitDefID = SpringShared.GetUnitDefID local UnitDefs = UnitDefs local CMD_REPAIR = CMD.REPAIR local CMD_FIGHT = CMD.FIGHT diff --git a/luaui/Widgets/cmd_no_duplicate_orders.lua b/luaui/Widgets/cmd_no_duplicate_orders.lua index d6e57d2136a..0535d2a9868 100644 --- a/luaui/Widgets/cmd_no_duplicate_orders.lua +++ b/luaui/Widgets/cmd_no_duplicate_orders.lua @@ -31,26 +31,26 @@ local mathCeil = math.ceil -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -local GetSelectedUnits = Spring.GetSelectedUnits -local GetUnitCommands = Spring.GetUnitCommands -local GetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local GetUnitPosition = Spring.GetUnitPosition -local GiveOrderToUnit = Spring.GiveOrderToUnit -local GetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt +local GetSelectedUnits = SpringUnsynced.GetSelectedUnits +local GetUnitCommands = SpringShared.GetUnitCommands +local GetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local GetUnitPosition = SpringShared.GetUnitPosition +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit +local GetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt local buildList = {} function widget:PlayerChanged(playerID) - if Spring.GetSpectatingState() then + if SpringUnsynced.GetSpectatingState() then widgetHandler:RemoveWidget() end end function widget:Initialize() - if Spring.IsReplay() or Spring.GetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or SpringShared.GetGameFrame() > 0 then widget:PlayerChanged() end - for _, unitID in ipairs(Spring.GetTeamUnits(Spring.GetMyTeamID())) do + for _, unitID in ipairs(SpringShared.GetTeamUnits(Spring.GetMyTeamID())) do if GetUnitIsBeingBuilt(unitID) then widget:UnitCreated(unitID) end diff --git a/luaui/Widgets/cmd_no_self_selection.lua b/luaui/Widgets/cmd_no_self_selection.lua index 9f8fba55c9f..c45ead8f70f 100644 --- a/luaui/Widgets/cmd_no_self_selection.lua +++ b/luaui/Widgets/cmd_no_self_selection.lua @@ -17,7 +17,7 @@ end -- Configuration --------------------------------------------------------------- ---@type number in seconds -local doubleClickTime = Spring.GetConfigInt("DoubleClickTime", 200) / 1000 +local doubleClickTime = SpringUnsynced.GetConfigInt("DoubleClickTime", 200) / 1000 ---@type integer in pixels, as the Manhattan norm local doubleClickDist = 12 ---@type table @@ -30,12 +30,12 @@ local allowSelfCommand = { local math_abs = math.abs -local sp_GetActiveCommand = Spring.GetActiveCommand -local sp_GetMouseState = Spring.GetMouseState -local sp_GetUnitDefID = Spring.GetUnitDefID -local sp_GetUnitSelectionVolumeData = Spring.GetUnitSelectionVolumeData -local sp_SetUnitSelectionVolumeData = Spring.SetUnitSelectionVolumeData -local sp_TraceScreenRay = Spring.TraceScreenRay +local sp_GetActiveCommand = SpringUnsynced.GetActiveCommand +local sp_GetMouseState = SpringUnsynced.GetMouseState +local sp_GetUnitDefID = SpringShared.GetUnitDefID +local sp_GetUnitSelectionVolumeData = SpringUnsynced.GetUnitSelectionVolumeData +local sp_SetUnitSelectionVolumeData = SpringUnsynced.SetUnitSelectionVolumeData +local sp_TraceScreenRay = SpringUnsynced.TraceScreenRay -------------------------------------------------------------------------------- -- Initialization -------------------------------------------------------------- @@ -259,14 +259,14 @@ end function widget:Initialize() WG.SpringTraceScreenRay = sp_TraceScreenRay - Spring.TraceScreenRay = traceScreenRay + SpringUnsynced.TraceScreenRay = traceScreenRay widgetHandler:RegisterGlobal("RemoveSelectionVolume", naiveRemoveSelectionVolume) widgetHandler:RegisterGlobal("RestoreSelectionVolume", naiveRestoreSelectionVolume) end function widget:Shutdown() naiveRestoreSelectionVolume() - Spring.TraceScreenRay = sp_TraceScreenRay + SpringUnsynced.TraceScreenRay = sp_TraceScreenRay widgetHandler:DeregisterGlobal("RemoveSelectionVolume") widgetHandler:DeregisterGlobal("RestoreSelectionVolume") end diff --git a/luaui/Widgets/cmd_onoff.lua b/luaui/Widgets/cmd_onoff.lua index cc87641c993..63a3b3a4a60 100644 --- a/luaui/Widgets/cmd_onoff.lua +++ b/luaui/Widgets/cmd_onoff.lua @@ -12,9 +12,9 @@ function widget:GetInfo() } end -local spGetSelectedUnitsSorted = Spring.GetSelectedUnitsSorted -local spGetUnitStates = Spring.GetUnitStates -local spGiveOrderToUnit = Spring.GiveOrderToUnit +local spGetSelectedUnitsSorted = SpringUnsynced.GetSelectedUnitsSorted +local spGetUnitStates = SpringShared.GetUnitStates +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit local unitOnOffable = {} for udid, ud in pairs(UnitDefs) do diff --git a/luaui/Widgets/cmd_persistent_build_spacing.lua b/luaui/Widgets/cmd_persistent_build_spacing.lua index 17b746b293c..624345f3ad7 100644 --- a/luaui/Widgets/cmd_persistent_build_spacing.lua +++ b/luaui/Widgets/cmd_persistent_build_spacing.lua @@ -18,9 +18,9 @@ local maxBuildSpacing = 16 -- you can still increase build spacing, it just will local lastCmdID = nil local buildSpacing = {} -local spGetActiveCommand = Spring.GetActiveCommand -local spGetBuildSpacing = Spring.GetBuildSpacing -local spSetBuildSpacing = Spring.SetBuildSpacing +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetBuildSpacing = SpringUnsynced.GetBuildSpacing +local spSetBuildSpacing = SpringUnsynced.SetBuildSpacing local unitNames = {} for udid, ud in pairs(UnitDefs) do diff --git a/luaui/Widgets/cmd_quick_build_extractor.lua b/luaui/Widgets/cmd_quick_build_extractor.lua index 3476e1edaf3..0eeac637faa 100644 --- a/luaui/Widgets/cmd_quick_build_extractor.lua +++ b/luaui/Widgets/cmd_quick_build_extractor.lua @@ -14,16 +14,16 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spTraceScreenRay = Spring.TraceScreenRay -local spGetMouseState = Spring.GetMouseState -local spSetMouseCursor = Spring.SetMouseCursor -local spGetModKeyState = Spring.GetModKeyState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetMouseState = SpringUnsynced.GetMouseState +local spSetMouseCursor = SpringUnsynced.SetMouseCursor +local spGetModKeyState = SpringUnsynced.GetModKeyState local CMD_RECLAIM = CMD.RECLAIM -local spGetActiveCommand = Spring.GetActiveCommand -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition local mathAbs = math.abs local mathHuge = math.huge @@ -68,7 +68,7 @@ for unitDefID, unitDef in pairs(UnitDefs) do isCloakableBuilder[unitDefID] = true end end -local spGetUnitStates = Spring.GetUnitStates +local spGetUnitStates = SpringShared.GetUnitStates local function unitIsCloaked(uDefId) return isCloakableBuilder[spGetUnitDefID(uDefId)] and select(5, spGetUnitStates(uDefId, false, true)) end @@ -109,7 +109,7 @@ local function clearGhostBuild() lastMx, lastMy = -1, -1 end -local selectedUnits = Spring.GetSelectedUnits() +local selectedUnits = SpringUnsynced.GetSelectedUnits() function widget:SelectionChanged(sel) selectedUnits = sel bestMex = spotBuilder.GetBestExtractorFromBuilders(selectedUnits, mexConstructors, mexBuildings) diff --git a/luaui/Widgets/cmd_resolution_switcher.lua b/luaui/Widgets/cmd_resolution_switcher.lua index b7171f6ff9e..eb73a5e3eff 100644 --- a/luaui/Widgets/cmd_resolution_switcher.lua +++ b/luaui/Widgets/cmd_resolution_switcher.lua @@ -27,7 +27,7 @@ local windowType = { -- Gets geometries for each screen and orders them by posX (left to right) local function refreshScreenGeometries(numDisplays) for displayIndex = 1, numDisplays do - local sx, sy, px, py = Spring.GetScreenGeometry(displayIndex - 1) + local sx, sy, px, py = SpringUnsynced.GetScreenGeometry(displayIndex - 1) screenGeometries[displayIndex] = { px, py, sx, sy, displayIndex } end @@ -43,7 +43,7 @@ local function getMaximalWindowGeometry(minI, maxI) local maxY = screenGeometries[minI][2] + screenGeometries[minI][4] local di = screenGeometries[minI][5] - for displayNum = 2, Spring.GetNumDisplays() do + for displayNum = 2, SpringUnsynced.GetNumDisplays() do local py = screenGeometries[displayNum][2] local sy = screenGeometries[displayNum][4] if py < minY then @@ -73,7 +73,7 @@ local function insertMaximalScreenMode(minI, maxI, modes) end local function insertMultiMonitorModes(modes) - local numDisplays = Spring.GetNumDisplays() + local numDisplays = SpringUnsynced.GetNumDisplays() if numDisplays <= 1 then return @@ -106,7 +106,7 @@ local function refreshScreenModes() -- Only capture the first occurence of the display index, it will contain maximum supported resolution if display ~= videoMode.display then display = videoMode.display - local w, h, x, y = Spring.GetScreenGeometry(display - 1) + local w, h, x, y = SpringUnsynced.GetScreenGeometry(display - 1) displays[display] = { name = videoMode.displayName, width = w, --videoMode.w, @@ -153,7 +153,7 @@ local function refreshScreenModes() end end - local numDisplays = Spring.GetNumDisplays() + local numDisplays = SpringUnsynced.GetNumDisplays() if numDisplays > 1 then refreshScreenGeometries(numDisplays) @@ -164,8 +164,8 @@ local function refreshScreenModes() for display = 1, numDisplays do for display2 = 1, numDisplays do if display ~= display2 then - local w, h, x, y = Spring.GetScreenGeometry(display - 1) - local w2, h2, x2, y2 = Spring.GetScreenGeometry(display2 - 1) + local w, h, x, y = SpringUnsynced.GetScreenGeometry(display - 1) + local w2, h2, x2, y2 = SpringUnsynced.GetScreenGeometry(display2 - 1) if w > 0 and w2 > 0 then if x + w == x2 or x2 + w2 == x or x2 - w == x or x - w2 == x2 then -- make sure they are next to eachother if not addedDisplayCombo[display] or addedDisplayCombo[display] ~= display2 then @@ -227,24 +227,24 @@ local function changeScreenMode(index) local screenMode = screenModes[index] if screenMode.type == windowType.fullscreen then - Spring.SetWindowGeometry(screenMode.display, 0, 0, screenMode.width, screenMode.height, true, false) + SpringUnsynced.SetWindowGeometry(screenMode.display, 0, 0, screenMode.width, screenMode.height, true, false) elseif screenMode.type == windowType.borderless then - Spring.SetWindowGeometry(screenMode.display, screenMode.x or 0, screenMode.y or 0, screenMode.width, screenMode.height, true, true) + SpringUnsynced.SetWindowGeometry(screenMode.display, screenMode.x or 0, screenMode.y or 0, screenMode.width, screenMode.height, true, true) elseif screenMode.type == windowType.multimonitor then - Spring.SetWindowGeometry(screenMode.actualDisplay, screenMode.x or 0, screenMode.y or 0, screenMode.width, screenMode.height, false, true) + SpringUnsynced.SetWindowGeometry(screenMode.actualDisplay, screenMode.x or 0, screenMode.y or 0, screenMode.width, screenMode.height, false, true) elseif screenMode.type == windowType.windowed then -- Windowed mode has a raptor-and-egg problem, where window borders can't be known until after switching to windowed mode -- This cannot be done in two consecutive SetWindowGeometry() calls, as there must be a two draw frame delay -- (one to write, one to read), before the values of GetWindowGeometry() are updated - local _, _, _, _, borderTop, borderLeft, borderBottom, borderRight = Spring.GetWindowGeometry() + local _, _, _, _, borderTop, borderLeft, borderBottom, borderRight = SpringUnsynced.GetWindowGeometry() local width = screenMode.width - borderLeft - borderRight local height = screenMode.height - borderTop - borderBottom - Spring.SetWindowGeometry(screenMode.display, borderLeft, borderTop, width, height, false, false) + SpringUnsynced.SetWindowGeometry(screenMode.display, borderLeft, borderTop, width, height, false, false) if firstPassDrawFrame then firstPassDrawFrame = nil else - firstPassDrawFrame = Spring.GetDrawFrame() + firstPassDrawFrame = SpringUnsynced.GetDrawFrame() end end end @@ -253,7 +253,7 @@ function widget:Update() if firstPassDrawFrame == nil then return end - if Spring.GetDrawFrame() - firstPassDrawFrame <= 2 then + if SpringUnsynced.GetDrawFrame() - firstPassDrawFrame <= 2 then return end -- 2 draw frame delay for engine to update window borders changeScreenMode(screenModeIndex) diff --git a/luaui/Widgets/cmd_share_unit.lua b/luaui/Widgets/cmd_share_unit.lua index 3abe12972f3..d5dd3e43e41 100644 --- a/luaui/Widgets/cmd_share_unit.lua +++ b/luaui/Widgets/cmd_share_unit.lua @@ -28,25 +28,25 @@ local range = 200 -------------------------------------------------------------------------------- --speedups -------------------------------------------------------------------------------- -local GetUnitsInCylinder = Spring.GetUnitsInCylinder +local GetUnitsInCylinder = SpringShared.GetUnitsInCylinder local GetMyTeamID = Spring.GetMyTeamID -local GetUnitTeam = Spring.GetUnitTeam -local GetSelectedUnits = Spring.GetSelectedUnits -local GetTeamAllyTeamID = Spring.GetTeamAllyTeamID -local ShareResources = Spring.ShareResources +local GetUnitTeam = SpringShared.GetUnitTeam +local GetSelectedUnits = SpringUnsynced.GetSelectedUnits +local GetTeamAllyTeamID = SpringShared.GetTeamAllyTeamID +local ShareResources = SpringUnsynced.ShareResources local I18N = Spring.I18N -local GetSpectatingState = Spring.GetSpectatingState -local WorldToScreenCoords = Spring.WorldToScreenCoords -local PlaySoundFile = Spring.PlaySoundFile -local GetTeamColor = Spring.GetTeamColor -local GetActiveCommand = Spring.GetActiveCommand -local GetCameraPosition = Spring.GetCameraPosition -local GetMouseState = Spring.GetMouseState -local TraceScreenRay = Spring.TraceScreenRay -local GetPlayerList = Spring.GetPlayerList -local GetPlayerInfo = Spring.GetPlayerInfo -local GetGameRulesParam = Spring.GetGameRulesParam -local GetViewGeometry = Spring.GetViewGeometry +local GetSpectatingState = SpringUnsynced.GetSpectatingState +local WorldToScreenCoords = SpringUnsynced.WorldToScreenCoords +local PlaySoundFile = SpringUnsynced.PlaySoundFile +local GetTeamColor = SpringUnsynced.GetTeamColor +local GetActiveCommand = SpringUnsynced.GetActiveCommand +local GetCameraPosition = SpringUnsynced.GetCameraPosition +local GetMouseState = SpringUnsynced.GetMouseState +local TraceScreenRay = SpringUnsynced.TraceScreenRay +local GetPlayerList = SpringShared.GetPlayerList +local GetPlayerInfo = SpringShared.GetPlayerInfo +local GetGameRulesParam = SpringShared.GetGameRulesParam +local GetViewGeometry = SpringUnsynced.GetViewGeometry local glBeginEnd = gl.BeginEnd local glCallList = gl.CallList @@ -201,7 +201,7 @@ local function colourNames(teamId) if tonumber(teamId) < 0 then return "" end - local nameColourR, nameColourG, nameColourB, nameColourA = Spring.GetTeamColor(teamId) + local nameColourR, nameColourG, nameColourB, nameColourA = SpringUnsynced.GetTeamColor(teamId) return Spring.Utilities.Color.ToString(nameColourR, nameColourG, nameColourB) end diff --git a/luaui/Widgets/cmd_state_remove.lua b/luaui/Widgets/cmd_state_remove.lua index a741b698663..4650150610a 100644 --- a/luaui/Widgets/cmd_state_remove.lua +++ b/luaui/Widgets/cmd_state_remove.lua @@ -12,9 +12,9 @@ function widget:GetInfo() } end -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitDefID = Spring.GetUnitDefID +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitDefID = SpringShared.GetUnitDefID local CMD_FIRE_STATE = CMD.FIRE_STATE local CMD_MOVE_STATE = CMD.MOVE_STATE diff --git a/luaui/Widgets/cmd_state_reverse_toggle.lua b/luaui/Widgets/cmd_state_reverse_toggle.lua index 330c6ef476c..918724986c2 100644 --- a/luaui/Widgets/cmd_state_reverse_toggle.lua +++ b/luaui/Widgets/cmd_state_reverse_toggle.lua @@ -12,10 +12,10 @@ function widget:GetInfo() } end -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetActiveCmdDesc = Spring.GetActiveCmdDesc -local spGetCmdDescIndex = Spring.GetCmdDescIndex +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetActiveCmdDesc = SpringUnsynced.GetActiveCmdDesc +local spGetCmdDescIndex = SpringUnsynced.GetCmdDescIndex function widget:CommandNotify(id, params, options) diff --git a/luaui/Widgets/cmd_stop_selfd.lua b/luaui/Widgets/cmd_stop_selfd.lua index 75f58691e80..bababa10b23 100644 --- a/luaui/Widgets/cmd_stop_selfd.lua +++ b/luaui/Widgets/cmd_stop_selfd.lua @@ -33,7 +33,7 @@ function widget:UnitCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOpti return end - if Spring.GetUnitSelfDTime(unitID) > 0 then - Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) + if SpringShared.GetUnitSelfDTime(unitID) > 0 then + SpringSynced.GiveOrderToUnit(unitID, CMD.SELFD, {}, 0) end end diff --git a/luaui/Widgets/cmd_take_proxy.lua b/luaui/Widgets/cmd_take_proxy.lua index 0fadaaa7d11..64496614079 100644 --- a/luaui/Widgets/cmd_take_proxy.lua +++ b/luaui/Widgets/cmd_take_proxy.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end local function TakeTeam() - Spring.SendCommands({ "luarules take2" }) + SpringUnsynced.SendCommands({ "luarules take2" }) end function widget:Initialize() diff --git a/luaui/Widgets/cmd_toggle_key.lua b/luaui/Widgets/cmd_toggle_key.lua index b1f5ed47208..cbeb433125a 100644 --- a/luaui/Widgets/cmd_toggle_key.lua +++ b/luaui/Widgets/cmd_toggle_key.lua @@ -14,7 +14,7 @@ end -- cmd, optLine, optWords, data, isRepeat, release, actions function ToggleCMD(_, optLine) - Spring.SetActiveCommand(optLine) + SpringUnsynced.SetActiveCommand(optLine) end function widget:Initialize() diff --git a/luaui/Widgets/cmd_transport_preserve_commands.lua b/luaui/Widgets/cmd_transport_preserve_commands.lua index 81650236fb6..7dcd1b9d1a9 100644 --- a/luaui/Widgets/cmd_transport_preserve_commands.lua +++ b/luaui/Widgets/cmd_transport_preserve_commands.lua @@ -18,7 +18,7 @@ local distToIgnore = 500 -- any initial commands outside of this distance from t --------------------------------------------------------------- function widget:UnitLoaded(unitID) - orders[unitID] = Spring.GetUnitCommands(unitID, -1) + orders[unitID] = SpringShared.GetUnitCommands(unitID, -1) end function widget:UnitUnloaded(unitID) @@ -29,7 +29,7 @@ function widget:UnitUnloaded(unitID) if #command.params >= 3 then local dist = math.huge if i == 1 then -- ditch first command if it's not near the starting point - local x, y, z = Spring.GetUnitPosition(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) dist = math.distance3d(x, y, z, command.params[1], command.params[2], command.params[3]) else dist = 0 @@ -41,7 +41,7 @@ function widget:UnitUnloaded(unitID) end end - Spring.GiveOrderArrayToUnit(unitID, newOrders) + SpringSynced.GiveOrderArrayToUnit(unitID, newOrders) orders[unitID] = nil end @@ -52,7 +52,7 @@ end --------------------------------------------------------------- local function maybeRemoveSelf() - if Spring.IsReplay() or Spring.GetSpectatingState() and (Spring.GetGameFrame() > 0) then + if SpringUnsynced.IsReplay() or SpringUnsynced.GetSpectatingState() and (SpringShared.GetGameFrame() > 0) then widgetHandler:RemoveWidget() end end diff --git a/luaui/Widgets/cmd_uikeys_loader.lua b/luaui/Widgets/cmd_uikeys_loader.lua index 6f85cfdf5ef..ef8382daf4e 100644 --- a/luaui/Widgets/cmd_uikeys_loader.lua +++ b/luaui/Widgets/cmd_uikeys_loader.lua @@ -24,9 +24,9 @@ function widget:Initialize() numLines = numLines + 1 end for ct, line in pairs(lines) do - Spring.SendCommands(line) + SpringUnsynced.SendCommands(line) end if numLines > 0 then - Spring.Echo("Succesfully loaded LuaUI/Widgets/uikeys.txt") + SpringShared.Echo("Succesfully loaded LuaUI/Widgets/uikeys.txt") end end diff --git a/luaui/Widgets/cmd_unit_mover.lua b/luaui/Widgets/cmd_unit_mover.lua index c3cb0e4ebdd..a5f25060d3d 100644 --- a/luaui/Widgets/cmd_unit_mover.lua +++ b/luaui/Widgets/cmd_unit_mover.lua @@ -26,13 +26,13 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame -local GiveOrderToUnit = Spring.GiveOrderToUnit -local GetUnitPosition = Spring.GetUnitPosition -local GetUnitDirection = Spring.GetUnitDirection +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit +local GetUnitPosition = SpringShared.GetUnitPosition +local GetUnitDirection = SpringShared.GetUnitDirection local GetMyTeamID = Spring.GetMyTeamID -local GetUnitDefID = Spring.GetUnitDefID +local GetUnitDefID = SpringShared.GetUnitDefID local CMD_MOVE = CMD.MOVE @@ -45,7 +45,7 @@ local moveUnitsDefs = {} local gameStarted function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -60,7 +60,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end for unitDefID, unitDef in pairs(UnitDefs) do @@ -75,7 +75,7 @@ function widget:Initialize() end end - local units = Spring.GetTeamUnits(myTeamID) + local units = SpringShared.GetTeamUnits(myTeamID) for i = 1, #units do local unitID = units[i] widget:UnitCreated(unitID, GetUnitDefID(unitID), myTeamID) diff --git a/luaui/Widgets/cmd_unitgroup_clear_selection_on_empty.lua b/luaui/Widgets/cmd_unitgroup_clear_selection_on_empty.lua index df93bb5393a..3b8f99fbb92 100644 --- a/luaui/Widgets/cmd_unitgroup_clear_selection_on_empty.lua +++ b/luaui/Widgets/cmd_unitgroup_clear_selection_on_empty.lua @@ -12,9 +12,9 @@ function widget:GetInfo() } end -local spGetGroupUnitsCount = Spring.GetGroupUnitsCount -local spSelectUnitMap = Spring.SelectUnitMap -local spGetModKeyState = Spring.GetModKeyState +local spGetGroupUnitsCount = SpringUnsynced.GetGroupUnitsCount +local spSelectUnitMap = SpringUnsynced.SelectUnitMap +local spGetModKeyState = SpringUnsynced.GetModKeyState local function ClearSelectionIfGroupSelected(groupIndex) if spGetGroupUnitsCount(groupIndex) > 0 then diff --git a/luaui/Widgets/dbg_ceg_auto_reloader.lua b/luaui/Widgets/dbg_ceg_auto_reloader.lua index 5089ee20e95..3c539b67e9f 100644 --- a/luaui/Widgets/dbg_ceg_auto_reloader.lua +++ b/luaui/Widgets/dbg_ceg_auto_reloader.lua @@ -20,8 +20,8 @@ end local tableInsert = table.insert -- Localized Spring API for performance -local spGetMouseState = Spring.GetMouseState -local spEcho = Spring.Echo +local spGetMouseState = SpringUnsynced.GetMouseState +local spEcho = SpringShared.Echo local mouseOffscreen = select(6, spGetMouseState()) @@ -978,7 +978,7 @@ local function ScanChanges() if allok then for cegDefname, cegDefFile in pairs(needsReload) do spEcho("Reloading: " .. cegDefname) - Spring.SendCommands("reloadcegs") + SpringUnsynced.SendCommands("reloadcegs") end end end @@ -1000,12 +1000,12 @@ function widget:Initialize() LoadAllCegs() end -local lastUpdate = Spring.GetTimer() +local lastUpdate = SpringUnsynced.GetTimer() function widget:Update() - if Spring.DiffTimers(Spring.GetTimer(), lastUpdate) < 1 then + if SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), lastUpdate) < 1 then return end - lastUpdate = Spring.GetTimer() + lastUpdate = SpringUnsynced.GetTimer() local prevMouseOffscreen = mouseOffscreen mouseOffscreen = select(6, spGetMouseState()) @@ -1015,6 +1015,6 @@ function widget:Update() --end if spamCeg then - Spring.SendCommands("luarules spawnceg " .. spamCeg .. " 0") + SpringUnsynced.SendCommands("luarules spawnceg " .. spamCeg .. " 0") end end diff --git a/luaui/Widgets/dbg_deferred_buffer_visualizer.lua b/luaui/Widgets/dbg_deferred_buffer_visualizer.lua index 86ae0f378bf..48c06184440 100644 --- a/luaui/Widgets/dbg_deferred_buffer_visualizer.lua +++ b/luaui/Widgets/dbg_deferred_buffer_visualizer.lua @@ -13,8 +13,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local myshader = nil local myshaderDebgDrawLoc = nil @@ -197,7 +197,7 @@ function widget:Initialize() RemoveMe("[deferred buffer visualizer] removing widget, no shader support") return end - hasdeferredrendering = (Spring.GetConfigString("AllowDeferredModelRendering") == "1") and (Spring.GetConfigString("AllowDeferredMapRendering") == "1") + hasdeferredrendering = (SpringUnsynced.GetConfigString("AllowDeferredModelRendering") == "1") and (SpringUnsynced.GetConfigString("AllowDeferredMapRendering") == "1") if hasdeferredrendering == false then RemoveMe("[deferred buffer visualizer] removing widget, AllowDeferred Model and Map Rendering is required") end diff --git a/luaui/Widgets/dbg_engine_shader_reload.lua b/luaui/Widgets/dbg_engine_shader_reload.lua index 4bcbe5de6e7..208a5c551a8 100644 --- a/luaui/Widgets/dbg_engine_shader_reload.lua +++ b/luaui/Widgets/dbg_engine_shader_reload.lua @@ -25,12 +25,12 @@ function widget:Initialize() end end -local lastUpdate = Spring.GetTimer() +local lastUpdate = SpringUnsynced.GetTimer() function widget:Update() - if Spring.DiffTimers(Spring.GetTimer(), lastUpdate) < interval then + if SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), lastUpdate) < interval then return end - lastUpdate = Spring.GetTimer() + lastUpdate = SpringUnsynced.GetTimer() local changed = false for fileName, oldContents in pairs(shaderContents) do local newContents = VFS.LoadFile(fileName) @@ -38,10 +38,10 @@ function widget:Update() interval = 1 changed = true shaderContents[fileName] = newContents - Spring.Echo("Reloading shader: " .. fileName) + SpringShared.Echo("Reloading shader: " .. fileName) end end if changed then - Spring.SendCommands("reloadshaders") + SpringUnsynced.SendCommands("reloadshaders") end end diff --git a/luaui/Widgets/dbg_ffa_startpoints_picker.lua b/luaui/Widgets/dbg_ffa_startpoints_picker.lua index 8ad14442be1..0a9dac2116f 100644 --- a/luaui/Widgets/dbg_ffa_startpoints_picker.lua +++ b/luaui/Widgets/dbg_ffa_startpoints_picker.lua @@ -30,10 +30,10 @@ local tableInsert = table.insert local tableRemove = table.remove -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spGetSelectedUnits = Spring.GetSelectedUnits +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits local spGetMyTeamID = Spring.GetMyTeamID -local spGetTeamUnits = Spring.GetTeamUnits +local spGetTeamUnits = SpringShared.GetTeamUnits -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -44,7 +44,7 @@ local startPointUnitName = "armcom" -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -local spGetUnitPosition = Spring.GetUnitPosition +local spGetUnitPosition = SpringShared.GetUnitPosition ---Potential map start point, materialized by a unit. ---@class StartPoint @@ -333,7 +333,7 @@ return { -- before we interact with byAllyTeamCount and layouts return coroutine.create(function() for _, startPoint in ipairs(self.startPoints) do - Spring.SendCommands(string.format("give %s @%s,%s,%s", startPointUnitName, startPoint.x, 0, startPoint.z)) + SpringUnsynced.SendCommands(string.format("give %s @%s,%s,%s", startPointUnitName, startPoint.x, 0, startPoint.z)) coroutine.yield() end for _, layouts in pairsByKeys(self.byAllyTeamCount) do @@ -419,7 +419,7 @@ local function tryLoadWIPConfig(currentMapName) local availableWIPConfigs = VFS.DirList(WIPConfigsDir, string.format("%s%s*.lua", WIPConfigFilePrefix, currentMapName)) if #availableWIPConfigs > 0 then local lastWIPConfig = availableWIPConfigs[#availableWIPConfigs] - Spring.Log(widget:GetInfo().name, LOG.INFO, string.format("found WIP config file %s previously written by editor for current map %s", lastWIPConfig, currentMapName)) + SpringShared.Log(widget:GetInfo().name, LOG.INFO, string.format("found WIP config file %s previously written by editor for current map %s", lastWIPConfig, currentMapName)) return VFS.Include(lastWIPConfig) end return nil @@ -433,7 +433,7 @@ local function tryLoadConfigFromBAR(currentMapName) for _, configFile in pairs(availableConfigFiles) do local basename = configFile:gsub(configsDirectory, ""):gsub(".lua", ""):gsub("_", " "):lower() if string.find(sanitizedCurrentMapName, basename) then - Spring.Log(widget:GetInfo().name, LOG.INFO, string.format("found config %s provided by BAR for current map %s", configFile, currentMapName)) + SpringShared.Log(widget:GetInfo().name, LOG.INFO, string.format("found config %s provided by BAR for current map %s", configFile, currentMapName)) return VFS.Include(configFile) end end @@ -452,8 +452,8 @@ local function doLoad(config) coroutine.resume(configLoadCoroutine) -- clean up whatever was on the map before loading - Spring.SelectUnitArray(existingUnits) - Spring.SendCommands("remove") + SpringUnsynced.SelectUnitArray(existingUnits) + SpringUnsynced.SendCommands("remove") end -------------------------------------------------------------------------------- @@ -468,11 +468,11 @@ local availableFilters = { local currentFilter = 1 local function giveStartPoint() - Spring.SendCommands("give " .. startPointUnitName) + SpringUnsynced.SendCommands("give " .. startPointUnitName) end local function removeSelectedStartPoints() - Spring.SendCommands("remove") + SpringUnsynced.SendCommands("remove") end local function addLayout() @@ -481,10 +481,10 @@ local function addLayout() if #selectedUnits >= 3 then local layout = Layout:new(selectedUnits) if not byAllyTeamCount:addLayout(layout) then - Spring.Log(widget:GetInfo().name, LOG.INFO, "layout was already registered") + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "layout was already registered") end else - Spring.Log(widget:GetInfo().name, LOG.ERROR, "must select at least 3 start points to add a layout") + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "must select at least 3 start points to add a layout") end end @@ -493,7 +493,7 @@ local function removeLayout() if #selectedUnits >= 3 then local layout = Layout:new(selectedUnits) if not byAllyTeamCount:removeLayout(layout) then - Spring.Log(widget:GetInfo().name, LOG.INFO, "this layout is not registered") + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "this layout is not registered") end end end @@ -519,15 +519,15 @@ local function copyToClipboard() byAllyTeamCount = configFile.byAllyTeamCount, } local output = configFile:serialize() - Spring.SetClipboard(output) - Spring.Log(widget:GetInfo().name, LOG.INFO, "copied to clipboard and stored ephemeral config") + SpringUnsynced.SetClipboard(output) + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "copied to clipboard and stored ephemeral config") end local function resetLastCopy() if WG[ephemeralConfig] then doLoad(WG[ephemeralConfig]) else - Spring.Log(widget:GetInfo().name, LOG.INFO, "no ephemeral config found to reset") + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "no ephemeral config found to reset") end end @@ -546,9 +546,9 @@ local function saveWIPConfig() if f then f:write(output) f:close() - Spring.Log(widget:GetInfo().name, LOG.INFO, string.format("saved to WIP config file %s", filepath)) + SpringShared.Log(widget:GetInfo().name, LOG.INFO, string.format("saved to WIP config file %s", filepath)) elseif err then - Spring.Log(widget:GetInfo().name, LOG.ERROR, err) + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, err) end end @@ -558,7 +558,7 @@ local function loadWIPOrBARConfig() if config then doLoad(config) else - Spring.Log(widget:GetInfo().name, LOG.INFO, "no config found in WIP configs nor BAR configs for this map") + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "no config found in WIP configs nor BAR configs for this map") end end @@ -579,8 +579,8 @@ local actions = { local function registerKeybinds(widget) for name, action in pairs(actions) do widgetHandler.actionHandler:AddAction(widget, name, action.handler, nil, "p") - Spring.SendCommands(string.format("unbindkeyset %s", action.keybind)) - Spring.SendCommands(string.format("bind %s %s", action.keybind, name)) + SpringUnsynced.SendCommands(string.format("unbindkeyset %s", action.keybind)) + SpringUnsynced.SendCommands(string.format("bind %s %s", action.keybind, name)) end end @@ -588,7 +588,7 @@ local function unregisterKeybinds(widget) for name, _ in pairs(actions) do widgetHandler.actionHandler:RemoveAction(widget, name) end - Spring.SendCommands("keyreload") + SpringUnsynced.SendCommands("keyreload") end -------------------------------------------------------------------------------- @@ -615,13 +615,13 @@ local outlineSizeDefault = 7 local outlineSize local outlineColor = { 0, 0, 0, 1 } local outlineStrength = 10 -local fontfile = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") +local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") local font = nil local DrawElement -local GetViewGeometry = Spring.GetViewGeometry -local IsGUIHidden = Spring.IsGUIHidden -local WorldToScreenCoords = Spring.WorldToScreenCoords +local GetViewGeometry = SpringUnsynced.GetViewGeometry +local IsGUIHidden = SpringUnsynced.IsGUIHidden +local WorldToScreenCoords = SpringUnsynced.WorldToScreenCoords local glCreateList = gl.CreateList local glCallList = gl.CallList local glDeleteList = gl.DeleteList @@ -800,20 +800,20 @@ end local function isSoloDevMode() -- compute if we are in a solo game (nothing but the player, not even AIs) - local gaiaAllyTeamID = select(6, Spring.GetTeamInfo(Spring.GetGaiaTeamID(), false)) - local allyTeamList = Spring.GetAllyTeamList() + local gaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(SpringShared.GetGaiaTeamID(), false)) + local allyTeamList = SpringShared.GetAllyTeamList() local allyTeamCount = 0 for _, allyTeam in ipairs(allyTeamList) do if allyTeam ~= gaiaAllyTeamID then allyTeamCount = allyTeamCount + 1 end end - local teamList = Spring.GetTeamList(Spring.GetMyAllyTeamID()) + local teamList = SpringShared.GetTeamList(Spring.GetMyAllyTeamID()) local teamCount = table.count(teamList) local isSolo = allyTeamCount == 1 and teamCount == 1 -- we only run in solo games with dev mode enabled, and not in replays - if not isSolo or not Spring.Utilities.IsDevMode() or Spring.IsReplay() then + if not isSolo or not Spring.Utilities.IsDevMode() or SpringUnsynced.IsReplay() then return false end return true @@ -837,11 +837,11 @@ function widget:Initialize() return end - Spring.SetLogSectionFilterLevel(widget:GetInfo().name, LOG.INFO) + SpringUnsynced.SetLogSectionFilterLevel(widget:GetInfo().name, LOG.INFO) -- we register the `GameFrame` callin to defer the rest of initialization at a -- later time. This is a kludge to make sure that we run very late, after the -- `autocheat` widget has had a chance to enable cheating - initialFrame = Spring.GetGameFrame() + initialFrame = SpringShared.GetGameFrame() widgetHandler:UpdateWidgetCallIn("GameFrame", self) end @@ -849,8 +849,8 @@ function widget:GameFrame(f) if f > initialFrame + 10 then widgetHandler:RemoveWidgetCallIn("GameFrame", self) - if not Spring.IsCheatingEnabled() then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "this widget needs cheating enabled") + if not SpringShared.IsCheatingEnabled() then + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "this widget needs cheating enabled") widgetHandler:RemoveWidget(self) return end diff --git a/luaui/Widgets/dbg_frame_grapher.lua b/luaui/Widgets/dbg_frame_grapher.lua index 58c72498a30..4b2e7c003b5 100644 --- a/luaui/Widgets/dbg_frame_grapher.lua +++ b/luaui/Widgets/dbg_frame_grapher.lua @@ -23,12 +23,12 @@ local mathAbs = math.abs local mathMin = math.min -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo ---------------------------Speedups----------------------------- -local spGetTimer = Spring.GetTimer -local spDiffTimers = Spring.DiffTimers +local spGetTimer = SpringUnsynced.GetTimer +local spDiffTimers = SpringUnsynced.DiffTimers ---------------------------Internal vars--------------------------- local timerstart = nil ----------------------------GL4 vars---------------------------- @@ -153,8 +153,8 @@ function widget:Initialize() spEcho("Failed to compile shaders for: frame grapher v2") widgetHandler:RemoveWidget(self) end - timerstart = Spring.GetTimerMicros() - timerold = Spring.GetTimerMicros() + timerstart = SpringUnsynced.GetTimerMicros() + timerold = SpringUnsynced.GetTimerMicros() end function widget:Shutdown() @@ -173,7 +173,7 @@ local eventBuffer = {} -- Even types are : "sim","update", "draw", "swap", params are start, duration, type local lastCallin = "DrawGenesis" -local lastTime = Spring.GetTimerMicros() +local lastTime = SpringUnsynced.GetTimerMicros() local frametypeidx = { sim = 1, -- @@ -223,7 +223,7 @@ local nowToPrevToFrameType = { } local function nowEvent(e) local frameType = nowToPrevToFrameType[e][lastCallin] - local nowTime = Spring.GetTimerMicros() + local nowTime = SpringUnsynced.GetTimerMicros() if frameType ~= "error" then local lastframetime = spDiffTimers(nowTime, timerstart, nil, true) * 1000 -- in MILLISECONDS local lastframeduration = spDiffTimers(nowTime, lastTime, nil, true) * 1000 -- in MILLISECONDS @@ -322,7 +322,7 @@ function widget:DrawScreen() rectShader:Activate() -- We should be setting individual uniforms AFTER activate - local shadertime = spDiffTimers(Spring.GetTimerMicros(), timerstart, nil, true) * 1000 -- in MILLISECONDS + local shadertime = spDiffTimers(SpringUnsynced.GetTimerMicros(), timerstart, nil, true) * 1000 -- in MILLISECONDS rectShader:SetUniform("shaderparams", shadertime, 0, 0, 0) drawInstanceVBO(rectInstanceTable) rectShader:Deactivate() diff --git a/luaui/Widgets/dbg_jitter_timer.lua b/luaui/Widgets/dbg_jitter_timer.lua index 073b956185e..c1a0b7228be 100644 --- a/luaui/Widgets/dbg_jitter_timer.lua +++ b/luaui/Widgets/dbg_jitter_timer.lua @@ -18,16 +18,16 @@ local mathAbs = math.abs local mathMax = math.max -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spGetCameraPosition = Spring.GetCameraPosition -local spEcho = Spring.Echo +local spGetGameFrame = SpringShared.GetGameFrame +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spEcho = SpringShared.Echo --------------------------- INFO ------------------------------- -- You can also add an exponential component to the load in ms with a second number param to the /****frameload commands ---------------------------Speedups----------------------------- -local spGetTimer = Spring.GetTimer -local spDiffTimers = Spring.DiffTimers +local spGetTimer = SpringUnsynced.GetTimer +local spDiffTimers = SpringUnsynced.DiffTimers ---------------------------Internal vars--------------------------- local viewSizeX, viewSizeY = 0, 0 @@ -42,9 +42,9 @@ local cammovespread = 0 local camalpha = 0.03 function widget:Initialize() - drawtimer = Spring.GetTimer() - timerstart = Spring.GetTimer() - timerold = Spring.GetTimer() + drawtimer = SpringUnsynced.GetTimer() + timerstart = SpringUnsynced.GetTimer() + timerold = SpringUnsynced.GetTimer() viewSizeX, viewSizeY = gl.GetViewSizes() --simtime = spGetGameFrame()/30 camX, camY, camZ = spGetCameraPosition() @@ -62,11 +62,11 @@ local function Loadms(millisecs, spread) millisecs = millisecs + math.min(10 * spread, -1.0 * spread * math.log(1.0 - math.random())) end --spEcho(millisecs) - local starttimer = Spring.GetTimer() + local starttimer = SpringUnsynced.GetTimer() local nowtimer for i = 1, 10000000 do - nowtimer = Spring.GetTimer() - if Spring.DiffTimers(nowtimer, starttimer) * 1000 >= millisecs then + nowtimer = SpringUnsynced.GetTimer() + if SpringUnsynced.DiffTimers(nowtimer, starttimer) * 1000 >= millisecs then break end end @@ -144,8 +144,8 @@ function widget:DrawScreen() local camerarelativejitter = cammovespread / mathMax(cammovemean, 0.001) drawspergameframe = drawspergameframe + 1 - local drawpersimframe = math.floor(Spring.GetFPS() / 30.0 + 0.5) - local fto = Spring.GetFrameTimeOffset() + local drawpersimframe = math.floor(SpringUnsynced.GetFPS() / 30.0 + 0.5) + local fto = SpringUnsynced.GetFrameTimeOffset() local timernew = spGetTimer() drawtimesmooth = spDiffTimers(timernew, drawtimer) + correctionfactor @@ -184,7 +184,7 @@ function widget:DrawScreen() text = text .. string.format("mean jitter = %.3f \n", avgjitter * 30) text = text .. string.format("averageCTO = %.3f, spreadCTO = %.3f \n", averageCTO, spreadCTO) text = text .. string.format("CamJitter = %.3f \n", camerarelativejitter) - text = text .. string.format("DrawFrame = %d \n", Spring.GetDrawFrame()) + text = text .. string.format("DrawFrame = %d \n", SpringUnsynced.GetDrawFrame()) gl.Text(text, viewSizeX - timerwidth, viewSizeY - timerYoffset + 48, 16, "d") --gl.Text(string.format("DrawFrame FTODelta = %.3f FTO = %.3f", currCTOdelta, fto), viewSizeX - timerwidth, viewSizeY - timerYoffset, 16, "d") @@ -201,7 +201,7 @@ function widget:DrawScreen() gl.PopMatrix() -- Frame Drop Indicator!! - local df = Spring.GetDrawFrame() + local df = SpringUnsynced.GetDrawFrame() local offset = 32 * (df % 8) gl.Rect(viewSizeX - timerwidth + offset, viewSizeY - timerYoffset + timerheight - 116, viewSizeX - timerwidth + 32 + offset, viewSizeY - timerYoffset + timerheight - 116 - 32) if drawframeload > 0 then diff --git a/luaui/Widgets/dbg_mouse_to_mex_portable.lua b/luaui/Widgets/dbg_mouse_to_mex_portable.lua index 592c2595c1f..7be6eb24893 100644 --- a/luaui/Widgets/dbg_mouse_to_mex_portable.lua +++ b/luaui/Widgets/dbg_mouse_to_mex_portable.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo include("keysym.h.lua") @@ -46,14 +46,14 @@ local function legalPos(pos) end function widget:MousePress(mx, my, button) - if enabled and (not Spring.IsAboveMiniMap(mx, my)) then - local _, pos = Spring.TraceScreenRay(mx, my, true) + if enabled and (not SpringUnsynced.IsAboveMiniMap(mx, my)) then + local _, pos = SpringUnsynced.TraceScreenRay(mx, my, true) if legalPos(pos) then --if true then handle:write("[" .. mexIndex .. "] = {x = " .. floor(pos[1] + 0.5) .. ", z = " .. floor(pos[3] + 0.5) .. ", metal = " .. tostring(metal) .. "},\n") handle:flush() markers[#markers + 1] = { pos[1], 0, pos[3] } - Spring.MarkerAddPoint(pos[1], 0, pos[3], mexIndex) + SpringUnsynced.MarkerAddPoint(pos[1], 0, pos[3], mexIndex) mexIndex = mexIndex + 1 --else -- TODO: make right click remove markers @@ -64,7 +64,7 @@ function widget:MousePress(mx, my, button) end function widget:Initialize() - if not Spring.IsCheatingEnabled() then + if not SpringShared.IsCheatingEnabled() then spEcho("This widget requires cheats enabled") widgetHandler:RemoveWidget() return @@ -78,7 +78,7 @@ end function widget:Shutdown() for _, i in pairs(markers) do - Spring.MarkerErasePosition(i[1], i[2], i[3]) + SpringUnsynced.MarkerErasePosition(i[1], i[2], i[3]) end if handle ~= nil then io.close(handle) diff --git a/luaui/Widgets/dbg_profiler_histograms.lua b/luaui/Widgets/dbg_profiler_histograms.lua index f45005e9205..bf7896b9cd7 100644 --- a/luaui/Widgets/dbg_profiler_histograms.lua +++ b/luaui/Widgets/dbg_profiler_histograms.lua @@ -21,15 +21,15 @@ end local mathRandom = math.random -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo ---------------------------Speedups----------------------------- -local spGetProfilerTimeRecord = Spring.GetProfilerTimeRecord +local spGetProfilerTimeRecord = SpringUnsynced.GetProfilerTimeRecord ---------------------------Internal vars--------------------------- local timerstart = nil -local vsx, vsy = Spring.GetViewGeometry() +local vsx, vsy = SpringUnsynced.GetViewGeometry() ----------------------------GL4 vars---------------------------- local boundingbox = { vsx / 4, vsy / 4, 3 * vsx / 4, 3 * vsy / 4 } @@ -225,10 +225,10 @@ function widget:Initialize() spEcho("Failed to compile shaders for: frame grapher v2") widgetHandler:RemoveWidget(self) end - timerstart = Spring.GetTimer() - timerold = Spring.GetTimer() + timerstart = SpringUnsynced.GetTimer() + timerold = SpringUnsynced.GetTimer() - for k, v in pairs(Spring.GetProfilerRecordNames()) do + for k, v in pairs(SpringUnsynced.GetProfilerRecordNames()) do --spEcho(k,v) profilerecords[k] = v histograms[v] = createhistogram(v) @@ -236,7 +236,7 @@ function widget:Initialize() end local function PrintRecord(name) - local total, current, maxdt, time, peak = Spring.GetProfilerTimeRecord(name, false) + local total, current, maxdt, time, peak = SpringUnsynced.GetProfilerTimeRecord(name, false) -- where total is in milliseconds -- current gets reset ever 33 frames, and is a running tally -- maxdt is the peak value @@ -250,7 +250,7 @@ local function PrintRecord(name) end local function GetRecordCurrent(name) - local total, current = Spring.GetProfilerTimeRecord(name, false) + local total, current = SpringUnsynced.GetProfilerTimeRecord(name, false) return current end diff --git a/luaui/Widgets/dbg_quadtree_atlas_tester.lua b/luaui/Widgets/dbg_quadtree_atlas_tester.lua index fb6ae46d000..76186defc07 100644 --- a/luaui/Widgets/dbg_quadtree_atlas_tester.lua +++ b/luaui/Widgets/dbg_quadtree_atlas_tester.lua @@ -16,7 +16,7 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local MyAtlasOnDemand local buildPicList = {} @@ -99,7 +99,7 @@ end function widget:Initialize() --font = WG['fonts'].getFont() - font = gl.LoadFont("fonts/" .. Spring.GetConfigString("bar_font", "Poppins-Regular.otf"), 64, 1, 1) + font = gl.LoadFont("fonts/" .. SpringUnsynced.GetConfigString("bar_font", "Poppins-Regular.otf"), 64, 1, 1) local MakeAtlasOnDemand = VFS.Include("LuaUI/Include/AtlasOnDemand.lua") if not MakeAtlasOnDemand then diff --git a/luaui/Widgets/dbg_reloadcob.lua b/luaui/Widgets/dbg_reloadcob.lua index 67fd212a70d..f8cce395e98 100644 --- a/luaui/Widgets/dbg_reloadcob.lua +++ b/luaui/Widgets/dbg_reloadcob.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo include("keysym.h.lua") @@ -41,12 +41,12 @@ end function widget:Update() if doReload then local reloadedCobDefs = {} - local selection = Spring.GetSelectedUnits() + local selection = SpringUnsynced.GetSelectedUnits() for i, unitID in ipairs(selection) do - local unitDefID = Spring.GetUnitDefID(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) if not reloadedCobDefs[unitDefID] then local unitDefName = UnitDefs[unitDefID].name - Spring.SendCommands("reloadcob " .. unitDefName) + SpringUnsynced.SendCommands("reloadcob " .. unitDefName) spEcho("Reloaded COB: " .. unitDefName .. " from " .. UnitDefs[unitDefID].scriptName) reloadedCobDefs[unitDefID] = true end diff --git a/luaui/Widgets/dbg_startbox_editor.lua b/luaui/Widgets/dbg_startbox_editor.lua index b5ff15dd295..698b55f406c 100644 --- a/luaui/Widgets/dbg_startbox_editor.lua +++ b/luaui/Widgets/dbg_startbox_editor.lua @@ -18,8 +18,8 @@ local mathAbs = math.abs local mathFloor = math.floor -- Localized Spring API for performance -local spTraceScreenRay = Spring.TraceScreenRay -local spGetGroundHeight = Spring.GetGroundHeight +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetGroundHeight = SpringShared.GetGroundHeight -- this is not ZK copy, its is modified @@ -113,7 +113,7 @@ function widget:KeyPress(key) local file = assert(io.open(filename, "w"), "Unable to save " .. filename) file:write(exportPrefix .. exported .. exportSuffix) file:close() - Spring.Echo((exportedTeam == 0 and "saved" or "added") .. " team " .. exportedTeam .. " startboxes to " .. filename) + SpringShared.Echo((exportedTeam == 0 and "saved" or "added") .. " team " .. exportedTeam .. " startboxes to " .. filename) final_polygons = {} exportedTeam = exportedTeam + 1 @@ -131,7 +131,7 @@ local function DrawLine() gl.Vertex(x, y, z) end - local mx, my = Spring.GetMouseState() + local mx, my = SpringUnsynced.GetMouseState() local pos = select(2, spTraceScreenRay(mx, my, true)) if pos then gl.Vertex(pos[1], pos[2], pos[3]) diff --git a/luaui/Widgets/dbg_test_runner.lua b/luaui/Widgets/dbg_test_runner.lua index 109438b6de2..ecd171d6ce8 100644 --- a/luaui/Widgets/dbg_test_runner.lua +++ b/luaui/Widgets/dbg_test_runner.lua @@ -12,7 +12,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame if not Spring.Utilities.IsDevMode() or not Spring.Utilities.Gametype.IsSinglePlayer() then return @@ -61,7 +61,7 @@ local function log(level, str, ...) if level < LOG_LEVEL then return end - Spring.Log(widget:GetInfo().name, LOG.NOTICE, str) + SpringShared.Log(widget:GetInfo().name, LOG.NOTICE, str) end local function logStartTests() @@ -187,19 +187,19 @@ local testTimer local function getGameTime() if gameTimer ~= nil then - return Spring.DiffTimers(Spring.GetTimer(), gameTimer, true) + return SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), gameTimer, true) end end local function getRunTestsTime() if runTestsTimer ~= nil then - return Spring.DiffTimers(Spring.GetTimer(), runTestsTimer, true) + return SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), runTestsTimer, true) end end local function getTestTime() if testTimer ~= nil then - return Spring.DiffTimers(Spring.GetTimer(), testTimer, true) + return SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), testTimer, true) end end @@ -470,22 +470,22 @@ local function startTests(patterns) return end - if not Spring.GetGameRulesParam("isSyncedProxyEnabled") then + if not SpringShared.GetGameRulesParam("isSyncedProxyEnabled") then log(LOG.ERROR, "The Synced Proxy gadget is required in order to run tests. It requires single player, dev mode, " .. "and cheating to be enabled.") return end local neededActions = {} - if not Spring.IsCheatingEnabled() then + if not SpringShared.IsCheatingEnabled() then neededActions[#neededActions + 1] = { "cheat", "Cheats are disabled; attempting to enable them...", "Could not enable cheats; tests cannot be run." } end - if not Spring.IsDevLuaEnabled() then + if not SpringShared.IsDevLuaEnabled() then neededActions[#neededActions + 1] = { "devlua", "DevLua mode disabled; attempting to enable it...", "Could not enable DevLua mode; tests cannot be run." } end - if Spring.GetModOptions().deathmode ~= "neverend" and not Spring.GetGameRulesParam("testEndConditionsOverride") then + if SpringShared.GetModOptions().deathmode ~= "neverend" and not SpringShared.GetGameRulesParam("testEndConditionsOverride") then neededActions[#neededActions + 1] = { "luarules setTestEndConditions", "Disabling end conditions...", "Could not override game end condition. Please use deathmode='neverend' game end mode. " .. "This is required in order to run tests, so that the game stays active between tests." } end - if spGetGameFrame() < 1 and not Spring.GetGameRulesParam("testEnvironmentStarting") then + if spGetGameFrame() < 1 and not SpringShared.GetGameRulesParam("testEnvironmentStarting") then neededActions[#neededActions + 1] = { "luarules setTestReadyPlayers", "Preparing players to start game...", "Could not prepare players. Please start game manually." } end if #neededActions > 0 then @@ -493,7 +493,7 @@ local function startTests(patterns) -- enable required actions, then wait for them to go through for _, action in ipairs(neededActions) do log(LOG.INFO, action[2]) - Spring.SendCommands(action[1]) + SpringUnsynced.SendCommands(action[1]) end queueStartTests(patterns) return @@ -549,7 +549,7 @@ local function startTests(patterns) log(LOG.NOTICE, "=====RUNNING TESTS=====") - runTestsTimer = Spring.GetTimer() + runTestsTimer = SpringUnsynced.GetTimer() end local function finishTest(result) @@ -589,7 +589,7 @@ local function finishTest(result) logEndTests(getRunTestsTime()) if config.quitWhenDone then - Spring.SendCommands("quitforce") + SpringUnsynced.SendCommands("quitforce") end end end @@ -612,7 +612,7 @@ local function createNestedProxy(prefix, path) } log(LOG.DEBUG, "[createNestedProxy." .. prefix .. ".send]") - Spring.SendLuaRulesMsg(prefix .. serializedFn) + SpringUnsynced.SendLuaRulesMsg(prefix .. serializedFn) local resumeOk, resumeResult = coroutine.yield() @@ -643,7 +643,7 @@ SyncedRun = function(fn, timeout) } log(LOG.DEBUG, "[SyncedRun.send]") - Spring.SendLuaRulesMsg(Proxy.PREFIX.RUN .. serializedFn) + SpringUnsynced.SendLuaRulesMsg(Proxy.PREFIX.RUN .. serializedFn) local resumeOk, resumeResult = coroutine.yield() @@ -691,9 +691,9 @@ Test = { end, waitTime = function(milliseconds, timeout) log(LOG.DEBUG, "[waitTime] " .. milliseconds) - local startTimer = Spring.GetTimer() + local startTimer = SpringUnsynced.GetTimer() Test.waitUntil(function() - return Spring.DiffTimers(Spring.GetTimer(), startTimer, true) >= milliseconds + return SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), startTimer, true) >= milliseconds end, timeout or (milliseconds * 30 / 1000 + 5), 1) log(LOG.DEBUG, "[waitTime.done]") end, @@ -748,11 +748,11 @@ Test = { end, clearMap = function() SyncedRun(function() - for _, unitID in ipairs(Spring.GetAllUnits()) do - Spring.DestroyUnit(unitID, false, true, nil, false) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + SpringSynced.DestroyUnit(unitID, false, true, nil, false) end - for _, featureID in ipairs(Spring.GetAllFeatures()) do - Spring.DestroyFeature(featureID) + for _, featureID in ipairs(SpringShared.GetAllFeatures()) do + SpringSynced.DestroyFeature(featureID) end end) end, @@ -1189,7 +1189,7 @@ local function step() activeTestState.coroutine = coroutine.create(activeTestState.environment.__runTestInternal) activeTestState.startFrame = spGetGameFrame() - testTimer = Spring.GetTimer() + testTimer = SpringUnsynced.GetTimer() else finishTest({ result = TestResults.TEST_RESULT.ERROR, @@ -1292,7 +1292,7 @@ function widget:Initialize() end, nil, "t") TestExtraUtils.linkActions(self) - gameTimer = Spring.GetTimer() + gameTimer = SpringUnsynced.GetTimer() end function widget:Shutdown() diff --git a/luaui/Widgets/dbg_test_runner_watchdog.lua b/luaui/Widgets/dbg_test_runner_watchdog.lua index 7aeeb3835a2..cdd20818d39 100644 --- a/luaui/Widgets/dbg_test_runner_watchdog.lua +++ b/luaui/Widgets/dbg_test_runner_watchdog.lua @@ -22,9 +22,9 @@ function widget:Update(dt) if t > CHECK_PERIOD then t = 0 if widgetHandler:FindWidget("Test Runner") == nil then - Spring.Log(widget:GetInfo().name, LOG.WARNING, "Test runner crashed, exiting game") + SpringShared.Log(widget:GetInfo().name, LOG.WARNING, "Test runner crashed, exiting game") widgetHandler:DisableWidget(widget:GetInfo().name) - Spring.SendCommands("quitforce") + SpringUnsynced.SendCommands("quitforce") end end end diff --git a/luaui/Widgets/dbg_unit_callins.lua b/luaui/Widgets/dbg_unit_callins.lua index ee8c6cf0c9b..984c8b1e098 100644 --- a/luaui/Widgets/dbg_unit_callins.lua +++ b/luaui/Widgets/dbg_unit_callins.lua @@ -16,8 +16,8 @@ end local tableInsert = table.insert -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo -- UNIT CALLINS: local showcallins = true @@ -74,8 +74,8 @@ local function addEvent(unitID, callin, param1, param2, param3, param4) px = unitID[1] py = unitID[2] pz = unitID[3] - elseif Spring.ValidUnitID(unitID) then - px, py, pz = Spring.GetUnitPosition(unitID) + elseif SpringShared.ValidUnitID(unitID) then + px, py, pz = SpringShared.GetUnitPosition(unitID) end if px == nil then return @@ -125,7 +125,7 @@ function widget:DrawWorld() if numevents > 0 then gl.Color(1, 1, 1, 1) for key, event in pairs(eventlist) do - if Spring.IsSphereInView(event.x, event.y, event.z, 128) then + if SpringUnsynced.IsSphereInView(event.x, event.y, event.z, 128) then gl.PushMatrix() gl.Translate(event.x, event.y, event.z) gl.Text(event.caption, 0, 0, 16, "n") @@ -474,12 +474,12 @@ function widget:FeatureCreated(featureID) if enabledcallins.FeatureCreated == nil then return end - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if printcallins then spEcho("w:FeatureCreated", featureID, FeatureDefs[featureDefID].name) end if showcallins then - local fx, fy, fz = Spring.GetFeaturePosition(featureID) + local fx, fy, fz = SpringShared.GetFeaturePosition(featureID) local pos = { fx, fy, fz } addEvent(pos, "FeatureCreated") end @@ -489,12 +489,12 @@ function widget:FeatureDestroyed(featureID) if enabledcallins.FeatureDestroyed == nil then return end - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if printcallins then spEcho("w:FeatureDestroyed", featureID, FeatureDefs[featureDefID].name) end if showcallins then - local fx, fy, fz = Spring.GetFeaturePosition(featureID) + local fx, fy, fz = SpringShared.GetFeaturePosition(featureID) local pos = { fx, fy, fz } addEvent(pos, "FeatureDestroyed") end diff --git a/luaui/Widgets/dbg_unit_csv_export.lua b/luaui/Widgets/dbg_unit_csv_export.lua index e5bb532674d..aae0146b71e 100644 --- a/luaui/Widgets/dbg_unit_csv_export.lua +++ b/luaui/Widgets/dbg_unit_csv_export.lua @@ -267,6 +267,6 @@ function widget:Initialize() end end - Spring.Echo("Exported units to file: " .. filename) + SpringShared.Echo("Exported units to file: " .. filename) file:close() end diff --git a/luaui/Widgets/dbg_widget_auto_reloader.lua b/luaui/Widgets/dbg_widget_auto_reloader.lua index f6fc12c39a0..5e44e6a735c 100644 --- a/luaui/Widgets/dbg_widget_auto_reloader.lua +++ b/luaui/Widgets/dbg_widget_auto_reloader.lua @@ -18,8 +18,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetMouseState = Spring.GetMouseState -local spEcho = Spring.Echo +local spGetMouseState = SpringUnsynced.GetMouseState +local spEcho = SpringShared.Echo local widgetContents = {} -- maps widgetname to raw code local widgetFilesNames = {} -- maps widgetname to filename @@ -51,12 +51,12 @@ local function CheckForChanges(widgetName, fileName) end end -local lastUpdate = Spring.GetTimer() +local lastUpdate = SpringUnsynced.GetTimer() function widget:Update() - if Spring.DiffTimers(Spring.GetTimer(), lastUpdate) < 1 then + if SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), lastUpdate) < 1 then return end - lastUpdate = Spring.GetTimer() + lastUpdate = SpringUnsynced.GetTimer() local prevMouseOffscreen = mouseOffscreen mouseOffscreen = select(6, spGetMouseState()) diff --git a/luaui/Widgets/dbg_widget_profiler.lua b/luaui/Widgets/dbg_widget_profiler.lua index e12360e29ff..f5ff13f4450 100644 --- a/luaui/Widgets/dbg_widget_profiler.lua +++ b/luaui/Widgets/dbg_widget_profiler.lua @@ -39,10 +39,10 @@ local tonumber = tonumber local type = type -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetLuaMemUsage = Spring.GetLuaMemUsage -local spDiffTimers = Spring.DiffTimers -local spGetTimer = Spring.GetTimer +local spEcho = SpringShared.Echo +local spGetLuaMemUsage = SpringUnsynced.GetLuaMemUsage +local spDiffTimers = SpringUnsynced.DiffTimers +local spGetTimer = SpringUnsynced.GetTimer local glText = gl.Text local glColor = gl.Color local glBeginText = gl.BeginText @@ -104,12 +104,12 @@ local redStrength = {} local ColorString = Spring.Utilities.Color.ToString -if Spring.GetTimerMicros and Spring.GetConfigInt("UseHighResTimer", 0) == 1 then - spGetTimer = Spring.GetTimerMicros +if SpringUnsynced.GetTimerMicros and SpringUnsynced.GetConfigInt("UseHighResTimer", 0) == 1 then + spGetTimer = SpringUnsynced.GetTimerMicros highres = true end -spEcho("Profiler using highres timers", highres, Spring.GetConfigInt("UseHighResTimer", 0)) +spEcho("Profiler using highres timers", highres, SpringUnsynced.GetConfigInt("UseHighResTimer", 0)) local prefixedWnames = {} local widgetNameColors = {} -- Store RGB values for background tinting @@ -516,7 +516,7 @@ function widget:DrawScreen() return end - local averageTime = Spring.GetConfigFloat("profiler_averagetime", 2) + local averageTime = SpringUnsynced.GetConfigFloat("profiler_averagetime", 2) -- sort & count timing deltaTime = spDiffTimers(spGetTimer(), startTimer, nil, highres) @@ -528,10 +528,10 @@ function widget:DrawScreen() allOverTime = 0 allOverSpace = 0 local n = 1 - local sortByLoad = Spring.GetConfigInt("profiler_sort_by_load", 1) == 1 + local sortByLoad = SpringUnsynced.GetConfigInt("profiler_sort_by_load", 1) == 1 -- Cache FPS and frame calculation - local frames = mathMin(1 / tick, Spring.GetFPS()) * retainSortTime + local frames = mathMin(1 / tick, SpringUnsynced.GetFPS()) * retainSortTime local framesMinusOne = frames - 1 for wname, callins in pairs(callinStats) do diff --git a/luaui/Widgets/death_messages.lua b/luaui/Widgets/death_messages.lua index e06bb226ac6..7d875a19495 100644 --- a/luaui/Widgets/death_messages.lua +++ b/luaui/Widgets/death_messages.lua @@ -33,11 +33,11 @@ local teamNames = {} local function getTeamNames(teamID) local playerNames = {} - local _, _, _, isAI = Spring.GetTeamInfo(teamID, false) + local _, _, _, isAI = SpringShared.GetTeamInfo(teamID, false) if isAI then - local _, _, _, name = Spring.GetAIInfo(teamID) - local niceName = Spring.GetGameRulesParam("ainame_" .. teamID) + local _, _, _, name = SpringShared.GetAIInfo(teamID) + local niceName = SpringShared.GetGameRulesParam("ainame_" .. teamID) if niceName then name = niceName @@ -45,10 +45,10 @@ local function getTeamNames(teamID) tableInsert(playerNames, name) else - local players = Spring.GetPlayerList(teamID) + local players = SpringShared.GetPlayerList(teamID) for _, playerID in pairs(players) do - local name = Spring.GetPlayerInfo(playerID, false) + local name = SpringShared.GetPlayerInfo(playerID, false) name = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerID)) or name tableInsert(playerNames, name) end @@ -61,13 +61,13 @@ local function notifyTeamDeath(teamID) local playerNameList = teamNames[teamID] if playerNameList == nil or next(playerNameList) == nil then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "Team " .. teamID .. ": no names in players list") + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "Team " .. teamID .. ": no names in players list") else local playerNames = table.concat(playerNameList, ", ") local n = math.random(#deathMessageKeys) local message = Spring.I18N("tips.deathMessages.team." .. deathMessageKeys[n], { playerList = playerNames }) - Spring.SendMessage(message) + SpringUnsynced.SendMessage(message) end end @@ -76,7 +76,7 @@ function widget:TeamDied(teamID) end function widget:Initialize() - local teams = Spring.GetTeamList() + local teams = SpringShared.GetTeamList() for _, teamID in pairs(teams) do teamNames[teamID] = getTeamNames(teamID) diff --git a/luaui/Widgets/dev_autocheat.lua b/luaui/Widgets/dev_autocheat.lua index 44aca9a4dd6..717d0d8f110 100644 --- a/luaui/Widgets/dev_autocheat.lua +++ b/luaui/Widgets/dev_autocheat.lua @@ -17,15 +17,15 @@ function widget:GetInfo() end function widget:Update(f) - if not Spring.IsCheatingEnabled() then - Spring.SendCommands("say !cheats") - Spring.SendCommands("say !hostsay /globallos") - Spring.SendCommands("say !hostsay /godmode") + if not SpringShared.IsCheatingEnabled() then + SpringUnsynced.SendCommands("say !cheats") + SpringUnsynced.SendCommands("say !hostsay /globallos") + SpringUnsynced.SendCommands("say !hostsay /godmode") --Spring.SendCommands("say !hostsay /nocost") - Spring.SendCommands("cheat") - Spring.SendCommands("globallos") - Spring.SendCommands("godmode") + SpringUnsynced.SendCommands("cheat") + SpringUnsynced.SendCommands("globallos") + SpringUnsynced.SendCommands("godmode") --Spring.SendCommands("nocost") end widgetHandler:RemoveCallIn("Update") diff --git a/luaui/Widgets/export_defs.lua b/luaui/Widgets/export_defs.lua index a5e8bea8d1e..8686d19f654 100644 --- a/luaui/Widgets/export_defs.lua +++ b/luaui/Widgets/export_defs.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local export_folder_path = "json_export" @@ -29,7 +29,7 @@ end local function ExportDefs() if not VFS.FileExists(export_folder_path) then - Spring.CreateDir(export_folder_path) + SpringUnsynced.CreateDir(export_folder_path) end for id, unitDef in pairs(UnitDefs) do diff --git a/luaui/Widgets/flowui_atlas_gl4.lua b/luaui/Widgets/flowui_atlas_gl4.lua index 41810df130a..2a6cc91f1c5 100644 --- a/luaui/Widgets/flowui_atlas_gl4.lua +++ b/luaui/Widgets/flowui_atlas_gl4.lua @@ -15,7 +15,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -- TODO 2022.10.21 -- Dont load all the 3d shit from luaui images root! diff --git a/luaui/Widgets/flowui_gl4.lua b/luaui/Widgets/flowui_gl4.lua index 7b31b9022c8..4be2410ece3 100644 --- a/luaui/Widgets/flowui_gl4.lua +++ b/luaui/Widgets/flowui_gl4.lua @@ -21,7 +21,7 @@ local mathMin = math.min local mathRandom = math.random -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local LuaShader = gl.LuaShader local InstanceVBOTable = gl.InstanceVBOTable @@ -152,7 +152,7 @@ iconTypes = nil -- and to use a smaller number elements local Draw = {} -local vsx, vsy = Spring.GetViewGeometry() +local vsx, vsy = SpringUnsynced.GetViewGeometry() local nameCounter = 0 local ROOT -- this is the global root, its children can only be layers! local Layers = {} -- A sorted list of Layer objects, each containing its own text list, its own scissor, and all kinds of other fun stuff. Maybe even setting its own stying like textcolor, outlinecolor? , keyed with layername @@ -645,8 +645,7 @@ function metaElement:NewSelector(obj) end -- this one is tricky, see how chili does it? function metaElement:NewEditBox(obj) end -function metaElement:NewComboBox(obj) -end +function metaElement:NewComboBox(obj) end function metaElement:NewSlider(o) o.textelements = { @@ -2072,15 +2071,15 @@ end -- Draw.Element = function(VBO, instanceID, z, px, py, sx, sy, tl, tr, br, bl, ptl, ptr, pbr, pbl, opacity, color1, color2, bgpadding) - local opacity = opacity or Spring.GetConfigFloat("ui_opacity", 0.7) + local opacity = opacity or SpringUnsynced.GetConfigFloat("ui_opacity", 0.7) local color1 = color1 or { 0, 0, 0, opacity } local color2 = color2 or { 1, 1, 1, opacity * 0.1 } - local ui_scale = Spring.GetConfigFloat("ui_scale", 1) + local ui_scale = SpringUnsynced.GetConfigFloat("ui_scale", 1) local bgpadding = bgpadding or WG.FlowUI.elementPadding local cs = WG.FlowUI.elementCorner * (bgpadding / WG.FlowUI.elementPadding) local glossMult = 1 + (2 - (opacity * 1.5)) - local tileopacity = Spring.GetConfigFloat("ui_tileopacity", 0.014) - local bgtexScale = Spring.GetConfigFloat("ui_tilescale", 7) + local tileopacity = SpringUnsynced.GetConfigFloat("ui_tileopacity", 0.014) + local bgtexScale = SpringUnsynced.GetConfigFloat("ui_tilescale", 7) local bgtexSize = mathFloor(WG.FlowUI.elementPadding * bgtexScale) local tl = tl or 1 @@ -2683,8 +2682,7 @@ function widget:DrawScreen() elseif r < 0.8 then --Draw.TexturedRectRound(rectRoundVBO, nil, 0.5, x,y,w,h, 10,1,1,1,1,nil,nil,nil,"icons/armpwt4.png") - Draw.Element(rectRoundVBO, nil, 0.5, x, y, w, h, 1, 1, 1, 1, 1, 1, 1, 1, nil, { 0, 0, 0, 0.8 }, { 0.2, 0.8, 0.2, 0.8 }, nil -) + Draw.Element(rectRoundVBO, nil, 0.5, x, y, w, h, 1, 1, 1, 1, 1, 1, 1, 1, nil, { 0, 0, 0, 0.8 }, { 0.2, 0.8, 0.2, 0.8 }, nil) elseif r < 0.9 then Draw.Unit( @@ -2717,7 +2715,7 @@ function widget:DrawScreen() --local UiButton = WG.FlowUI.Draw.Button --UiButton(500, 500, 600, 550, 1,1,1,1, 1,1,1,1, nil, { 0, 0, 0, 0.8 }, { 0.2, 0.8, 0.2, 0.8 }, WG.FlowUI.elementCorner * 0.5) - local mx, my, left, middle, right = Spring.GetMouseState() + local mx, my, left, middle, right = SpringUnsynced.GetMouseState() uiUpdate(mx, my, left, middle, right) RefreshText() diff --git a/luaui/Widgets/gfx_DrawUnitShape_GL4.lua b/luaui/Widgets/gfx_DrawUnitShape_GL4.lua index 14391f1dc95..234ae47fad9 100644 --- a/luaui/Widgets/gfx_DrawUnitShape_GL4.lua +++ b/luaui/Widgets/gfx_DrawUnitShape_GL4.lua @@ -15,8 +15,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spEcho = Spring.Echo +local spGetUnitDefID = SpringShared.GetUnitDefID +local spEcho = SpringShared.Echo -- TODO: correctly track add/remove per vbotable -- Dont Allow mixed types, it will fuck with textures anyway @@ -435,7 +435,7 @@ if TESTMODE then local unitDefIDtoUniqueID = {} function widget:UnitCreated(unitID, unitDefID) unitIDtoUniqueID[unitID] = DrawUnitGL4(unitID, unitDefID, 0, 0, 0, math.random() * 2, 0.6) - local px, py, pz = Spring.GetUnitPosition(unitID) + local px, py, pz = SpringShared.GetUnitPosition(unitID) unitDefIDtoUniqueID[unitID] = DrawUnitShapeGL4(spGetUnitDefID(unitID), px + 20, py + 50, pz + 20, 0, 0.6) end @@ -548,7 +548,7 @@ function widget:Initialize() widgetHandler:RemoveWidget() end if TESTMODE then - for i, unitID in ipairs(Spring.GetAllUnits()) do + for i, unitID in ipairs(SpringShared.GetAllUnits()) do widget:UnitCreated(unitID) end end @@ -622,7 +622,7 @@ function widget:DrawWorldPreUnit() -- this is for UnitDef gl.DepthTest(GL.LEQUAL) gl.PolygonOffset(1, 1) -- so as not to clash with engine ghosts unitShapeShader:Activate() - unitShapeShader:SetUniform("iconDistance", 27 * Spring.GetConfigInt("UnitIconDist", 200)) + unitShapeShader:SetUniform("iconDistance", 27 * SpringUnsynced.GetConfigInt("UnitIconDist", 200)) active = true end @@ -645,7 +645,7 @@ function widget:DrawWorld() gl.DepthTest(true) gl.PolygonOffset(-2, -2) unitShader:Activate() - unitShader:SetUniform("iconDistance", 27 * Spring.GetConfigInt("UnitIconDist", 200)) + unitShader:SetUniform("iconDistance", 27 * SpringUnsynced.GetConfigInt("UnitIconDist", 200)) if corDrawUnitVBOTable.usedElements > 0 then gl.UnitShapeTextures(corcomUnitDefID, true) corDrawUnitVBOTable.VAO:Submit() diff --git a/luaui/Widgets/gfx_HighlightUnit_GL4.lua b/luaui/Widgets/gfx_HighlightUnit_GL4.lua index b87ae50f1a4..654f87c1f6d 100644 --- a/luaui/Widgets/gfx_HighlightUnit_GL4.lua +++ b/luaui/Widgets/gfx_HighlightUnit_GL4.lua @@ -14,8 +14,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spEcho = Spring.Echo +local spGetUnitDefID = SpringShared.GetUnitDefID +local spEcho = SpringShared.Echo -- Notes: this API can be considered mildly deprecated, as CUS GL4 now handles the major consumers of this API. -- This API is now fully deprecated, as the swith to quaternions breaks it entirely. @@ -384,10 +384,10 @@ function widget:Initialize() return end if TESTMODE then - for i, unitID in ipairs(Spring.GetAllUnits()) do + for i, unitID in ipairs(SpringShared.GetAllUnits()) do widget:UnitCreated(unitID) end - for i, featureID in ipairs(Spring.GetAllFeatures()) do + for i, featureID in ipairs(SpringShared.GetAllFeatures()) do HighlightUnitGL4(featureID, "featureID", 0.0, 0.25, 1, 0.2, 0.5, 3.0, 0.0) end end @@ -450,7 +450,7 @@ function widget:DrawWorld() gl.Blending(GL.SRC_ALPHA, GL.ONE) gl.PolygonOffset(-0.1, -0.1) -- too much here bleeds highlightunitShader:Activate() - highlightunitShader:SetUniform("iconDistance", 27 * Spring.GetConfigInt("UnitIconDist", 200)) + highlightunitShader:SetUniform("iconDistance", 27 * SpringUnsynced.GetConfigInt("UnitIconDist", 200)) highlightUnitVBOTable.VAO:Submit() highlightunitShader:Deactivate() gl.PolygonOffset(false) diff --git a/luaui/Widgets/gfx_airjets_gl4.lua b/luaui/Widgets/gfx_airjets_gl4.lua index 046b6e79a0a..f56392d7ee9 100644 --- a/luaui/Widgets/gfx_airjets_gl4.lua +++ b/luaui/Widgets/gfx_airjets_gl4.lua @@ -21,12 +21,12 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spEcho = Spring.Echo -local spGetAllUnits = Spring.GetAllUnits -local spGetTeamUnitsByDefs = Spring.GetTeamUnitsByDefs -local spGetTeamList = Spring.GetTeamList -local spGetSpectatingState = Spring.GetSpectatingState +local spGetUnitDefID = SpringShared.GetUnitDefID +local spEcho = SpringShared.Echo +local spGetAllUnits = SpringShared.GetAllUnits +local spGetTeamUnitsByDefs = SpringShared.GetTeamUnitsByDefs +local spGetTeamList = SpringShared.GetTeamList +local spGetSpectatingState = SpringUnsynced.GetSpectatingState -- TODO: -- reflections @@ -43,12 +43,12 @@ local spGetSpectatingState = Spring.GetSpectatingState -------------------------------------------------------------------------------- --- -local spGetGameFrame = Spring.GetGameFrame -local spGetUnitPieceMap = Spring.GetUnitPieceMap -local spGetUnitIsActive = Spring.GetUnitIsActive -local spGetUnitVelocity = Spring.GetUnitVelocity -local spGetUnitTeam = Spring.GetUnitTeam -local spIsUnitInLos = Spring.IsUnitInLos +local spGetGameFrame = SpringShared.GetGameFrame +local spGetUnitPieceMap = SpringShared.GetUnitPieceMap +local spGetUnitIsActive = SpringShared.GetUnitIsActive +local spGetUnitVelocity = SpringShared.GetUnitVelocity +local spGetUnitTeam = SpringShared.GetUnitTeam +local spIsUnitInLos = SpringShared.IsUnitInLos local glBlending = gl.Blending local glTexture = gl.Texture @@ -60,7 +60,7 @@ local GL_ONE = GL.ONE local glAlphaTest = gl.AlphaTest local glDepthTest = gl.DepthTest -local spValidUnitID = Spring.ValidUnitID +local spValidUnitID = SpringShared.ValidUnitID -------------------------------------------------------------------------------- -- Configuration @@ -150,7 +150,7 @@ local inactivePlanes = {} local lights = {} local shaders -local lastGameFrame = Spring.GetGameFrame() +local lastGameFrame = SpringShared.GetGameFrame() local updateSec = 0 local spec, fullview = spGetSpectatingState() @@ -448,7 +448,7 @@ local function ValidateUnitIDs(unitIDkeys) local invalidstr = "" for indexpos, unitID in pairs(unitIDkeys) do numunitids = numunitids + 1 - if Spring.ValidUnitID(unitID) then + if SpringShared.ValidUnitID(unitID) then validunitids = validunitids + 1 else invalidunitids[#invalidunitids + 1] = unitID @@ -542,7 +542,7 @@ local function Activate(unitID, unitDefID, who, when) when = 0 end -- - if Spring.GetUnitIsDead(unitID) == true then + if SpringShared.GetUnitIsDead(unitID) == true then --Spring.SendCommands({"pause 1"}) return end @@ -614,7 +614,7 @@ function widget:Update(dt) return end updateSec = updateSec + dt - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() if gf ~= lastGameFrame and updateSec > 0.51 then -- to limit the number of unit status checks --[[ if Spring.GetGameFrame() > 0 then @@ -632,7 +632,7 @@ function widget:Update(dt) updateSec = 0 for unitID, unitDefID in pairs(inactivePlanes) do -- always activate enemy planes - if spGetUnitIsActive(unitID) or not Spring.IsUnitAllied(unitID) then + if spGetUnitIsActive(unitID) or not SpringUnsynced.IsUnitAllied(unitID) then if xzVelocityUnits[unitDefID] then local uvx, _, uvz = spGetUnitVelocity(unitID) if uvx * uvx + uvz * uvz > xzVelocityUnits[unitDefID] * xzVelocityUnits[unitDefID] then @@ -644,7 +644,7 @@ function widget:Update(dt) end end for unitID, unitDefID in pairs(activePlanes) do - if Spring.ValidUnitID(unitID) then + if SpringShared.ValidUnitID(unitID) then if not spGetUnitIsActive(unitID) then Deactivate(unitID, unitDefID, "updatewasinactive") else diff --git a/luaui/Widgets/gfx_bloom_shader_deferred.lua b/luaui/Widgets/gfx_bloom_shader_deferred.lua index 62de8cbb600..19d38e1e291 100644 --- a/luaui/Widgets/gfx_bloom_shader_deferred.lua +++ b/luaui/Widgets/gfx_bloom_shader_deferred.lua @@ -26,7 +26,7 @@ local mathCeil = math.ceil local mathMax = math.max -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local version = 1.1 @@ -113,7 +113,7 @@ local function RemoveMe(msg) end local function MakeBloomShaders() - local viewSizeX, viewSizeY = Spring.GetViewGeometry() + local viewSizeX, viewSizeY = SpringUnsynced.GetViewGeometry() local downscale = presets[preset].quality --spEcho("New bloom init preset:", preset) vsx = mathMax(4, viewSizeX) @@ -516,11 +516,11 @@ function widget:Initialize() return end - local hasdeferredmodelrendering = (Spring.GetConfigString("AllowDeferredModelRendering") == "1") + local hasdeferredmodelrendering = (SpringUnsynced.GetConfigString("AllowDeferredModelRendering") == "1") if hasdeferredmodelrendering == false then RemoveMe("[BloomShader::Initialize] removing widget, AllowDeferredModelRendering is required") end - local hasdeferredmaprendering = (Spring.GetConfigString("AllowDeferredMapRendering") == "1") + local hasdeferredmaprendering = (SpringUnsynced.GetConfigString("AllowDeferredMapRendering") == "1") if hasdeferredmaprendering == false then RemoveMe("[BloomShader::Initialize] removing widget, AllowDeferredMapRendering is required") end diff --git a/luaui/Widgets/gfx_cas.lua b/luaui/Widgets/gfx_cas.lua index eaad56e7779..8863b012cb3 100644 --- a/luaui/Widgets/gfx_cas.lua +++ b/luaui/Widgets/gfx_cas.lua @@ -15,7 +15,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -- Shameless port from https://gist.github.com/martymcmodding/30304c4bffa6e2bd2eb59ff8bb09d135 @@ -183,7 +183,7 @@ function widget:Initialize() return end - _, _, vpx, vpy = Spring.GetViewGeometry() + _, _, vpx, vpy = SpringUnsynced.GetViewGeometry() --local commonTexOpts = { -- target = GL_TEXTURE_2D, diff --git a/luaui/Widgets/gfx_darken_map.lua b/luaui/Widgets/gfx_darken_map.lua index 61a5040cd8c..1b9697da766 100644 --- a/luaui/Widgets/gfx_darken_map.lua +++ b/luaui/Widgets/gfx_darken_map.lua @@ -17,7 +17,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetCameraPosition = Spring.GetCameraPosition +local spGetCameraPosition = SpringUnsynced.GetCameraPosition local darknessvalue = 0 local maxDarkness = 0.6 @@ -28,7 +28,7 @@ local maxDarkness = 0.6 local features local camX, camY, camZ = spGetCameraPosition() -local camDirX, camDirY, camDirZ = Spring.GetCameraDirection() +local camDirX, camDirY, camDirZ = SpringUnsynced.GetCameraDirection() function widget:Shutdown() WG["darkenmap"] = nil @@ -61,14 +61,14 @@ prevCam[1], prevCam[2], prevCam[3] = spGetCameraPosition() function widget:Update(dt) if darknessvalue >= 0.01 then camX, camY, camZ = spGetCameraPosition() - camDirX, camDirY, camDirZ = Spring.GetCameraDirection() + camDirX, camDirY, camDirZ = SpringUnsynced.GetCameraDirection() end end function widget:DrawWorldPreUnit() if darknessvalue >= 0.01 then - local drawMode = Spring.GetMapDrawMode() + local drawMode = SpringUnsynced.GetMapDrawMode() if (drawMode == "height") or (drawMode == "path") then return end diff --git a/luaui/Widgets/gfx_decals_gl4.lua b/luaui/Widgets/gfx_decals_gl4.lua index 704e01c2c19..32afd98c3b6 100644 --- a/luaui/Widgets/gfx_decals_gl4.lua +++ b/luaui/Widgets/gfx_decals_gl4.lua @@ -20,8 +20,8 @@ local mathRandom = math.random local round = math.round -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo -- Notes and TODO -- yes these are geometry shader decals @@ -135,7 +135,7 @@ local hasBadCulling = false -- AMD+Linux combo --------------------------- Localization for faster access ------------------- -local spGetGroundHeight = Spring.GetGroundHeight +local spGetGroundHeight = SpringShared.GetGroundHeight local abs = math.abs local glTexture = gl.Texture @@ -427,7 +427,7 @@ local function DrawSmoothness() gl.Color(1, 1, 1, 1) for areaHash, areaInfo in pairs(areaDecals) do --spEcho(areaHash, areaInfo.x, areaInfo.y, areaInfo.z) - if Spring.IsSphereInView(areaInfo.x, areaInfo.y, areaInfo.z, 128) then + if SpringUnsynced.IsSphereInView(areaInfo.x, areaInfo.y, areaInfo.z, 128) then gl.PushMatrix() local text = string.format("Smoothness = %d", areaInfo.smoothness) local w = gl.GetTextWidth(text) * 16.0 @@ -489,7 +489,7 @@ local function AddDecal(decaltexturename, posx, posz, rotation, width, length, h p, q, s, t = uvs[1], uvs[2], uvs[3], uvs[4] end - local posy = Spring.GetGroundHeight(posx, posz) + local posy = SpringShared.GetGroundHeight(posx, posz) --spEcho (unitDefID,decalInfo.texfile, width, length, alpha) -- match the vertex shader on lifetime: -- float currentAlpha = min(1.0, (lifetonow / FADEINTIME)) * alphastart - lifetonow* alphadecay; @@ -547,7 +547,7 @@ local function DrawDecals() if decalVBO.usedElements > 0 or decalLargeVBO.usedElements > 0 or decalExtraLargeVBO.usedElements > 0 then gl.Blending(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA) -- the default mode - local disticon = 27 * Spring.GetConfigInt("UnitIconDist", 200) -- iconLength = unitIconDist * unitIconDist * 750.0f; + local disticon = 27 * SpringUnsynced.GetConfigInt("UnitIconDist", 200) -- iconLength = unitIconDist * unitIconDist * 750.0f; --spEcho(decalVBO.usedElements,decalLargeVBO.usedElements) if hasBadCulling then glCulling(false) @@ -721,7 +721,7 @@ do end end -local globalDamageMult = Spring.GetModOptions().multiplier_weapondamage or 1 +local globalDamageMult = SpringShared.GetModOptions().multiplier_weapondamage or 1 local damageCoefficient = (1 / globalDamageMult + 0.25 * globalDamageMult - 0.25) -- for sane values with high modifiers local weaponConfig = {} @@ -1837,7 +1837,7 @@ call-script lua_UnitScriptDecal(1, (get PIECE_XZ(lfoot) & 0xffff0000) / 0x000100 -- local function UnitScriptDecal(unitID, unitDefID, whichDecal, posx, posz, heading) --spEcho("Widgetside UnitScriptDecal", unitID, unitDefID, whichDecal, posx,posz, heading) - if Spring.ValidUnitID(unitID) and Spring.GetUnitIsDead(unitID) == false and UnitScriptDecals[unitDefID] and UnitScriptDecals[unitDefID][whichDecal] then + if SpringShared.ValidUnitID(unitID) and SpringShared.GetUnitIsDead(unitID) == false and UnitScriptDecals[unitDefID] and UnitScriptDecals[unitDefID][whichDecal] then local decalTable = UnitScriptDecals[unitDefID][whichDecal] -- So order of transformations is, get heading, rotate that into world space , heading 0 is +Z direction @@ -1877,7 +1877,7 @@ local function UnitScriptDecal(unitID, unitDefID, whichDecal, posx, posz, headin decalCache[3] = decalTable.offsetrot + rotationradians decalCache[13] = worldposx - decalCache[14] = Spring.GetGroundHeight(posx, posz) + decalCache[14] = SpringShared.GetGroundHeight(posx, posz) decalCache[15] = worldposz decalCache[10] = decalTable.alphadecay / (lifeTimeMult * lifeTimeMultMult) @@ -1982,7 +1982,7 @@ function widget:Initialize() if step == 13 then -- Compact: reconstruct full 20-float VBO entry local posx, posz = entry[11], entry[12] - local posy = Spring.GetGroundHeight(posx, posz) or 0 + local posy = SpringShared.GetGroundHeight(posx, posz) or 0 vboEntry = { entry[1], entry[2], diff --git a/luaui/Widgets/gfx_deferred_rendering_GL4.lua b/luaui/Widgets/gfx_deferred_rendering_GL4.lua index dac58968e3a..45af1f6bf27 100644 --- a/luaui/Widgets/gfx_deferred_rendering_GL4.lua +++ b/luaui/Widgets/gfx_deferred_rendering_GL4.lua @@ -31,39 +31,39 @@ local stringFormat = string.format local stringLower = string.lower -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo -local spGetSpectatingState = Spring.GetSpectatingState -local spGetPlayerList = Spring.GetPlayerList -local spGetTeamColor = Spring.GetTeamColor -local spGetPlayerInfo = Spring.GetPlayerInfo -local spIsUnitAllied = Spring.IsUnitAllied -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPieceMap = Spring.GetUnitPieceMap +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetPlayerList = SpringShared.GetPlayerList +local spGetTeamColor = SpringUnsynced.GetTeamColor +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPieceMap = SpringShared.GetUnitPieceMap local spGetProjectileName = Spring.GetProjectileName -local spGetWind = Spring.GetWind -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay -local spGetModKeyState = Spring.GetModKeyState -local spGetCameraPosition = Spring.GetCameraPosition -local spGetCameraDirection = Spring.GetCameraDirection -local spGetConfigInt = Spring.GetConfigInt -local spSetSunLighting = Spring.SetSunLighting -local spGetAllFeatures = Spring.GetAllFeatures -local spGetFeatureDefID = Spring.GetFeatureDefID -local spGetFeaturePosition = Spring.GetFeaturePosition -local spGetUnitHeight = Spring.GetUnitHeight -local spGetUnitLosState = Spring.GetUnitLosState -local spDiffTimers = Spring.DiffTimers -local spGetTimer = Spring.GetTimer -local spGetTimerMicros = Spring.GetTimerMicros -local spGetDrawFrame = Spring.GetDrawFrame -local spGetFPS = Spring.GetFPS -local spGetConfigString = Spring.GetConfigString -local spGetTeamInfo = Spring.GetTeamInfo -local spGetAllyTeamList = Spring.GetAllyTeamList -local spGetTeamList = Spring.GetTeamList +local spGetWind = SpringShared.GetWind +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetModKeyState = SpringUnsynced.GetModKeyState +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spGetCameraDirection = SpringUnsynced.GetCameraDirection +local spGetConfigInt = SpringUnsynced.GetConfigInt +local spSetSunLighting = SpringUnsynced.SetSunLighting +local spGetAllFeatures = SpringShared.GetAllFeatures +local spGetFeatureDefID = SpringShared.GetFeatureDefID +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spGetUnitHeight = SpringShared.GetUnitHeight +local spGetUnitLosState = SpringShared.GetUnitLosState +local spDiffTimers = SpringUnsynced.DiffTimers +local spGetTimer = SpringUnsynced.GetTimer +local spGetTimerMicros = SpringUnsynced.GetTimerMicros +local spGetDrawFrame = SpringUnsynced.GetDrawFrame +local spGetFPS = SpringUnsynced.GetFPS +local spGetConfigString = SpringUnsynced.GetConfigString +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetAllyTeamList = SpringShared.GetAllyTeamList +local spGetTeamList = SpringShared.GetTeamList -------------------------------- Notes, TODO ---------------------------------- do @@ -249,19 +249,19 @@ local GL_ONE = GL.ONE local GL_ONE_MINUS_SRC_ALPHA = GL.ONE_MINUS_SRC_ALPHA -- Strong: -local spGetProjectilePosition = Spring.GetProjectilePosition -local spGetProjectileVelocity = Spring.GetProjectileVelocity -local spGetProjectileType = Spring.GetProjectileType -local spGetPieceProjectileParams = Spring.GetPieceProjectileParams -local spGetProjectileDefID = Spring.GetProjectileDefID -local spGetGroundHeight = Spring.GetGroundHeight -local spIsSphereInView = Spring.IsSphereInView -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitIsDead = Spring.GetUnitIsDead -local spValidUnitID = Spring.ValidUnitID +local spGetProjectilePosition = SpringShared.GetProjectilePosition +local spGetProjectileVelocity = SpringShared.GetProjectileVelocity +local spGetProjectileType = SpringShared.GetProjectileType +local spGetPieceProjectileParams = SpringShared.GetPieceProjectileParams +local spGetProjectileDefID = SpringShared.GetProjectileDefID +local spGetGroundHeight = SpringShared.GetGroundHeight +local spIsSphereInView = SpringUnsynced.IsSphereInView +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spValidUnitID = SpringShared.ValidUnitID -- Weak: -local spIsGUIHidden = Spring.IsGUIHidden +local spIsGUIHidden = SpringUnsynced.IsGUIHidden local math_max = mathMax local math_ceil = mathCeil @@ -1162,7 +1162,7 @@ for wdid, wd in pairs(WeaponDefs) do end function widget:VisibleExplosion(px, py, pz, weaponID, ownerID) - if targetable[weaponID] and py - 300 > Spring.GetGroundHeight(px, pz) then -- dont add light to (likely) intercepted explosions (mainly to curb nuke flashes) + if targetable[weaponID] and py - 300 > SpringShared.GetGroundHeight(px, pz) then -- dont add light to (likely) intercepted explosions (mainly to curb nuke flashes) return end if explosionLights[weaponID] then @@ -1490,13 +1490,13 @@ end local function PrintProjectileInfo(projectileID) local px, py, pz = spGetProjectilePosition(projectileID) - local weapon, piece = Spring.GetProjectileType(projectileID) - local weaponDefID = weapon and Spring.GetProjectileDefID(projectileID) + local weapon, piece = SpringShared.GetProjectileType(projectileID) + local weaponDefID = weapon and SpringShared.GetProjectileDefID(projectileID) Spring.Debug.TraceFullEcho() end local function updateProjectileLights(newgameframe) - local nowprojectiles = Spring.GetVisibleProjectiles() + local nowprojectiles = SpringUnsynced.GetVisibleProjectiles() gameFrame = spGetGameFrame() local newgameframe = true if gameFrame == lastGameFrame then @@ -1624,7 +1624,7 @@ local function updateProjectileLights(newgameframe) --end end -local configCache = { lastUpdate = Spring.GetTimer() } +local configCache = { lastUpdate = SpringUnsynced.GetTimer() } local function checkConfigUpdates() if spDiffTimers(spGetTimer(), configCache.lastUpdate) > 0.5 then local newconfa = VFS.LoadFile("luaui/configs/DeferredLightsGL4config.lua") diff --git a/luaui/Widgets/gfx_distortion_gl4.lua b/luaui/Widgets/gfx_distortion_gl4.lua index bee79294f32..8ce9073062b 100644 --- a/luaui/Widgets/gfx_distortion_gl4.lua +++ b/luaui/Widgets/gfx_distortion_gl4.lua @@ -27,27 +27,27 @@ local pcall = pcall local select = select -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry -local spGetWind = Spring.GetWind -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spIsUnitAllied = Spring.IsUnitAllied -local spGetUnitPieceMap = Spring.GetUnitPieceMap -local spGetUnitHeight = Spring.GetUnitHeight -local spGetUnitLosState = Spring.GetUnitLosState -local spGetFeatureDefID = Spring.GetFeatureDefID -local spGetFeaturePosition = Spring.GetFeaturePosition +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetWind = SpringShared.GetWind +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spGetUnitPieceMap = SpringShared.GetUnitPieceMap +local spGetUnitHeight = SpringShared.GetUnitHeight +local spGetUnitLosState = SpringShared.GetUnitLosState +local spGetFeatureDefID = SpringShared.GetFeatureDefID +local spGetFeaturePosition = SpringShared.GetFeaturePosition local spGetProjectileName = Spring.GetProjectileName -local spGetModKeyState = Spring.GetModKeyState -local spGetTimer = Spring.GetTimer -local spDiffTimers = Spring.DiffTimers -local spGetTimerMicros = Spring.GetTimerMicros -local spGetConfigString = Spring.GetConfigString -local spGetAllFeatures = Spring.GetAllFeatures -local spGetSpectatingState = Spring.GetSpectatingState -local spGetVisibleProjectiles = Spring.GetVisibleProjectiles +local spGetModKeyState = SpringUnsynced.GetModKeyState +local spGetTimer = SpringUnsynced.GetTimer +local spDiffTimers = SpringUnsynced.DiffTimers +local spGetTimerMicros = SpringUnsynced.GetTimerMicros +local spGetConfigString = SpringUnsynced.GetConfigString +local spGetAllFeatures = SpringShared.GetAllFeatures +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetVisibleProjectiles = SpringUnsynced.GetVisibleProjectiles -- Localized GL functions local glClear = gl.Clear @@ -78,19 +78,19 @@ local glBlending = gl.Blending local glTexture = gl.Texture -- Strong: -local spGetProjectilePosition = Spring.GetProjectilePosition -local spGetProjectileVelocity = Spring.GetProjectileVelocity -local spGetProjectileType = Spring.GetProjectileType -local spGetPieceProjectileParams = Spring.GetPieceProjectileParams -local spGetProjectileDefID = Spring.GetProjectileDefID -local spGetGroundHeight = Spring.GetGroundHeight -local spIsSphereInView = Spring.IsSphereInView -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitIsDead = Spring.GetUnitIsDead -local spValidUnitID = Spring.ValidUnitID +local spGetProjectilePosition = SpringShared.GetProjectilePosition +local spGetProjectileVelocity = SpringShared.GetProjectileVelocity +local spGetProjectileType = SpringShared.GetProjectileType +local spGetPieceProjectileParams = SpringShared.GetPieceProjectileParams +local spGetProjectileDefID = SpringShared.GetProjectileDefID +local spGetGroundHeight = SpringShared.GetGroundHeight +local spIsSphereInView = SpringUnsynced.IsSphereInView +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spValidUnitID = SpringShared.ValidUnitID -- Weak: -local spIsGUIHidden = Spring.IsGUIHidden +local spIsGUIHidden = SpringUnsynced.IsGUIHidden local math_max = mathMax local math_ceil = mathCeil @@ -769,7 +769,7 @@ for wdid, wd in pairs(WeaponDefs) do end function widget:VisibleExplosion(px, py, pz, weaponID, ownerID) - if targetable[weaponID] and py - 7300 > Spring.GetGroundHeight(px, pz) then -- dont add distortion to (likely) intercepted explosions (mainly to curb nuke flashes) + if targetable[weaponID] and py - 7300 > SpringShared.GetGroundHeight(px, pz) then -- dont add distortion to (likely) intercepted explosions (mainly to curb nuke flashes) return end if explosionDistortions[weaponID] then @@ -1071,8 +1071,8 @@ end local function PrintProjectileInfo(projectileID) local px, py, pz = spGetProjectilePosition(projectileID) - local weapon, piece = Spring.GetProjectileType(projectileID) - local weaponDefID = weapon and Spring.GetProjectileDefID(projectileID) + local weapon, piece = SpringShared.GetProjectileType(projectileID) + local weaponDefID = weapon and SpringShared.GetProjectileDefID(projectileID) Spring.Debug.TraceFullEcho() end diff --git a/luaui/Widgets/gfx_dof.lua b/luaui/Widgets/gfx_dof.lua index 6c6bbce7f2e..6a6a85fe78a 100644 --- a/luaui/Widgets/gfx_dof.lua +++ b/luaui/Widgets/gfx_dof.lua @@ -14,7 +14,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local highQuality = true -- doesnt seem to do anything local autofocus = true @@ -30,7 +30,7 @@ local autofocusFocalLength = 0.03 -- Autofocus Focal Length -- Engine Functions ----------------------------------------------------------------- -local spGetCameraPosition = Spring.GetCameraPosition +local spGetCameraPosition = SpringUnsynced.GetCameraPosition local math_max = math.max local math_log = math.log @@ -135,7 +135,7 @@ local shaderPasses = { } function InitTextures() - vsx, vsy, vpx, vpy = Spring.GetViewGeometry() + vsx, vsy, vpx, vpy = SpringUnsynced.GetViewGeometry() local blurTexSizeX, blurTexSizeY = vsx / 2, vsy / 2 CleanupTextures() @@ -382,7 +382,7 @@ end local function FilterCalculation() local cpx, cpy, cpz = spGetCameraPosition() - local gmin, gmax = Spring.GetGroundExtremes() + local gmin, gmax = SpringShared.GetGroundExtremes() local effectiveHeight = cpy - math_max(0, gmin) cpy = 3.5 * math_sqrt(effectiveHeight) * math_log(effectiveHeight) glUniform(eyePosLoc, cpx, cpy, cpz) @@ -480,7 +480,7 @@ function widget:DrawScreenEffects() glCopyToTexture(screenTex, 0, 0, vpx, vpy, vsx, vsy) -- the original screen image glCopyToTexture(depthTex, 0, 0, vpx, vpy, vsx, vsy) -- the original screen image - local mx, my = Spring.GetMouseState() + local mx, my = SpringUnsynced.GetMouseState() glUseShader(dofShader) glUniform(distanceLimitsLoc, gl.GetViewRange()) diff --git a/luaui/Widgets/gfx_glass.lua b/luaui/Widgets/gfx_glass.lua index 7ce5b8a1edd..134687e302b 100644 --- a/luaui/Widgets/gfx_glass.lua +++ b/luaui/Widgets/gfx_glass.lua @@ -1,4 +1,4 @@ -if gl.CreateShader == nil or Spring.GetSpectatingState() then +if gl.CreateShader == nil or SpringUnsynced.GetSpectatingState() then return end @@ -15,7 +15,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -- Shameless port from https://gist.github.com/martymcmodding/30304c4bffa6e2bd2eb59ff8bb09d135 @@ -287,27 +287,27 @@ function widget:Shutdown() end function widget:PlayerChanged() - if Spring.GetSpectatingState() then + if SpringUnsynced.GetSpectatingState() then widgetHandler:RemoveWidget() end end -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() local myteamid = Spring.GetMyTeamID() local effectOn = false local effectStart = 0 function widget:FeatureDestroyed(featureID, allyTeam) - if allyTeam == gaiaTeamID and glasstriggerfeaturedefsids[Spring.GetFeatureDefID(featureID)] then - local fx, fy, fz = Spring.GetFeaturePosition(featureID) - local featureHealth = Spring.GetFeatureHealth(featureID) - local mr, mm, er, em, rl = Spring.GetFeatureResources(featureID) + if allyTeam == gaiaTeamID and glasstriggerfeaturedefsids[SpringShared.GetFeatureDefID(featureID)] then + local fx, fy, fz = SpringShared.GetFeaturePosition(featureID) + local featureHealth = SpringShared.GetFeatureHealth(featureID) + local mr, mm, er, em, rl = SpringShared.GetFeatureResources(featureID) spEcho("Reclaiming that was probably not a good idea...", featureHealth, mr, mm, er, em, rl) if featureHealth > 0 and er == 0 then - local unitsnearby = Spring.GetUnitsInCylinder(fx, fz, 170, myteamid) + local unitsnearby = SpringShared.GetUnitsInCylinder(fx, fz, 170, myteamid) for i, unitID in ipairs(unitsnearby) do --spEcho("nearby", unitID) - local unitDefID = Spring.GetUnitDefID(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) --spEcho("nearby", unitID, UnitDefs[unitDefID].name) if UnitDefs[unitDefID].name == "armcom" or UnitDefs[unitDefID].name == "corcom" then if effectOn == false then @@ -348,7 +348,7 @@ function widget:DrawScreenEffects() glTexture(0, screenCopyTex) glBlending(true) glassShader:Activate() - glassShader:SetUniform("iTime", 0.01 * Spring.GetGameFrame()) + glassShader:SetUniform("iTime", 0.01 * SpringShared.GetGameFrame()) glassShader:SetUniform("strength", strength) fullTexQuad:DrawArrays(GL.TRIANGLES, 3) glassShader:Deactivate() diff --git a/luaui/Widgets/gfx_guishader.lua b/luaui/Widgets/gfx_guishader.lua index cf170c85eef..4f893417eb8 100644 --- a/luaui/Widgets/gfx_guishader.lua +++ b/luaui/Widgets/gfx_guishader.lua @@ -21,12 +21,12 @@ local mathMax = math.max local stringFind = string.find -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry -local spIsGUIHidden = Spring.IsGUIHidden -local spGetConfigFloat = Spring.GetConfigFloat +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spIsGUIHidden = SpringUnsynced.IsGUIHidden +local spGetConfigFloat = SpringUnsynced.GetConfigFloat -local uiOpacity = Spring.GetConfigFloat("ui_opacity", 0.7) +local uiOpacity = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7) local uiOpacityCheckFrame = 0 -- hardware capability @@ -134,7 +134,7 @@ local function DrawStencilTexture(world, fullscreen) }) if usedStencilTex == nil then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "guishader api: texture error") + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "guishader api: texture error") widgetHandler:RemoveWidget() return false end @@ -330,7 +330,7 @@ local function CreateShaders() }, "guishader blurShader") if not blurShader:Initialize() then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "guishader blurShader: shader error: " .. gl.GetShaderLog()) + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "guishader blurShader: shader error: " .. gl.GetShaderLog()) widgetHandler:RemoveWidget() return false end @@ -344,7 +344,7 @@ local function CreateShaders() }) if screencopyUI == nil then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "guishader api: texture error") + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "guishader api: texture error") widgetHandler:RemoveWidget() return false end diff --git a/luaui/Widgets/gfx_highlight_commander_wrecks.lua b/luaui/Widgets/gfx_highlight_commander_wrecks.lua index 41ddd395db6..fb4744353ff 100644 --- a/luaui/Widgets/gfx_highlight_commander_wrecks.lua +++ b/luaui/Widgets/gfx_highlight_commander_wrecks.lua @@ -27,11 +27,11 @@ local DEFAULT_COLOR = { 0.9, 0.5, 1, DEFAULT_OPACITY } local highlightUnitNames = {} local prevMapDrawMode, prevSpectatingFullView -local SpringGetAllFeatures = Spring.GetAllFeatures -local SpringGetFeatureResurrect = Spring.GetFeatureResurrect -local SpringGetFeatureTeam = Spring.GetFeatureTeam -local SpringGetSpectatingState = Spring.GetSpectatingState -local SpringGetMapDrawMode = Spring.GetMapDrawMode +local SpringGetAllFeatures = SpringShared.GetAllFeatures +local SpringGetFeatureResurrect = SpringShared.GetFeatureResurrect +local SpringGetFeatureTeam = SpringShared.GetFeatureTeam +local SpringGetSpectatingState = SpringUnsynced.GetSpectatingState +local SpringGetMapDrawMode = SpringUnsynced.GetMapDrawMode -- util @@ -180,16 +180,16 @@ local function shouldHighlight(unitName) end local function addHighlight(featureID, noUpload) - local m, dm, e, de, rl, rt = Spring.GetFeatureResources(featureID) + local m, dm, e, de, rl, rt = SpringShared.GetFeatureResources(featureID) if m > 0 then - local x, y, z = Spring.GetFeaturePosition(featureID) - y = Spring.GetGroundHeight(x, z) - 50 --account for deformable terrain + local x, y, z = SpringShared.GetFeaturePosition(featureID) + y = SpringShared.GetGroundHeight(x, z) - 50 --account for deformable terrain local color = DEFAULT_COLOR if useTeamColor then local featureTeamID = SpringGetFeatureTeam(featureID) if featureTeamID ~= nil then - local r, g, b = Spring.GetTeamColor(featureTeamID) + local r, g, b = SpringUnsynced.GetTeamColor(featureTeamID) color = { r, g, b, DEFAULT_OPACITY } end end @@ -236,7 +236,7 @@ local function checkAllFeatures() end function widget:DrawWorld() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if instanceVBO.usedElements == 0 then diff --git a/luaui/Widgets/gfx_limit_idle_fps.lua b/luaui/Widgets/gfx_limit_idle_fps.lua index a974551c925..2ab75193d71 100644 --- a/luaui/Widgets/gfx_limit_idle_fps.lua +++ b/luaui/Widgets/gfx_limit_idle_fps.lua @@ -14,15 +14,15 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetMouseState = Spring.GetMouseState -local spGetCameraPosition = Spring.GetCameraPosition +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetCameraPosition = SpringUnsynced.GetCameraPosition local offscreenDelay = 3 -local idleDelay = Spring.GetConfigInt("LimitIdleFpsDelay", 60) -local vsyncValueActive = Spring.GetConfigInt("VSyncGame", -1) * Spring.GetConfigInt("VSyncFraction", 1) -local vsyncValueIdle = Spring.GetConfigInt("IdleFpsDivider", 4) -- sometimes vsync > 4 doesnt work at all +local idleDelay = SpringUnsynced.GetConfigInt("LimitIdleFpsDelay", 60) +local vsyncValueActive = SpringUnsynced.GetConfigInt("VSyncGame", -1) * SpringUnsynced.GetConfigInt("VSyncFraction", 1) +local vsyncValueIdle = SpringUnsynced.GetConfigInt("IdleFpsDivider", 4) -- sometimes vsync > 4 doesnt work at all -local limitFpsWhenIdle = Spring.GetConfigInt("LimitIdleFps", 0) == 1 +local limitFpsWhenIdle = SpringUnsynced.GetConfigInt("LimitIdleFps", 0) == 1 local restrictFps = false local lastUserInputTime = os.clock() @@ -32,7 +32,7 @@ local lastMouseOffScreen = false local chobbyInterface = false function widget:Shutdown() - Spring.SetConfigInt("VSync", vsyncValueActive) + SpringUnsynced.SetConfigInt("VSync", vsyncValueActive) WG["limitidlefps"] = nil end @@ -42,7 +42,7 @@ function widget:RecvLuaMsg(msg, playerID) lastUserInputTime = os.clock() if chobbyInterface then restrictFps = false - Spring.SetConfigInt("VSync", (restrictFps and vsyncValueIdle or vsyncValueActive)) + SpringUnsynced.SetConfigInt("VSync", (restrictFps and vsyncValueIdle or vsyncValueActive)) end end end @@ -62,12 +62,12 @@ function widget:Update(dt) sec = sec + dt if sec > 2 then sec = 0 - vsyncValueActive = Spring.GetConfigInt("VSyncGame", -1) * Spring.GetConfigInt("VSyncFraction", 1) - limitFpsWhenIdle = Spring.GetConfigInt("LimitIdleFps", 0) == 1 - idleDelay = Spring.GetConfigInt("LimitIdleFpsDelay", 40) + vsyncValueActive = SpringUnsynced.GetConfigInt("VSyncGame", -1) * SpringUnsynced.GetConfigInt("VSyncFraction", 1) + limitFpsWhenIdle = SpringUnsynced.GetConfigInt("LimitIdleFps", 0) == 1 + idleDelay = SpringUnsynced.GetConfigInt("LimitIdleFpsDelay", 40) end -- detect change by user - local curVsync = Spring.GetConfigInt("VSync", 1) + local curVsync = SpringUnsynced.GetConfigInt("VSync", 1) if curVsync ~= vsyncValueIdle and curVsync ~= vsyncValueActive then vsyncValueActive = curVsync end @@ -98,7 +98,7 @@ function widget:Update(dt) restrictFps = false end if restrictFps ~= prevRestrictFps then - Spring.SetConfigInt("VSync", (restrictFps and vsyncValueIdle or vsyncValueActive)) + SpringUnsynced.SetConfigInt("VSync", (restrictFps and vsyncValueIdle or vsyncValueActive)) end end end diff --git a/luaui/Widgets/gfx_los_colors.lua b/luaui/Widgets/gfx_los_colors.lua index 64c4eaaca5d..0b7361d8542 100644 --- a/luaui/Widgets/gfx_los_colors.lua +++ b/luaui/Widgets/gfx_los_colors.lua @@ -46,7 +46,7 @@ local losColorsWithoutRadars = { } local always, LOS, radar, jam, radar2 -local spSetLosViewColors = Spring.SetLosViewColors +local spSetLosViewColors = SpringUnsynced.SetLosViewColors local function applyOpacity(colors) local newColors = table.copy(colors) @@ -122,7 +122,7 @@ end function widget:PlayerChanged(playerID) if playerID == Spring.GetMyPlayerID() then - if Spring.GetSpectatingState() then + if SpringUnsynced.GetSpectatingState() then specDetected = true if losWithRadarEnabled then withRadars() @@ -157,7 +157,7 @@ function widget:Initialize() end end - always, LOS, radar, jam, radar2 = Spring.GetLosViewColors() + always, LOS, radar, jam, radar2 = SpringUnsynced.GetLosViewColors() if losWithRadarEnabled == true then setLosWithRadars() diff --git a/luaui/Widgets/gfx_los_view.lua b/luaui/Widgets/gfx_los_view.lua index d8e536c91f0..190a15f58cc 100644 --- a/luaui/Widgets/gfx_los_view.lua +++ b/luaui/Widgets/gfx_los_view.lua @@ -14,21 +14,21 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spGetSpectatingState = Spring.GetSpectatingState +local spGetGameFrame = SpringShared.GetGameFrame +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local myPlayerID = Spring.GetMyPlayerID() -local lastMapDrawMode = Spring.GetMapDrawMode() +local lastMapDrawMode = SpringUnsynced.GetMapDrawMode() local function TurnOnLOS() - if Spring.GetMapDrawMode() ~= "los" then - Spring.SendCommands("togglelos") + if SpringUnsynced.GetMapDrawMode() ~= "los" then + SpringUnsynced.SendCommands("togglelos") end end local function TurnOffLOS() - if Spring.GetMapDrawMode() == "los" then - Spring.SendCommands("togglelos") + if SpringUnsynced.GetMapDrawMode() == "los" then + SpringUnsynced.SendCommands("togglelos") end end @@ -70,7 +70,7 @@ function widget:PlayerChanged(playerID) end function widget:GetConfigData() --save config - return { lastMapDrawMode = Spring.GetMapDrawMode() } + return { lastMapDrawMode = SpringUnsynced.GetMapDrawMode() } end function widget:SetConfigData(data) --load config diff --git a/luaui/Widgets/gfx_map_lights.lua b/luaui/Widgets/gfx_map_lights.lua index 4447a6ab8a4..4a7a0e4781f 100644 --- a/luaui/Widgets/gfx_map_lights.lua +++ b/luaui/Widgets/gfx_map_lights.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -- a table of lights -- Important: the A param is a multiplier to the power of the light (mults RGB). diff --git a/luaui/Widgets/gfx_norush_timer_gl4.lua b/luaui/Widgets/gfx_norush_timer_gl4.lua index c4779e3e84a..a4f382d0aa3 100644 --- a/luaui/Widgets/gfx_norush_timer_gl4.lua +++ b/luaui/Widgets/gfx_norush_timer_gl4.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -- spEcho(Spring.GetTeamInfo(Spring.GetMyTeamID())) @@ -23,7 +23,7 @@ local pveAllyTeamID = Spring.Utilities.GetScavAllyTeamID() or Spring.Utilities.G local autoReload = false -- refresh shader code every second (disable in production!) local StartBoxes = {} -- list of xXyY -local noRushTime = Spring.GetModOptions().norushtimer * 60 * 30 +local noRushTime = SpringShared.GetModOptions().norushtimer * 60 * 30 if noRushTime == 0 then return end @@ -31,14 +31,14 @@ end local LuaShader = gl.LuaShader local InstanceVBOTable = gl.InstanceVBOTable -local minY, maxY = Spring.GetGroundExtremes() +local minY, maxY = SpringShared.GetGroundExtremes() local shaderSourceCache = { vssrcpath = "LuaUI/Shaders/norush_timer.vert.glsl", fssrcpath = "LuaUI/Shaders/norush_timer.frag.glsl", uniformInt = { mapDepths = 0, - noRushTimer = Spring.GetModOptions().norushtimer * 60 * 30, + noRushTimer = SpringShared.GetModOptions().norushtimer * 60 * 30, }, uniformFloat = {}, shaderName = "Norush Timer GL4", @@ -56,7 +56,7 @@ local norushTimerShader local glTexture = gl.Texture local glCulling = gl.Culling local glDepthTest = gl.DepthTest -local spIsGUIHidden = Spring.IsGUIHidden +local spIsGUIHidden = SpringUnsynced.IsGUIHidden function widget:RecvLuaMsg(msg, playerID) --spEcho("widget:RecvLuaMsg",msg) @@ -66,7 +66,7 @@ function widget:RecvLuaMsg(msg, playerID) end function widget:DrawWorldPreUnit() - if Spring.GetGameFrame() > noRushTime + 150 then + if SpringShared.GetGameFrame() > noRushTime + 150 then return end if autoReload then @@ -77,7 +77,7 @@ function widget:DrawWorldPreUnit() return end - local _, advMapShading = Spring.HaveAdvShading() + local _, advMapShading = SpringUnsynced.HaveAdvShading() if advMapShading then gl.Texture(0, "$map_gbuffer_zvaltex") @@ -112,12 +112,12 @@ end function widget:Initialize() local gaiaAllyTeamID - if Spring.GetGaiaTeamID() then - gaiaAllyTeamID = select(6, Spring.GetTeamInfo(Spring.GetGaiaTeamID(), false)) + if SpringShared.GetGaiaTeamID() then + gaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(SpringShared.GetGaiaTeamID(), false)) end - for i, teamID in ipairs(Spring.GetAllyTeamList()) do + for i, teamID in ipairs(SpringShared.GetAllyTeamList()) do if teamID ~= gaiaAllyTeamID and teamID ~= pveAllyTeamID then - local xn, zn, xp, zp = Spring.GetAllyTeamStartBox(teamID) + local xn, zn, xp, zp = SpringShared.GetAllyTeamStartBox(teamID) --spEcho("Allyteam",teamID,"startbox",xn, zn, xp, zp) StartBoxes[#StartBoxes + 1] = { xn, zn, xp, zp } end diff --git a/luaui/Widgets/gfx_orb_effects_gl4.lua b/luaui/Widgets/gfx_orb_effects_gl4.lua index 41a321b09c1..9894783aa69 100644 --- a/luaui/Widgets/gfx_orb_effects_gl4.lua +++ b/luaui/Widgets/gfx_orb_effects_gl4.lua @@ -14,10 +14,10 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo -local spGetUnitTeam = Spring.GetUnitTeam +local spGetUnitTeam = SpringShared.GetUnitTeam -------------------------------------------------------------------------------- -- Beherith's notes @@ -871,7 +871,7 @@ function widget:VisibleUnitAdded(unitID, unitDefID, unitTeam, noupload) unitTeam = unitTeam or spGetUnitTeam(unitID) - local _, _, _, _, buildProgress = Spring.GetUnitHealth(unitID) + local _, _, _, _, buildProgress = SpringShared.GetUnitHealth(unitID) if buildProgress < 1 then return end diff --git a/luaui/Widgets/gfx_paralyze_effect.lua b/luaui/Widgets/gfx_paralyze_effect.lua index fd8dab00033..3b267f6bdf8 100644 --- a/luaui/Widgets/gfx_paralyze_effect.lua +++ b/luaui/Widgets/gfx_paralyze_effect.lua @@ -14,11 +14,11 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitHealth = Spring.GetUnitHealth -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo -local spGetAllUnits = Spring.GetAllUnits +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo +local spGetAllUnits = SpringShared.GetAllUnits local LuaShader = gl.LuaShader local InstanceVBOTable = gl.InstanceVBOIdTable @@ -334,7 +334,7 @@ local paralyzeSourceShaderCache = { } --holy hacks batman -if Spring.GetModOptions().emprework then +if SpringShared.GetModOptions().emprework then fsSrc = string.gsub(fsSrc, "//empreworktagdonotremove", "paralysis_level = paralysis_level*3; if (paralysis_level> 1) { paralysis_level = 1; }") fsSrc = string.gsub(fsSrc, "//empreworkherealsodonotremove", "if (paralysis_level > 0.49) { wholeunitbasecolor = vec4(0.35, 0.43, 0.94, 0.18); }") end @@ -380,7 +380,7 @@ local function DrawParalyzedUnitGL4(unitID, unitDefID, red_start, green_start, b if paralyzedDrawUnitVBOTable.instanceIDtoIndex[unitID] then return end -- already got this unit - if Spring.ValidUnitID(unitID) ~= true or Spring.GetUnitIsDead(unitID) == true then + if SpringShared.ValidUnitID(unitID) ~= true or SpringShared.GetUnitIsDead(unitID) == true then return end red_start = red_start or 1.0 @@ -440,7 +440,7 @@ local function init() end function widget:PlayerChanged(playerID) - spec, fullview = Spring.GetSpectatingState() + spec, fullview = SpringUnsynced.GetSpectatingState() local prevMyTeamID = myTeamID myTeamID = Spring.GetMyTeamID() if myTeamID ~= prevMyTeamID then -- TODO only really needed if onlyShowOwnTeam, or if allyteam changed? diff --git a/luaui/Widgets/gfx_sepia_tone.lua b/luaui/Widgets/gfx_sepia_tone.lua index 95feaa8f40f..7a9c3beb347 100644 --- a/luaui/Widgets/gfx_sepia_tone.lua +++ b/luaui/Widgets/gfx_sepia_tone.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo --------------------------------------- @@ -138,7 +138,7 @@ function widget:Initialize() return end - vsx, vsy, vpx, vpy = Spring.GetViewGeometry() + vsx, vsy, vpx, vpy = SpringUnsynced.GetViewGeometry() local commonTexOpts = { target = GL.TEXTURE_2D, diff --git a/luaui/Widgets/gfx_showbuilderqueue.lua b/luaui/Widgets/gfx_showbuilderqueue.lua index 52616eeb711..ac4f6509d75 100644 --- a/luaui/Widgets/gfx_showbuilderqueue.lua +++ b/luaui/Widgets/gfx_showbuilderqueue.lua @@ -17,7 +17,7 @@ end local tableInsert = table.insert -- Localized Spring API for performance -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local shapeOpacity = 0.26 local maxUnitShapes = 4096 @@ -36,7 +36,7 @@ local maxUnitShapes = 4096 local myPlayerId = Spring.GetMyPlayerID() local _, fullView, _ = spGetSpectatingState() -local spGetGroundHeight = Spring.GetGroundHeight +local spGetGroundHeight = SpringShared.GetGroundHeight local halfPi = math.pi / 2 local reInitialize @@ -170,7 +170,7 @@ function widget:PlayerChanged(playerId) end end -local prevGuiHidden = Spring.IsGUIHidden() +local prevGuiHidden = SpringUnsynced.IsGUIHidden() function widget:Update() if not WG.BuilderQueueApi then @@ -179,7 +179,7 @@ function widget:Update() return end - local isGuiHidden = Spring.IsGUIHidden() + local isGuiHidden = SpringUnsynced.IsGUIHidden() if not isGuiHidden then if reInitialize then diff --git a/luaui/Widgets/gfx_snow.lua b/luaui/Widgets/gfx_snow.lua index e75683d6d37..bfcf43e7339 100644 --- a/luaui/Widgets/gfx_snow.lua +++ b/luaui/Widgets/gfx_snow.lua @@ -18,9 +18,9 @@ local mathRandom = math.random local tableInsert = table.insert -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry -------------------------------------------------------------------------------- -- /snow -- toggles snow on current map (also remembers this) @@ -87,10 +87,10 @@ local widgetDisabledSnow = false local shader -local startTimer = Spring.GetTimer() +local startTimer = SpringUnsynced.GetTimer() local diffTime = 0 -local spGetFPS = Spring.GetFPS +local spGetFPS = SpringUnsynced.GetFPS local averageFps = 60 local camX, camY, camZ @@ -116,7 +116,7 @@ local previousParticleAmount = particleDensity -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -local spGetWind = Spring.GetWind +local spGetWind = SpringShared.GetWind local glBlending = gl.Blending local glCallList = gl.CallList @@ -425,23 +425,23 @@ function widget:Shutdown() end local pausedTime = 0 -local lastFrametime = Spring.GetTimer() +local lastFrametime = SpringUnsynced.GetTimer() function widget:DrawWorld() if not enabled then return end - local _, _, isPaused = Spring.GetGameSpeed() + local _, _, isPaused = SpringUnsynced.GetGameSpeed() if isPaused then - pausedTime = pausedTime + Spring.DiffTimers(Spring.GetTimer(), lastFrametime) + pausedTime = pausedTime + SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), lastFrametime) end - lastFrametime = Spring.GetTimer() + lastFrametime = SpringUnsynced.GetTimer() if os.clock() - startOsClock > 0.5 then -- delay to prevent no textures being shown if shader ~= nil and particleLists[#particleTypes] ~= nil and particleLists[#particleTypes][particleStep] ~= nil then shader:Activate() - camX, camY, camZ = Spring.GetCameraPosition() - diffTime = Spring.DiffTimers(lastFrametime, startTimer) - pausedTime + camX, camY, camZ = SpringUnsynced.GetCameraPosition() + diffTime = SpringUnsynced.DiffTimers(lastFrametime, startTimer) - pausedTime shader:SetUniform("time", diffTime) shader:SetUniform("camPos", camX, camY, camZ) diff --git a/luaui/Widgets/gfx_ssao.lua b/luaui/Widgets/gfx_ssao.lua index 57dabfd9432..0fec154b4df 100644 --- a/luaui/Widgets/gfx_ssao.lua +++ b/luaui/Widgets/gfx_ssao.lua @@ -30,9 +30,9 @@ local mathRandom = math.random local mathPi = math.pi -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry -local spGetDrawFrame = Spring.GetDrawFrame +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetDrawFrame = SpringUnsynced.GetDrawFrame -- pre unitStencilTexture it takes 800 ms per frame -- todo: fake more ground ao in blur pass? @@ -140,9 +140,9 @@ local cusMult = 1.4 local strengthMult = 1 local strengthMultCached = 0 -- pre-computed shaderConfig.SSAO_ALPHA_POW / 7.0, updated in InitGL -local initialTonemapA = Spring.GetConfigFloat("tonemapA", 4.75) -local initialTonemapD = Spring.GetConfigFloat("tonemapD", 0.85) -local initialTonemapE = Spring.GetConfigFloat("tonemapE", 1.0) +local initialTonemapA = SpringUnsynced.GetConfigFloat("tonemapA", 4.75) +local initialTonemapD = SpringUnsynced.GetConfigFloat("tonemapD", 0.85) +local initialTonemapE = SpringUnsynced.GetConfigFloat("tonemapE", 1.0) local preset = 3 local presets = { @@ -388,10 +388,10 @@ local function InitGL() -- make unit lighting brighter to compensate for darkening (also restoring values on Shutdown()) if presets[preset].tonemapA then - Spring.SetConfigFloat("tonemapA", initialTonemapA + (presets[preset].tonemapA * ((shaderConfig.SSAO_ALPHA_POW * strengthMult) / 11))) - Spring.SetConfigFloat("tonemapD", initialTonemapD + (presets[preset].tonemapD * ((shaderConfig.SSAO_ALPHA_POW * strengthMult) / 11))) - Spring.SetConfigFloat("tonemapE", initialTonemapE + (presets[preset].tonemapE * ((shaderConfig.SSAO_ALPHA_POW * strengthMult) / 11))) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetConfigFloat("tonemapA", initialTonemapA + (presets[preset].tonemapA * ((shaderConfig.SSAO_ALPHA_POW * strengthMult) / 11))) + SpringUnsynced.SetConfigFloat("tonemapD", initialTonemapD + (presets[preset].tonemapD * ((shaderConfig.SSAO_ALPHA_POW * strengthMult) / 11))) + SpringUnsynced.SetConfigFloat("tonemapE", initialTonemapE + (presets[preset].tonemapE * ((shaderConfig.SSAO_ALPHA_POW * strengthMult) / 11))) + SpringUnsynced.SendCommands("luarules updatesun") end vsx, vsy = spGetViewGeometry() @@ -630,7 +630,7 @@ function widget:Update(dt) sec = sec + dt if sec > 1 then sec = 0 - if Spring.GetConfigInt("cus", 1) == 1 then + if SpringUnsynced.GetConfigInt("cus", 1) == 1 then if WG.disabledCus then strengthMult = 1 else @@ -646,10 +646,10 @@ function widget:Shutdown() -- restore unit lighting settings if presets[preset].tonemapA then - Spring.SetConfigFloat("tonemapA", initialTonemapA) - Spring.SetConfigFloat("tonemapD", initialTonemapD) - Spring.SetConfigFloat("tonemapE", initialTonemapE) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetConfigFloat("tonemapA", initialTonemapA) + SpringUnsynced.SetConfigFloat("tonemapD", initialTonemapD) + SpringUnsynced.SetConfigFloat("tonemapE", initialTonemapE) + SpringUnsynced.SendCommands("luarules updatesun") end if shaderDefinedSlidersLayer and shaderDefinedSlidersLayer.Destroy then @@ -776,10 +776,10 @@ function widget:GetConfigData(data) } end -local lastfps = Spring.GetFPS() +local lastfps = SpringUnsynced.GetFPS() function widget:DrawScreen() if shaderDefinedSlidersLayer then - local newfps = Spring.GetFPS() + local newfps = SpringUnsynced.GetFPS() if ssaoShaderCache.updateFlag then ssaoShaderCache.updateFlag = nil lastfps = newfps diff --git a/luaui/Widgets/gfx_unit_stencil_gl4.lua b/luaui/Widgets/gfx_unit_stencil_gl4.lua index b2e81e23611..76a11208c97 100644 --- a/luaui/Widgets/gfx_unit_stencil_gl4.lua +++ b/luaui/Widgets/gfx_unit_stencil_gl4.lua @@ -14,7 +14,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -- Key Idea: make a 1/2 or 1/4 sized texture 'stencil buffer' that can be used for units and features. -- Draw features first at 0.5, then units at 1.0, clear if no draw happened @@ -198,7 +198,7 @@ local resolution = 4 local vsx, vsy function widget:ViewResize() local GL_R8 = 0x8229 - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() if unitFeatureStencilTex then gl.DeleteTexture(unitFeatureStencilTex) end @@ -320,7 +320,7 @@ function widget:VisibleUnitRemoved(unitID) end function widget:FeatureCreated(featureID, allyTeam) - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) --spEcho(featureDefID, featureID) if featureDimensionsXYZ[featureDefID] == nil then @@ -439,7 +439,7 @@ function widget:Initialize() for unitID, unitDefID in pairs(visibleUnits) do widget:VisibleUnitAdded(unitID, unitDefID) end - for _, featureID in ipairs(Spring.GetAllFeatures()) do + for _, featureID in ipairs(SpringShared.GetAllFeatures()) do widget:FeatureCreated(featureID) end end diff --git a/luaui/Widgets/gfx_volumetric_clouds.lua b/luaui/Widgets/gfx_volumetric_clouds.lua index 88e6b8bdd55..68deabc4d44 100644 --- a/luaui/Widgets/gfx_volumetric_clouds.lua +++ b/luaui/Widgets/gfx_volumetric_clouds.lua @@ -49,7 +49,7 @@ else --error(": no custom defined mapinfo.lua cloud settings found") end -local gnd_min, gnd_max = Spring.GetGroundExtremes() +local gnd_min, gnd_max = SpringShared.GetGroundExtremes() local function convertAltitude(input, default) local result = input @@ -106,9 +106,9 @@ local glCreateTexture = gl.CreateTexture local glDeleteTexture = gl.DeleteTexture local glTexture = gl.Texture local LuaShader = gl.LuaShader -local spGetCameraPosition = Spring.GetCameraPosition -local spGetWind = Spring.GetWind -local spEcho = Spring.Echo +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spGetWind = SpringShared.GetWind +local spEcho = SpringShared.Echo -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -148,7 +148,7 @@ local offsetZ = 0 -------------------------------------------------------------------------------- function widget:ViewResize() - vsx, vsy, vpx, vpy = Spring.GetViewGeometry() + vsx, vsy, vpx, vpy = SpringUnsynced.GetViewGeometry() if depthTexture then glDeleteTexture(depthTexture) @@ -627,7 +627,7 @@ local function DrawFogNew() depthShader:SetUniform("sundir", sunDir[1], sunDir[2], sunDir[3]) depthShader:SetUniform("suncolor", sunCol[1], sunCol[2], sunCol[3]) - depthShader:SetUniform("time", Spring.GetGameSeconds() * speed) + depthShader:SetUniform("time", SpringShared.GetGameSeconds() * speed) depthShader:SetUniformMatrix("viewProjectionInv", "viewprojectioninverse") diff --git a/luaui/Widgets/gui_advplayerslist.lua b/luaui/Widgets/gui_advplayerslist.lua index d9d9c3aa356..90e1ad122ee 100644 --- a/luaui/Widgets/gui_advplayerslist.lua +++ b/luaui/Widgets/gui_advplayerslist.lua @@ -24,10 +24,10 @@ local strUpper = string.upper local osClock = os.clock -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spGetMouseState = Spring.GetMouseState -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState +local spGetGameFrame = SpringShared.GetGameFrame +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState --[[Changelog before v8.0 developed outside of BA by Marmoth @@ -103,25 +103,25 @@ local AdvPlayersListAtlas -------------------------------------------------------------------------------- local sp = { - GetAllyTeamList = Spring.GetAllyTeamList, - GetTeamInfo = Spring.GetTeamInfo, - GetTeamList = Spring.GetTeamList, - GetPlayerInfo = Spring.GetPlayerInfo, - GetPlayerList = Spring.GetPlayerList, - GetTeamColor = Spring.GetTeamColor, - GetLocalAllyTeamID = Spring.GetLocalAllyTeamID, - GetLocalTeamID = Spring.GetLocalTeamID, - GetLocalPlayerID = Spring.GetLocalPlayerID, - ShareResources = Spring.ShareResources, - GetTeamUnitCount = Spring.GetTeamUnitCount, - GetTeamResources = Spring.GetTeamResources, - SendCommands = Spring.SendCommands, + GetAllyTeamList = SpringShared.GetAllyTeamList, + GetTeamInfo = SpringShared.GetTeamInfo, + GetTeamList = SpringShared.GetTeamList, + GetPlayerInfo = SpringShared.GetPlayerInfo, + GetPlayerList = SpringShared.GetPlayerList, + GetTeamColor = SpringUnsynced.GetTeamColor, + GetLocalAllyTeamID = SpringUnsynced.GetLocalAllyTeamID, + GetLocalTeamID = SpringUnsynced.GetLocalTeamID, + GetLocalPlayerID = SpringUnsynced.GetLocalPlayerID, + ShareResources = SpringUnsynced.ShareResources, + GetTeamUnitCount = SpringShared.GetTeamUnitCount, + GetTeamResources = SpringShared.GetTeamResources, + SendCommands = SpringUnsynced.SendCommands, GetMouseState = spGetMouseState, - GetAIInfo = Spring.GetAIInfo, - GetTeamRulesParam = Spring.GetTeamRulesParam, + GetAIInfo = SpringShared.GetAIInfo, + GetTeamRulesParam = SpringShared.GetTeamRulesParam, GetMyTeamID = Spring.GetMyTeamID, - AreTeamsAllied = Spring.AreTeamsAllied, - GetTeamStatsHistory = Spring.GetTeamStatsHistory, + AreTeamsAllied = SpringShared.AreTeamsAllied, + GetTeamStatsHistory = SpringShared.GetTeamStatsHistory, } local Color = { @@ -214,11 +214,11 @@ local originalColourNames = {} -- loaded in SetOriginalColourNames, format is or local apiAbsPosition = { 0, 0, 0, 0, 1, 1, false } -local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode -local anonymousTeamColor = { Spring.GetConfigInt("anonymousColorR", 255) / 255, Spring.GetConfigInt("anonymousColorG", 0) / 255, Spring.GetConfigInt("anonymousColorB", 0) / 255 } +local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode +local anonymousTeamColor = { SpringUnsynced.GetConfigInt("anonymousColorR", 255) / 255, SpringUnsynced.GetConfigInt("anonymousColorG", 0) / 255, SpringUnsynced.GetConfigInt("anonymousColorB", 0) / 255 } -local sharingTax = Spring.GetModOptions().tax_resource_sharing_amount or 0 -if Spring.GetModOptions().easytax then +local sharingTax = SpringShared.GetModOptions().tax_resource_sharing_amount or 0 +if SpringShared.GetModOptions().easytax then sharingTax = 0.3 -- 30% tax for easytax modoption end @@ -289,11 +289,11 @@ local accountIDLookup = {} -- accountID -> playerID for fast duplicate detection -- local player info local myPlayerID = Spring.GetMyPlayerID() -local myAllyTeamID = Spring.GetLocalAllyTeamID() -local myTeamID = Spring.GetLocalTeamID() -local myTeamPlayerID = select(2, Spring.GetTeamInfo(myTeamID)) +local myAllyTeamID = SpringUnsynced.GetLocalAllyTeamID() +local myTeamID = SpringUnsynced.GetLocalTeamID() +local myTeamPlayerID = select(2, SpringShared.GetTeamInfo(myTeamID)) local mySpecStatus, fullView, _ = spGetSpectatingState() -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() --General players/spectator count and tables local player = {} @@ -321,7 +321,7 @@ local isSinglePlayer = Spring.Utilities.Gametype.IsSinglePlayer() local isSingle = false if not mySpecStatus then - local teamList = Spring.GetTeamList(myAllyTeamID) or {} + local teamList = SpringShared.GetTeamList(myAllyTeamID) or {} isSingle = #teamList == 1 end -------------------------------------------------------------------------------- @@ -567,7 +567,7 @@ m_chat = { } position = position + 1 -local drawAllyButton = not Spring.GetModOptions().fixedallies +local drawAllyButton = not SpringShared.GetModOptions().fixedallies m_alliance = { name = "ally", @@ -620,7 +620,7 @@ local specsLabelOffset = 0 local enemyLabelOffset = 0 local hideShareIcons = false -local numTeamsInAllyTeam = #Spring.GetTeamList(myAllyTeamID) +local numTeamsInAllyTeam = #SpringShared.GetTeamList(myAllyTeamID) if mySpecStatus or numTeamsInAllyTeam <= 1 then hideShareIcons = true @@ -842,9 +842,9 @@ end function widget:PlayerChanged(playerID) myPlayerID = Spring.GetMyPlayerID() - myAllyTeamID = Spring.GetLocalAllyTeamID() - myTeamID = Spring.GetLocalTeamID() - myTeamPlayerID = select(2, Spring.GetTeamInfo(myTeamID)) + myAllyTeamID = SpringUnsynced.GetLocalAllyTeamID() + myTeamID = SpringUnsynced.GetLocalTeamID() + myTeamPlayerID = select(2, SpringShared.GetTeamInfo(myTeamID)) -- UNTESTED: reset original color names for the player, cause they can be wrong depending on the anonymous mode if anonymousMode and playerID == myPlayerID and not mySpecStatus and spGetSpectatingState() then SetOriginalColourNames() @@ -952,8 +952,8 @@ function widget:Initialize() specListShow = false end end - if Spring.GetConfigInt("ShowPlayerInfo") == 1 then - Spring.SendCommands("info 0") + if SpringUnsynced.GetConfigInt("ShowPlayerInfo") == 1 then + SpringUnsynced.SendCommands("info 0") end if spGetGameFrame() > 0 then @@ -1091,9 +1091,9 @@ end function SetSidePics() --record readyStates - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for _, playerID in pairs(playerList) do - playerReadyState[playerID] = Spring.GetGameRulesParam("player_" .. tostring(playerID) .. "_readyState") + playerReadyState[playerID] = SpringShared.GetGameRulesParam("player_" .. tostring(playerID) .. "_readyState") end --set factions, from TeamRulesParam when possible and from initial info if not @@ -1186,7 +1186,7 @@ function round(num, idp) end function GetSkill(playerID) - local customtable = select(11, Spring.GetPlayerInfo(playerID)) + local customtable = select(11, SpringShared.GetPlayerInfo(playerID)) local osMu = customtable.skill local osSigma = customtable.skilluncertainty local osSkill = "" @@ -1300,7 +1300,7 @@ function CreatePlayer(playerID) energy = energy, energyStorage = energyStorage, energyShare = energyShare, - energyConversion = Spring.GetTeamRulesParam(tteam, "mmLevel"), + energyConversion = SpringShared.GetTeamRulesParam(tteam, "mmLevel"), metal = metal, metalStorage = metalStorage, metalShare = metalShare, @@ -1313,7 +1313,7 @@ end function GetAIName(teamID) local _, _, _, name, _, options = sp.GetAIInfo(teamID) - local niceName = Spring.GetGameRulesParam("ainame_" .. teamID) + local niceName = SpringShared.GetGameRulesParam("ainame_" .. teamID) if niceName then name = niceName @@ -1343,7 +1343,7 @@ function CreatePlayerFromTeam(teamID) tdead = false tai = true else - if Spring.GetGameSeconds() < 0.1 then + if SpringShared.GetGameSeconds() < 0.1 then tname = absentName ttotake = false tdead = false @@ -1392,7 +1392,7 @@ function CreatePlayerFromTeam(teamID) energy = energy, energyStorage = energyStorage, energyShare = energyShare, - energyConversion = Spring.GetTeamRulesParam(teamID, "mmLevel"), + energyConversion = SpringShared.GetTeamRulesParam(teamID, "mmLevel"), metal = metal, metalStorage = metalStorage, metalShare = metalShare, @@ -1435,7 +1435,7 @@ function UpdatePlayerResources() p.metalStorage = metalStorage p.metalShare = metalShare if not p.spec then - p.energyConversion = Spring.GetTeamRulesParam(p.team, "mmLevel") + p.energyConversion = SpringShared.GetTeamRulesParam(p.team, "mmLevel") end local pAllyteam = p.allyteam if not allyTeamMaxStorage[pAllyteam] then @@ -1519,7 +1519,7 @@ function SortList() playerScale = playerScale - 0.05 - (playerScale * ((#sp.GetAllyTeamList() - 2) / 200)) -- reduce size some more when mega ffa end if playerScale < 0.9 then - playerScale = playerScale - (playerScale * (Spring.GetConfigFloat("ui_scale", 1) - 1)) + playerScale = playerScale - (playerScale * (SpringUnsynced.GetConfigFloat("ui_scale", 1) - 1)) end -- calls the (cascade) sorting for players @@ -2776,8 +2776,8 @@ function DrawName(name, nameIsAlias, team, posY, dark, playerID, accountID, desy local isAbsent = false if name == absentName then isAbsent = true - local teamPlayerID = select(2, Spring.GetTeamInfo(team, false)) - local playerName = Spring.GetPlayerInfo(teamPlayerID, false) + local teamPlayerID = select(2, SpringShared.GetTeamInfo(team, false)) + local playerName = SpringShared.GetPlayerInfo(teamPlayerID, false) playerName = (WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(teamPlayerID) or playerName if playerName then --and aliveAllyTeams[player[playerID].allyteam] then name = player[playerID].name @@ -2786,9 +2786,9 @@ function DrawName(name, nameIsAlias, team, posY, dark, playerID, accountID, desy if not gameStarted then if playerID >= specOffset then - willSub = (Spring.GetGameRulesParam("Player" .. (playerID - specOffset) .. "willSub") == 1) and " (sub)" or "" --pID-specOffset because apl uses dummy playerIDs for absent players + willSub = (SpringShared.GetGameRulesParam("Player" .. (playerID - specOffset) .. "willSub") == 1) and " (sub)" or "" --pID-specOffset because apl uses dummy playerIDs for absent players else - willSub = (Spring.GetGameRulesParam("Player" .. playerID .. "willSub") == 1) and " (sub)" or "" + willSub = (SpringShared.GetGameRulesParam("Player" .. playerID .. "willSub") == 1) and " (sub)" or "" end end @@ -3056,7 +3056,7 @@ function NameTip(mouseX, playerID, accountID, nameIsAlias) local text = "" local c = 0 - local pname = Spring.GetPlayerInfo(playerID, false) + local pname = SpringShared.GetPlayerInfo(playerID, false) for i, name in ipairs(pTip.history) do if pTip.name ~= name then if c > 0 then @@ -3319,7 +3319,7 @@ function widget:MousePress(x, y, button) end if button == 1 then - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() sliderPosition = nil shareAmount = 0 @@ -3362,7 +3362,7 @@ function widget:MousePress(x, y, button) if clickedPlayer.pointTime ~= nil then if IsOnRect(x, y, widgetPosX - 33, posY - 2, widgetPosX - 17, posY + (playerOffset * playerScale)) then --point button - Spring.SetCameraTarget(clickedPlayer.pointX, clickedPlayer.pointY, clickedPlayer.pointZ, 1) + SpringUnsynced.SetCameraTarget(clickedPlayer.pointX, clickedPlayer.pointY, clickedPlayer.pointZ, 1) return true end end @@ -3427,10 +3427,10 @@ function widget:MousePress(x, y, button) if release >= now then if clickedPlayer.team == myTeamID then --sp.SendCommands("say a: " .. Spring.I18N('ui.playersList.chat.needSupport')) - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.needSupport") + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.needSupport") else sp.ShareResources(clickedPlayer.team, "units") - Spring.PlaySoundFile("beep4", 1, "ui") + SpringUnsynced.PlaySoundFile("beep4", 1, "ui") end end release = nil @@ -3480,7 +3480,7 @@ function widget:MousePress(x, y, button) if clickedPlayer.pointTime ~= nil then if clickedPlayer.allyteam == myAllyTeamID then if IsOnRect(x, y, widgetPosX - 28, posY - 1, widgetPosX - 12, posY + 17) then - Spring.SetCameraTarget(clickedPlayer.pointX, clickedPlayer.pointY, clickedPlayer.pointZ, 1) + SpringUnsynced.SetCameraTarget(clickedPlayer.pointX, clickedPlayer.pointY, clickedPlayer.pointZ, 1) return true end end @@ -3541,7 +3541,7 @@ function widget:MouseMove(x, y, dx, dy, button) UpdateResources() if playSounds and (lastSliderSound == nil or osClock() - lastSliderSound > 0.05) and shareAmount ~= prevAmountEM then lastSliderSound = osClock() - Spring.PlaySoundFile(sliderdrag, 0.3, "ui") + SpringUnsynced.PlaySoundFile(sliderdrag, 0.3, "ui") end end end @@ -3558,22 +3558,22 @@ function widget:MouseRelease(x, y, button) if energyPlayer ~= nil then -- share energy/metal mouse release if energyPlayer.team == myTeamID then - Spring.SendLuaUIMsg("alert:allyRequest:energy", "allies") + SpringUnsynced.SendLuaUIMsg("alert:allyRequest:energy", "allies") if shareAmount == 0 then --sp.SendCommands("say a:" .. Spring.I18N('ui.playersList.chat.needEnergy')) - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.needEnergy") + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.needEnergy") else --sp.SendCommands("say a:" .. Spring.I18N('ui.playersList.chat.needEnergyAmount', { amount = shareAmount })) - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.needEnergyAmount:amount=" .. shareAmount) + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.needEnergyAmount:amount=" .. shareAmount) end elseif shareAmount > 0 then sp.ShareResources(energyPlayer.team, "energy", shareAmount) --sp.SendCommands("say a:" .. Spring.I18N('ui.playersList.chat.giveEnergy', { amount = shareAmount, name = energyPlayer.name })) if sharingTax and sharingTax > 0 then local amount2 = mathFloor(shareAmount * (1 - sharingTax)) - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.giveEnergy_taxed:amount=" .. shareAmount .. ":name=" .. (energyPlayer.orgname or energyPlayer.name) .. ":amount2=" .. amount2) + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.giveEnergy_taxed:amount=" .. shareAmount .. ":name=" .. (energyPlayer.orgname or energyPlayer.name) .. ":amount2=" .. amount2) else - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.giveEnergy:amount=" .. shareAmount .. ":name=" .. (energyPlayer.orgname or energyPlayer.name)) + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.giveEnergy:amount=" .. shareAmount .. ":name=" .. (energyPlayer.orgname or energyPlayer.name)) end WG.sharedEnergyFrame = spGetGameFrame() end @@ -3586,22 +3586,22 @@ function widget:MouseRelease(x, y, button) if metalPlayer ~= nil and shareAmount then if metalPlayer.team == myTeamID then - Spring.SendLuaUIMsg("alert:allyRequest:metal", "allies") + SpringUnsynced.SendLuaUIMsg("alert:allyRequest:metal", "allies") if shareAmount == 0 then --sp.SendCommands("say a:" .. Spring.I18N('ui.playersList.chat.needMetal')) - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.needMetal") + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.needMetal") else --sp.SendCommands("say a:" .. Spring.I18N('ui.playersList.chat.needMetalAmount', { amount = shareAmount })) - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.needMetalAmount:amount=" .. shareAmount) + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.needMetalAmount:amount=" .. shareAmount) end elseif shareAmount > 0 then sp.ShareResources(metalPlayer.team, "metal", shareAmount) --sp.SendCommands("say a:" .. Spring.I18N('ui.playersList.chat.giveMetal', { amount = shareAmount, name = metalPlayer.name })) if sharingTax and sharingTax > 0 then local amount2 = mathFloor(shareAmount * (1 - sharingTax)) - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.giveMetal_taxed:amount=" .. shareAmount .. ":name=" .. (metalPlayer.orgname or metalPlayer.name) .. ":amount2=" .. amount2) + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.giveMetal_taxed:amount=" .. shareAmount .. ":name=" .. (metalPlayer.orgname or metalPlayer.name) .. ":amount2=" .. amount2) else - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.giveMetal:amount=" .. shareAmount .. ":name=" .. (metalPlayer.orgname or metalPlayer.name)) + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.giveMetal:amount=" .. shareAmount .. ":name=" .. (metalPlayer.orgname or metalPlayer.name)) end WG.sharedMetalFrame = spGetGameFrame() end @@ -3615,12 +3615,12 @@ function widget:MouseRelease(x, y, button) end function Spec(teamID) - local oldMapDrawMode = Spring.GetMapDrawMode() + local oldMapDrawMode = SpringUnsynced.GetMapDrawMode() sp.SendCommands("specteam " .. teamID) -- restore current los drawmode (doing specteam makes it non normal non los view) - local newMapDrawMode = Spring.GetMapDrawMode() + local newMapDrawMode = SpringUnsynced.GetMapDrawMode() if oldMapDrawMode == "los" and oldMapDrawMode ~= newMapDrawMode then - Spring.SendCommands("togglelos") + SpringUnsynced.SendCommands("togglelos") end SortList() end @@ -3949,7 +3949,7 @@ function widget:Update(delta) if tipText and WG["tooltip"] then WG["tooltip"].ShowTooltip("advplayerlist", tipText, nil, nil, tipTextTitle) end - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end lockPlayerID = WG.lockcamera and WG.lockcamera.GetPlayerID() or false @@ -3972,7 +3972,7 @@ function widget:Update(delta) if scheduledSpecFullView ~= nil then -- this is needed else the minimap/world doesnt update properly - Spring.SendCommands("specfullview") + SpringUnsynced.SendCommands("specfullview") scheduledSpecFullView = scheduledSpecFullView - 1 if scheduledSpecFullView == 0 then scheduledSpecFullView = nil @@ -3997,9 +3997,9 @@ function widget:Update(delta) end end if detailedToSay then - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.takeTeam:name=" .. tookTeamName .. ":units=" .. mathFloor(afterU) .. ":energy=" .. mathFloor(afterE) .. ":metal=" .. mathFloor(afterE)) + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.takeTeam:name=" .. tookTeamName .. ":units=" .. mathFloor(afterU) .. ":energy=" .. mathFloor(afterE) .. ":metal=" .. mathFloor(afterE)) else - Spring.SendLuaRulesMsg("msg:ui.playersList.chat.takeTeam:name=" .. tookTeamName) + SpringUnsynced.SendLuaRulesMsg("msg:ui.playersList.chat.takeTeam:name=" .. tookTeamName) end for j = 0, (specOffset * 2) - 1 do @@ -4055,7 +4055,7 @@ function updateWidgetScale() end local prevWidgetScale = widgetScale widgetScale = (vsy / 980) * (1 + ((vsx / vsy) * 0.065)) * customScale - widgetScale = widgetScale * (1 + (Spring.GetConfigFloat("ui_scale", 1) - 1) / 1.25) + widgetScale = widgetScale * (1 + (SpringUnsynced.GetConfigFloat("ui_scale", 1) - 1) / 1.25) if prevWidgetScale ~= widgetScale then prevWidgetScale = widgetScale forceMainListRefresh = true diff --git a/luaui/Widgets/gui_advplayerslist_gameinfo.lua b/luaui/Widgets/gui_advplayerslist_gameinfo.lua index 417a612cdee..fc43baccc1c 100644 --- a/luaui/Widgets/gui_advplayerslist_gameinfo.lua +++ b/luaui/Widgets/gui_advplayerslist_gameinfo.lua @@ -16,8 +16,8 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spGetViewGeometry = Spring.GetViewGeometry +local spGetGameFrame = SpringShared.GetGameFrame +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local timeNotation = 24 @@ -56,7 +56,7 @@ local function drawContent() local textsize = 11 * widgetScale * math.clamp(1 + ((1 - (vsy / 1200)) * 0.4), 1, 1.15) local textXPadding = 10 * widgetScale - local fps = Spring.GetFPS() + local fps = SpringUnsynced.GetFPS() local titleColor = "\255\210\210\210" local valueColor = "\255\245\245\245" local minutes = mathFloor((gameframe / 30 / 60)) @@ -137,7 +137,7 @@ local function updatePosition(force) elseif WG["advplayerlist_api"] then advplayerlistPos = WG["advplayerlist_api"].GetPosition() else - local scale = (vsy / 880) * (1 + (Spring.GetConfigFloat("ui_scale", 1) - 1) / 1.25) + local scale = (vsy / 880) * (1 + (SpringUnsynced.GetConfigFloat("ui_scale", 1) - 1) / 1.25) advplayerlistPos = { 0, vsx - (220 * scale), 0, vsx, scale } end if advplayerlistPos[5] ~= nil then @@ -159,9 +159,9 @@ function widget:Initialize() WG["displayinfo"].GetPosition = function() return { top, left, bottom, right, widgetScale } end - Spring.SendCommands("fps 0") - Spring.SendCommands("clock 0") - Spring.SendCommands("speed 0") + SpringUnsynced.SendCommands("fps 0") + SpringUnsynced.SendCommands("clock 0") + SpringUnsynced.SendCommands("speed 0") end function widget:Shutdown() @@ -182,9 +182,9 @@ function widget:Shutdown() gl.DeleteTexture(uiTex) uiTex = nil end - Spring.SendCommands("fps 1") - Spring.SendCommands("clock 1") - Spring.SendCommands("speed 1") + SpringUnsynced.SendCommands("fps 1") + SpringUnsynced.SendCommands("clock 1") + SpringUnsynced.SendCommands("speed 1") WG["displayinfo"] = nil end diff --git a/luaui/Widgets/gui_advplayerslist_mascot.lua b/luaui/Widgets/gui_advplayerslist_mascot.lua index 70d1588ea2d..dc2d5be61fe 100644 --- a/luaui/Widgets/gui_advplayerslist_mascot.lua +++ b/luaui/Widgets/gui_advplayerslist_mascot.lua @@ -204,7 +204,7 @@ function updatePosition(force) elseif WG["advplayerlist_api"] ~= nil then parentPos = WG["advplayerlist_api"].GetPosition() else - local scale = (vsy / 880) * (1 + (Spring.GetConfigFloat("ui_scale", 1) - 1) / 1.25) + local scale = (vsy / 880) * (1 + (SpringUnsynced.GetConfigFloat("ui_scale", 1) - 1) / 1.25) parentPos = { 0, vsx - (220 * scale), 0, vsx, scale } end if parentPos[5] ~= nil then @@ -287,7 +287,7 @@ end function widget:TextCommand(command) if string.sub(command, 1, 6) == "mascot" then toggleOptions(tonumber(string.sub(command, 8))) - Spring.Echo("Playerlist mascot: " .. OPTIONS[currentOption].name) + SpringShared.Echo("Playerlist mascot: " .. OPTIONS[currentOption].name) end end diff --git a/luaui/Widgets/gui_advplayerslist_music_new.lua b/luaui/Widgets/gui_advplayerslist_music_new.lua index 77eee16e382..a4a6ce423ce 100644 --- a/luaui/Widgets/gui_advplayerslist_music_new.lua +++ b/luaui/Widgets/gui_advplayerslist_music_new.lua @@ -20,22 +20,22 @@ local mathMin = math.min local mathRandom = math.random -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spGetMouseState = Spring.GetMouseState -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState - -Spring.CreateDir("music/custom/loading") -Spring.CreateDir("music/custom/peace") -Spring.CreateDir("music/custom/warlow") -Spring.CreateDir("music/custom/warhigh") -Spring.CreateDir("music/custom/interludes") -Spring.CreateDir("music/custom/bossfight") -Spring.CreateDir("music/custom/victory") -Spring.CreateDir("music/custom/defeat") -Spring.CreateDir("music/custom/gameover") -Spring.CreateDir("music/custom/menu") +local spGetGameFrame = SpringShared.GetGameFrame +local spGetMouseState = SpringUnsynced.GetMouseState +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState + +SpringUnsynced.CreateDir("music/custom/loading") +SpringUnsynced.CreateDir("music/custom/peace") +SpringUnsynced.CreateDir("music/custom/warlow") +SpringUnsynced.CreateDir("music/custom/warhigh") +SpringUnsynced.CreateDir("music/custom/interludes") +SpringUnsynced.CreateDir("music/custom/bossfight") +SpringUnsynced.CreateDir("music/custom/victory") +SpringUnsynced.CreateDir("music/custom/defeat") +SpringUnsynced.CreateDir("music/custom/gameover") +SpringUnsynced.CreateDir("music/custom/menu") ---------------------------------------------------------------------- -- CONFIG @@ -61,10 +61,10 @@ local function applySpectatorThresholds() --spEcho("[Music Player] Spectator mode enabled") end -if spGetSpectatingState() or Spring.IsReplay() then +if spGetSpectatingState() or SpringUnsynced.IsReplay() then victoryConditionAllyID = 999 else - victoryConditionAllyID = Spring.GetLocalAllyTeamID() + victoryConditionAllyID = SpringUnsynced.GetLocalAllyTeamID() end math.randomseed(os.clock()) @@ -100,13 +100,13 @@ local isChangingTrack = false local function ReloadMusicPlaylists() -----------------------------------SETTINGS--------------------------------------- - interruptionEnabled = Spring.GetConfigInt("UseSoundtrackInterruption", 1) == 1 - local newSoundtrackEnabled = Spring.GetConfigInt("UseSoundtrackNew", 1) == 1 - local customSoundtrackEnabled = Spring.GetConfigInt("UseSoundtrackCustom", 1) == 1 + interruptionEnabled = SpringUnsynced.GetConfigInt("UseSoundtrackInterruption", 1) == 1 + local newSoundtrackEnabled = SpringUnsynced.GetConfigInt("UseSoundtrackNew", 1) == 1 + local customSoundtrackEnabled = SpringUnsynced.GetConfigInt("UseSoundtrackCustom", 1) == 1 - if Spring.GetConfigInt("UseSoundtrackNew", 1) == 0 and Spring.GetConfigInt("UseSoundtrackOld", 0) == 1 then - Spring.SetConfigInt("UseSoundtrackNew", 1) - Spring.SetConfigInt("UseSoundtrackOld", 0) + if SpringUnsynced.GetConfigInt("UseSoundtrackNew", 1) == 0 and SpringUnsynced.GetConfigInt("UseSoundtrackOld", 0) == 1 then + SpringUnsynced.SetConfigInt("UseSoundtrackNew", 1) + SpringUnsynced.SetConfigInt("UseSoundtrackOld", 0) end deviceLostSafetyCheck = 0 @@ -168,7 +168,7 @@ local function ReloadMusicPlaylists() table.append(eventWarHighTracks, VFS.DirList(musicDirNew .. "/events/raptors/warhigh", allowedExtensions)) table.append(interludeTracks, VFS.DirList(musicDirNew .. "/events/raptors/interludes", allowedExtensions)) table.append(bossFightTracks, VFS.DirList(musicDirNew .. "/events/raptors/bossfight", allowedExtensions)) - elseif Spring.GetConfigInt("UseSoundtrackRaptors", 0) == 1 then + elseif SpringUnsynced.GetConfigInt("UseSoundtrackRaptors", 0) == 1 then table.append(peaceTracksNew, VFS.DirList(musicDirNew .. "/events/raptors/peace", allowedExtensions)) table.append(warlowTracksNew, VFS.DirList(musicDirNew .. "/events/raptors/warlow", allowedExtensions)) table.append(warhighTracksNew, VFS.DirList(musicDirNew .. "/events/raptors/warhigh", allowedExtensions)) @@ -188,7 +188,7 @@ local function ReloadMusicPlaylists() table.append(eventWarHighTracks, VFS.DirList(musicDirNew .. "/events/scavengers/warhigh", allowedExtensions)) table.append(interludeTracks, VFS.DirList(musicDirNew .. "/events/scavengers/interludes", allowedExtensions)) table.append(bossFightTracks, VFS.DirList(musicDirNew .. "/events/scavengers/bossfight", allowedExtensions)) - elseif Spring.GetConfigInt("UseSoundtrackScavengers", 0) == 1 then + elseif SpringUnsynced.GetConfigInt("UseSoundtrackScavengers", 0) == 1 then table.append(peaceTracksNew, VFS.DirList(musicDirNew .. "/events/scavengers/peace", allowedExtensions)) table.append(warlowTracksNew, VFS.DirList(musicDirNew .. "/events/scavengers/warlow", allowedExtensions)) table.append(warhighTracksNew, VFS.DirList(musicDirNew .. "/events/scavengers/warhigh", allowedExtensions)) @@ -202,14 +202,14 @@ local function ReloadMusicPlaylists() table.append(scavTracks, VFS.DirList(musicDirNew .. "/events/scavengers/bossfight", allowedExtensions)) -- April Fools -------------------------------------------------------------------------------------------------------------------- - if Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools"] and Spring.GetConfigInt("UseSoundtrackAprilFools", 1) == 1 then + if Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools"] and SpringUnsynced.GetConfigInt("UseSoundtrackAprilFools", 1) == 1 then table.append(eventPeaceTracks, VFS.DirList(musicDirNew .. "/events/aprilfools/peace", allowedExtensions)) table.append(eventWarLowTracks, VFS.DirList(musicDirNew .. "/events/aprilfools/war", allowedExtensions)) table.append(eventWarHighTracks, VFS.DirList(musicDirNew .. "/events/aprilfools/war", allowedExtensions)) table.append(eventWarLowTracks, VFS.DirList(musicDirNew .. "/events/aprilfools/warlow", allowedExtensions)) table.append(eventWarHighTracks, VFS.DirList(musicDirNew .. "/events/aprilfools/warhigh", allowedExtensions)) table.append(interludeTracks, VFS.DirList(musicDirNew .. "/events/aprilfools/interludes", allowedExtensions)) - elseif (not Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools"]) and Spring.GetConfigInt("UseSoundtrackAprilFoolsPostEvent", 0) == 1 then + elseif (not Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools"]) and SpringUnsynced.GetConfigInt("UseSoundtrackAprilFoolsPostEvent", 0) == 1 then table.append(peaceTracksNew, VFS.DirList(musicDirNew .. "/events/aprilfools/peace", allowedExtensions)) table.append(warlowTracksNew, VFS.DirList(musicDirNew .. "/events/aprilfools/war", allowedExtensions)) table.append(warhighTracksNew, VFS.DirList(musicDirNew .. "/events/aprilfools/war", allowedExtensions)) @@ -226,14 +226,14 @@ local function ReloadMusicPlaylists() table.append(bonusTracks, VFS.DirList(musicDirNew .. "/events/aprilfools/interludes", allowedExtensions)) -- Halloween -------------------------------------------------------------------------------------------------------------------- - if Spring.Utilities.Gametype.GetCurrentHolidays()["halloween"] and Spring.GetConfigInt("UseSoundtrackHalloween", 1) == 1 then + if Spring.Utilities.Gametype.GetCurrentHolidays()["halloween"] and SpringUnsynced.GetConfigInt("UseSoundtrackHalloween", 1) == 1 then table.append(eventPeaceTracks, VFS.DirList(musicDirNew .. "/events/halloween/peace", allowedExtensions)) table.append(eventWarLowTracks, VFS.DirList(musicDirNew .. "/events/halloween/war", allowedExtensions)) table.append(eventWarHighTracks, VFS.DirList(musicDirNew .. "/events/halloween/war", allowedExtensions)) table.append(eventWarLowTracks, VFS.DirList(musicDirNew .. "/events/halloween/warlow", allowedExtensions)) table.append(eventWarHighTracks, VFS.DirList(musicDirNew .. "/events/halloween/warhigh", allowedExtensions)) table.append(interludeTracks, VFS.DirList(musicDirNew .. "/events/halloween/interludes", allowedExtensions)) - elseif (not Spring.Utilities.Gametype.GetCurrentHolidays()["halloween"]) and Spring.GetConfigInt("UseSoundtrackHalloweenPostEvent", 0) == 1 then + elseif (not Spring.Utilities.Gametype.GetCurrentHolidays()["halloween"]) and SpringUnsynced.GetConfigInt("UseSoundtrackHalloweenPostEvent", 0) == 1 then table.append(peaceTracksNew, VFS.DirList(musicDirNew .. "/events/halloween/peace", allowedExtensions)) table.append(warlowTracksNew, VFS.DirList(musicDirNew .. "/events/halloween/war", allowedExtensions)) table.append(warhighTracksNew, VFS.DirList(musicDirNew .. "/events/halloween/war", allowedExtensions)) @@ -250,14 +250,14 @@ local function ReloadMusicPlaylists() table.append(bonusTracks, VFS.DirList(musicDirNew .. "/events/halloween/interludes", allowedExtensions)) -- Christmas -------------------------------------------------------------------------------------------------------------------- - if Spring.Utilities.Gametype.GetCurrentHolidays()["xmas"] and Spring.GetConfigInt("UseSoundtrackXmas", 1) == 1 then + if Spring.Utilities.Gametype.GetCurrentHolidays()["xmas"] and SpringUnsynced.GetConfigInt("UseSoundtrackXmas", 1) == 1 then table.append(eventPeaceTracks, VFS.DirList(musicDirNew .. "/events/xmas/peace", allowedExtensions)) table.append(eventWarLowTracks, VFS.DirList(musicDirNew .. "/events/xmas/war", allowedExtensions)) table.append(eventWarHighTracks, VFS.DirList(musicDirNew .. "/events/xmas/war", allowedExtensions)) table.append(eventWarLowTracks, VFS.DirList(musicDirNew .. "/events/xmas/warlow", allowedExtensions)) table.append(eventWarHighTracks, VFS.DirList(musicDirNew .. "/events/xmas/warhigh", allowedExtensions)) table.append(interludeTracks, VFS.DirList(musicDirNew .. "/events/xmas/interludes", allowedExtensions)) - elseif (not Spring.Utilities.Gametype.GetCurrentHolidays()["xmas"]) and Spring.GetConfigInt("UseSoundtrackXmasPostEvent", 0) == 1 then + elseif (not Spring.Utilities.Gametype.GetCurrentHolidays()["xmas"]) and SpringUnsynced.GetConfigInt("UseSoundtrackXmasPostEvent", 0) == 1 then table.append(peaceTracksNew, VFS.DirList(musicDirNew .. "/events/xmas/peace", allowedExtensions)) table.append(warlowTracksNew, VFS.DirList(musicDirNew .. "/events/xmas/war", allowedExtensions)) table.append(warhighTracksNew, VFS.DirList(musicDirNew .. "/events/xmas/war", allowedExtensions)) @@ -475,17 +475,17 @@ local playedGameOverTrack = false local fadeLevel = 100 local faderMin = 45 -- range in dB for volume faders, from -faderMin to 0dB -local playedTime, totalTime = Spring.GetSoundStreamTime() +local playedTime, totalTime = SpringUnsynced.GetSoundStreamTime() local prevPlayedTime = playedTime -local maxMusicVolume = Spring.GetConfigInt("snd_volmusic", 50) -- user value, cause actual volume will change during fadein/outc +local maxMusicVolume = SpringUnsynced.GetConfigInt("snd_volmusic", 50) -- user value, cause actual volume will change during fadein/outc if maxMusicVolume > 99 then - Spring.SetConfigInt("snd_volmusic", 99) + SpringUnsynced.SetConfigInt("snd_volmusic", 99) maxMusicVolume = 99 end -local volume = Spring.GetConfigInt("snd_volmaster", 80) +local volume = SpringUnsynced.GetConfigInt("snd_volmaster", 80) if volume > 80 then - Spring.SetConfigInt("snd_volmaster", 80) + SpringUnsynced.SetConfigInt("snd_volmaster", 80) volume = 80 end @@ -502,9 +502,9 @@ local updateDrawing = false local guishaderWasActive = false local vsx, vsy = spGetViewGeometry() -local ui_opacity = Spring.GetConfigFloat("ui_opacity", 0.7) +local ui_opacity = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7) -local playing = (Spring.GetConfigInt("music", 1) == 1) +local playing = (SpringUnsynced.GetConfigInt("music", 1) == 1) local shutdown local playTex = ":l:" .. LUAUI_DIRNAME .. "Images/music/play.png" @@ -554,7 +554,7 @@ local function getFastFadeSpeed() return 1.5 * 0.33 end local function getSlowFadeSpeed() - return mathMax(Spring.GetGameSpeed(), 0.01) + return mathMax(SpringUnsynced.GetGameSpeed(), 0.01) end local getFadeSpeed = getSlowFadeSpeed @@ -563,16 +563,16 @@ local function fadeChange() end local function getMusicVolume() - return Spring.GetConfigInt("snd_volmusic", defaultMusicVolume) * 0.01 + return SpringUnsynced.GetConfigInt("snd_volmusic", defaultMusicVolume) * 0.01 end local function setMusicVolume(fadeLevel) - Spring.SetSoundStreamVolume(getMusicVolume() * math.clamp(fadeLevel, 0, 100) * 0.01) + SpringUnsynced.SetSoundStreamVolume(getMusicVolume() * math.clamp(fadeLevel, 0, 100) * 0.01) end local function updateFade() if fadeDirection then - if Spring.GetConfigInt("UseSoundtrackFades", 1) == 1 then + if SpringUnsynced.GetConfigInt("UseSoundtrackFades", 1) == 1 then fadeLevel = fadeLevel + fadeChange() else if fadeDirection < 0 then @@ -588,7 +588,7 @@ local function updateFade() playInterlude = false PlayNewTrack() else - Spring.StopSoundStream() + SpringUnsynced.StopSoundStream() end elseif fadeDirection > 0 and fadeLevel >= 100 then fadeDirection = nil @@ -792,7 +792,7 @@ local function updatePosition(force) if WG["advplayerlist_api"] ~= nil then advplayerlistPos = WG["advplayerlist_api"].GetPosition() else - local scale = (vsy / 880) * (1 + (Spring.GetConfigFloat("ui_scale", 1) - 1) / 1.25) + local scale = (vsy / 880) * (1 + (SpringUnsynced.GetConfigFloat("ui_scale", 1) - 1) / 1.25) advplayerlistPos = { 0, vsx - (220 * scale), 0, vsx, scale } end left = advplayerlistPos[2] @@ -807,8 +807,8 @@ end function widget:Initialize() isChangingTrack = false - if spGetGameFrame() == 0 and Spring.GetConfigInt("music_loadscreen", 1) == 1 then - currentTrack = Spring.GetConfigString("music_loadscreen_track", "") + if spGetGameFrame() == 0 and SpringUnsynced.GetConfigInt("music_loadscreen", 1) == 1 then + currentTrack = SpringUnsynced.GetConfigString("music_loadscreen_track", "") end ReloadMusicPlaylists() widget:ViewResize() @@ -827,7 +827,7 @@ function widget:Initialize() end WG["music"].SetMusicVolume = function(value) maxMusicVolume = value - Spring.SetConfigInt("snd_volmusic", mathMin(99, mathCeil(maxMusicVolume))) -- It took us 2 and half year to realize that the engine is not saving value of a 100 because it's engine default, which is why we're maxing it at 99 + SpringUnsynced.SetConfigInt("snd_volmusic", mathMin(99, mathCeil(maxMusicVolume))) -- It took us 2 and half year to realize that the engine is not saving value of a 100 because it's engine default, which is why we're maxing it at 99 if fadeDirection then setMusicVolume(fadeLevel) end @@ -937,11 +937,11 @@ function widget:Initialize() end WG["music"].playTrack = function(track) currentTrack = track - Spring.StopSoundStream() - Spring.PlaySoundStream(currentTrack, 1) + SpringUnsynced.StopSoundStream() + SpringUnsynced.PlaySoundStream(currentTrack, 1) playing = true - Spring.SetConfigInt("music", (playing and 1 or 0)) - local playedTime, totalTime = Spring.GetSoundStreamTime() + SpringUnsynced.SetConfigInt("music", (playing and 1 or 0)) + local playedTime, totalTime = SpringUnsynced.GetSoundStreamTime() interruptionTime = totalTime + 2 if fadeDirection then setMusicVolume(fadeLevel) @@ -951,10 +951,10 @@ function widget:Initialize() updateDrawing = true end WG["music"].RefreshSettings = function() - interruptionEnabled = Spring.GetConfigInt("UseSoundtrackInterruption", 1) == 1 + interruptionEnabled = SpringUnsynced.GetConfigInt("UseSoundtrackInterruption", 1) == 1 end WG["music"].RefreshTrackList = function() - Spring.StopSoundStream() + SpringUnsynced.StopSoundStream() ReloadMusicPlaylists() playInterlude = false PlayNewTrack() @@ -963,7 +963,7 @@ end function widget:Shutdown() shutdown = true - Spring.SetConfigInt("music", (playing and 1 or 0)) + SpringUnsynced.SetConfigInt("music", (playing and 1 or 0)) if WG["guishader"] then WG["guishader"].RemoveDlist("music") @@ -1035,7 +1035,7 @@ function widget:MouseMove(x, y) if showGUI and draggingSlider ~= nil then if draggingSlider == "musicvolume" then maxMusicVolume = mathCeil(getVolumeCoef(getSliderValue(draggingSlider, x)) * 99) - Spring.SetConfigInt("snd_volmusic", mathMin(99, maxMusicVolume)) -- It took us 2 and half year to realize that the engine is not saving value of a 100 because it's engine default, which is why we're maxing it at 99 + SpringUnsynced.SetConfigInt("snd_volmusic", mathMin(99, maxMusicVolume)) -- It took us 2 and half year to realize that the engine is not saving value of a 100 because it's engine default, which is why we're maxing it at 99 if fadeDirection then setMusicVolume(fadeLevel) end @@ -1043,14 +1043,14 @@ function widget:MouseMove(x, y) end if draggingSlider == "volume" then volume = mathCeil(getVolumeCoef(getSliderValue(draggingSlider, x)) * 80) - Spring.SetConfigInt("snd_volmaster", volume) + SpringUnsynced.SetConfigInt("snd_volmaster", volume) updateDrawing = true end end end local function mouseEvent(x, y, button, release) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return false end if not showGUI then @@ -1063,14 +1063,14 @@ local function mouseEvent(x, y, button, release) if math_isInRect(x, y, buttons[button][1] - sliderWidth, buttons[button][2], buttons[button][3] + sliderWidth, buttons[button][4]) then draggingSlider = button maxMusicVolume = mathCeil(getVolumeCoef(getSliderValue(button, x)) * 99) - Spring.SetConfigInt("snd_volmusic", mathMin(99, maxMusicVolume)) -- It took us 2 and half year to realize that the engine is not saving value of a 100 because it's engine default, which is why we're maxing it at 99 + SpringUnsynced.SetConfigInt("snd_volmusic", mathMin(99, maxMusicVolume)) -- It took us 2 and half year to realize that the engine is not saving value of a 100 because it's engine default, which is why we're maxing it at 99 updateDrawing = true end button = "volume" if math_isInRect(x, y, buttons[button][1] - sliderWidth, buttons[button][2], buttons[button][3] + sliderWidth, buttons[button][4]) then draggingSlider = button volume = mathCeil(getVolumeCoef(getSliderValue(button, x)) * 80) - Spring.SetConfigInt("snd_volmaster", volume) + SpringUnsynced.SetConfigInt("snd_volmaster", volume) updateDrawing = true end end @@ -1080,12 +1080,12 @@ local function mouseEvent(x, y, button, release) if button == 1 and not release and math_isInRect(x, y, left, bottom, right, top) then if buttons["playpause"] ~= nil and math_isInRect(x, y, buttons["playpause"][1], buttons["playpause"][2], buttons["playpause"][3], buttons["playpause"][4]) then playing = not playing - Spring.SetConfigInt("music", (playing and 1 or 0)) - Spring.PauseSoundStream() + SpringUnsynced.SetConfigInt("music", (playing and 1 or 0)) + SpringUnsynced.PauseSoundStream() updateDrawing = true elseif buttons["next"] ~= nil and math_isInRect(x, y, buttons["next"][1], buttons["next"][2], buttons["next"][3], buttons["next"][4]) then playing = true - Spring.SetConfigInt("music", (playing and 1 or 0)) + SpringUnsynced.SetConfigInt("music", (playing and 1 or 0)) playInterlude = false PlayNewTrack() end @@ -1109,9 +1109,9 @@ end local playingInit = false function widget:Update(dt) local frame = spGetGameFrame() - local _, _, paused = Spring.GetGameSpeed() + local _, _, paused = SpringUnsynced.GetGameSpeed() - playedTime, totalTime = Spring.GetSoundStreamTime() + playedTime, totalTime = SpringUnsynced.GetSoundStreamTime() if not playingInit then playingInit = true @@ -1144,7 +1144,7 @@ function widget:Update(dt) if math_isInRect(mx, my, left, bottom, right, top) then mouseover = true end - local curVolume = Spring.GetConfigInt("snd_volmaster", 80) + local curVolume = SpringUnsynced.GetConfigInt("snd_volmaster", 80) if volume ~= curVolume then volume = curVolume updateDrawing = true @@ -1166,7 +1166,7 @@ function widget:DrawScreen() mouseover = false else if math_isInRect(mx, my, left, bottom, right, top) then - local curVolume = Spring.GetConfigInt("snd_volmaster", 80) + local curVolume = SpringUnsynced.GetConfigInt("snd_volmaster", 80) if volume ~= curVolume then volume = curVolume updateDrawing = true @@ -1226,7 +1226,7 @@ function widget:DrawScreen() end if mouseover then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end end @@ -1236,14 +1236,14 @@ function PlayNewTrack(paused) end isChangingTrack = true - if Spring.GetConfigInt("music", 1) ~= 1 then + if SpringUnsynced.GetConfigInt("music", 1) ~= 1 then isChangingTrack = false return end if (not paused) and spGetGameFrame() > 1 then deviceLostSafetyCheck = deviceLostSafetyCheck + 1 end - Spring.StopSoundStream() + SpringUnsynced.StopSoundStream() fadeOutSkipTrack = false if (not gameOver) and spGetGameFrame() > 1 then @@ -1415,7 +1415,7 @@ function PlayNewTrack(paused) end if currentTrack then - Spring.PlaySoundStream(currentTrack, 1) + SpringUnsynced.PlaySoundStream(currentTrack, 1) playing = true if string.find(currentTrackListString, "event") then @@ -1439,7 +1439,7 @@ end function widget:UnitDamaged(unitID, unitDefID, _, damage) if damage > 1 then warMeterResetTimer = 0 - local curHealth, maxHealth = Spring.GetUnitHealth(unitID) + local curHealth, maxHealth = SpringShared.GetUnitHealth(unitID) if maxHealth and damage > maxHealth then warMeter = mathCeil(warMeter + maxHealth) else @@ -1481,21 +1481,21 @@ function widget:GameFrame(n) end if Spring.Utilities.Gametype.IsRaptors() then - if (Spring.GetGameRulesParam("raptorQueenAnger", 0)) > 60 and warMeter < warHighLevel + 1 then + if (SpringShared.GetGameRulesParam("raptorQueenAnger", 0)) > 60 and warMeter < warHighLevel + 1 then warMeter = warHighLevel + 1 - elseif (Spring.GetGameRulesParam("raptorQueenAnger", 0)) > 20 and warMeter < warLowLevel + 1 then + elseif (SpringShared.GetGameRulesParam("raptorQueenAnger", 0)) > 20 and warMeter < warLowLevel + 1 then warMeter = warLowLevel + 1 end elseif Spring.Utilities.Gametype.IsScavengers() then - if (Spring.GetGameRulesParam("scavBossAnger", 0)) > 60 and warMeter < warHighLevel + 1 then + if (SpringShared.GetGameRulesParam("scavBossAnger", 0)) > 60 and warMeter < warHighLevel + 1 then warMeter = warHighLevel + 1 - elseif (Spring.GetGameRulesParam("scavBossAnger", 0)) > 20 and warMeter < warLowLevel + 1 then + elseif (SpringShared.GetGameRulesParam("scavBossAnger", 0)) > 20 and warMeter < warLowLevel + 1 then warMeter = warLowLevel + 1 end end if n % 30 == 15 then - if Spring.GetGameRulesParam("BossFightStarted") and Spring.GetGameRulesParam("BossFightStarted") == 1 then + if SpringShared.GetGameRulesParam("BossFightStarted") and SpringShared.GetGameRulesParam("BossFightStarted") == 1 then bossHasSpawned = true else bossHasSpawned = false @@ -1513,7 +1513,7 @@ function widget:GameFrame(n) if not gameOver then if playedTime > 0 and totalTime > 0 then -- music is playing if not fadeDirection then - Spring.SetSoundStreamVolume(musicVolume) + SpringUnsynced.SetSoundStreamVolume(musicVolume) if (bossHasSpawned and currentTrackListString ~= "bossFight") or ((not bossHasSpawned) and currentTrackListString == "bossFight") then fadeDirection = -2 fadeOutSkipTrack = true @@ -1529,7 +1529,7 @@ function widget:GameFrame(n) then -- Interlude is playing but we're hitting WarHigh levels. Let's switch to WarHigh fadeDirection = -2 fadeOutSkipTrack = true - elseif playedTime >= totalTime - 12 and Spring.GetConfigInt("UseSoundtrackFades", 1) == 1 then + elseif playedTime >= totalTime - 12 and SpringUnsynced.GetConfigInt("UseSoundtrackFades", 1) == 1 then fadeDirection = -1 end end diff --git a/luaui/Widgets/gui_advplayerslist_unittotals.lua b/luaui/Widgets/gui_advplayerslist_unittotals.lua index 7f28e9b4264..55720bc28c4 100644 --- a/luaui/Widgets/gui_advplayerslist_unittotals.lua +++ b/luaui/Widgets/gui_advplayerslist_unittotals.lua @@ -18,7 +18,7 @@ local mathFloor = math.floor -- Localized Spring API for performance local spGetMyTeamID = Spring.GetMyTeamID -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local displayFeatureCount = false @@ -31,7 +31,7 @@ local glCreateList = gl.CreateList local glDeleteList = gl.DeleteList local glCallList = gl.CallList -local spGetTeamUnitCount = Spring.GetTeamUnitCount +local spGetTeamUnitCount = SpringShared.GetTeamUnitCount local RectRound, UiElement, elementCorner local font @@ -51,9 +51,9 @@ local POSITION_CHECK_INTERVAL = 0.05 local allTeamIDs = {} local allTeamCount = 0 do - local allyTeamList = Spring.GetAllyTeamList() + local allyTeamList = SpringShared.GetAllyTeamList() for i = 1, #allyTeamList do - local teams = Spring.GetTeamList(allyTeamList[i]) + local teams = SpringShared.GetTeamList(allyTeamList[i]) for j = 1, #teams do allTeamCount = allTeamCount + 1 allTeamIDs[allTeamCount] = teams[j] @@ -69,11 +69,11 @@ local function drawContent() local textsize = 11 * widgetScale * math.clamp(1 + ((1 - (vsy / 1200)) * 0.4), 1, 1.15) local textXPadding = 10 * widgetScale - local maxUnits, currentUnits = Spring.GetTeamMaxUnits(myTeamID) + local maxUnits, currentUnits = SpringShared.GetTeamMaxUnits(myTeamID) local text = Spring.I18N("ui.unitTotals.totals", { titleColor = "\255\210\210\210", textColor = "\255\245\245\245", units = currentUnits, maxUnits = maxUnits, totalUnits = totalUnits }) if displayFeatureCount then - local features = Spring.GetAllFeatures() + local features = SpringShared.GetAllFeatures() text = text .. " \255\170\170\170" .. #features end font:Begin(true) @@ -120,7 +120,7 @@ local function updatePosition(force) elseif WG["advplayerlist_api"] ~= nil then advplayerlistPos = WG["advplayerlist_api"].GetPosition() else - local scale = (vsy / 880) * (1 + (Spring.GetConfigFloat("ui_scale", 1) - 1) / 1.25) + local scale = (vsy / 880) * (1 + (SpringUnsynced.GetConfigFloat("ui_scale", 1) - 1) / 1.25) advplayerlistPos = { 0, vsx - (220 * scale), 0, vsx, scale } end left = advplayerlistPos[2] @@ -175,7 +175,7 @@ function widget:Update(dt) updatePosition() end - if passedTime > 1 and Spring.GetGameFrame() > 0 then + if passedTime > 1 and SpringShared.GetGameFrame() > 0 then local count = 0 for i = 1, allTeamCount do count = count + spGetTeamUnitCount(allTeamIDs[i]) diff --git a/luaui/Widgets/gui_allySelectedUnits.lua b/luaui/Widgets/gui_allySelectedUnits.lua index 9d997ac00cf..33a40264d67 100644 --- a/luaui/Widgets/gui_allySelectedUnits.lua +++ b/luaui/Widgets/gui_allySelectedUnits.lua @@ -15,8 +15,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spGetGameFrame = Spring.GetGameFrame +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID local showAsSpectator = true @@ -56,11 +56,11 @@ local GL_REPLACE = GL.REPLACE local GL_POINTS = GL.POINTS local spGetUnitDefID = spGetUnitDefID -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetSpectatingState = Spring.GetSpectatingState +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local playerIsSpec = {} -for i, playerID in pairs(Spring.GetPlayerList()) do +for i, playerID in pairs(SpringShared.GetPlayerList()) do playerIsSpec[playerID] = select(3, spGetPlayerInfo(playerID, false)) end @@ -73,7 +73,7 @@ local playerSelectedUnits = {} -- [playerID][unitID] = true local lockPlayerID local unitAllyteam = {} -local spGetUnitTeam = Spring.GetUnitTeam +local spGetUnitTeam = SpringShared.GetUnitTeam local unitScale = {} local unitCanFly = {} @@ -160,7 +160,7 @@ end local function addUnit(unitID) if selectedUnits[unitID] ~= nil and selectedUnits[unitID] == false and (fullview or myAllyTeam == unitAllyteam[unitID]) then - if not Spring.ValidUnitID(unitID) or Spring.GetUnitIsDead(unitID) then + if not SpringShared.ValidUnitID(unitID) or SpringShared.GetUnitIsDead(unitID) then return end if enablePlatter then @@ -189,7 +189,7 @@ local function selectPlayerSelectedUnits(playerID) units[count] = unitID end end - Spring.SelectUnitArray(units) + SpringUnsynced.SelectUnitArray(units) end -- called by gadget @@ -228,7 +228,7 @@ local function selectedUnitsAdd(playerID, unitID) if not playerIsSpec[playerID] or (lockPlayerID ~= nil and playerID == lockPlayerID) then if spGetUnitDefID(unitID) then selectedUnits[unitID] = false - unitAllyteam[unitID] = select(6, Spring.GetTeamInfo(spGetUnitTeam(unitID), false)) + unitAllyteam[unitID] = select(6, SpringShared.GetTeamInfo(spGetUnitTeam(unitID), false)) addUnit(unitID) end end @@ -292,7 +292,7 @@ function widget:PlayerChanged(playerID) end end - for i, playerID in pairs(Spring.GetPlayerList()) do + for i, playerID in pairs(SpringShared.GetPlayerList()) do local spec = select(3, spGetPlayerInfo(playerID, false)) if spec and not playerIsSpec[playerID] then selectedUnitsClear(playerID) @@ -365,7 +365,7 @@ function widget:Initialize() if not init() then return end - for _, playerID in pairs(Spring.GetPlayerList()) do + for _, playerID in pairs(SpringShared.GetPlayerList()) do widget:PlayerAdded(playerID) end widget:PlayerChanged(myPlayerID) @@ -401,7 +401,7 @@ function widget:DrawWorldPreUnit() return end - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end diff --git a/luaui/Widgets/gui_ally_cursors.lua b/luaui/Widgets/gui_ally_cursors.lua index e4ba8effb8a..2c274b6bd18 100644 --- a/luaui/Widgets/gui_ally_cursors.lua +++ b/luaui/Widgets/gui_ally_cursors.lua @@ -17,7 +17,7 @@ local mathAtan2 = math.atan2 -- Localized Spring API for performance local spGetMyTeamID = Spring.GetMyTeamID -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState -- TODO: hide (enemy) cursor light when not specfullview @@ -54,13 +54,13 @@ local lightSelfShadowing = false -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -local spGetGroundHeight = Spring.GetGroundHeight -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetTeamColor = Spring.GetTeamColor -local spIsSphereInView = Spring.IsSphereInView -local spGetCameraPosition = Spring.GetCameraPosition -local spIsGUIHidden = Spring.IsGUIHidden -local spAreTeamsAllied = Spring.AreTeamsAllied +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetTeamColor = SpringUnsynced.GetTeamColor +local spIsSphereInView = SpringUnsynced.IsSphereInView +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spIsGUIHidden = SpringUnsynced.IsGUIHidden +local spAreTeamsAllied = SpringShared.AreTeamsAllied local glCreateList = gl.CreateList local glDeleteList = gl.DeleteList @@ -79,7 +79,7 @@ local glDepthTest = gl.DepthTest local glBlending = gl.Blending local glPolygonOffset = gl.PolygonOffset -local spGetCameraDirection = Spring.GetCameraDirection +local spGetCameraDirection = SpringUnsynced.GetCameraDirection local math_deg = math.deg local abs = math.abs @@ -100,7 +100,7 @@ local playerTeamIDs = {} local myPlayerID = Spring.GetMyPlayerID() local _, fullview = spGetSpectatingState() local myTeamID = spGetMyTeamID() -local isReplay = Spring.IsReplay() +local isReplay = SpringUnsynced.IsReplay() local allyCursor = ":n:LuaUI/Images/allycursor.dds" local cursors = {} @@ -109,7 +109,7 @@ local specList = {} local notIdle = {} local teamColorKeys = {} -local teams = Spring.GetTeamList() +local teams = SpringShared.GetTeamList() for i = 1, #teams do local r, g, b = spGetTeamColor(teams[i]) teamColorKeys[teams[i]] = r .. "_" .. g .. "_" .. b @@ -133,7 +133,7 @@ end local function updateSpecList(init) specList = {} playerTeamIDs = {} - local t = Spring.GetPlayerList() + local t = SpringShared.GetPlayerList() for _, playerID in ipairs(t) do local _, _, isSpec, teamID = spGetPlayerInfo(playerID, false) specList[playerID] = isSpec @@ -284,7 +284,7 @@ function widget:Initialize() end local now = clock() - (idleCursorTime * 0.95) - local pList = Spring.GetPlayerList() + local pList = SpringShared.GetPlayerList() for _, playerID in ipairs(pList) do alliedCursorsTime[playerID] = now end @@ -457,12 +457,12 @@ function widget:Update(dt) sec = 0 -- check if team colors have changed - local teams = Spring.GetTeamList() + local teams = SpringShared.GetTeamList() for i = 1, #teams do local r, g, b = spGetTeamColor(teams[i]) if teamColorKeys[teams[i]] ~= r .. "_" .. g .. "_" .. b then teamColorKeys[teams[i]] = r .. "_" .. g .. "_" .. b - local players = Spring.GetPlayerList(teams[i]) + local players = SpringShared.GetPlayerList(teams[i]) for _, playerID in ipairs(players) do widget:PlayerChanged(playerID) end diff --git a/luaui/Widgets/gui_anti_ranges.lua b/luaui/Widgets/gui_anti_ranges.lua index f2eb06d8f10..25b514249dc 100644 --- a/luaui/Widgets/gui_anti_ranges.lua +++ b/luaui/Widgets/gui_anti_ranges.lua @@ -15,7 +15,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -- project page on github: https://github.com/jamerlan/gui_mobile_anti_defence_range @@ -56,15 +56,15 @@ local glDepthTest = gl.DepthTest local glLineWidth = gl.LineWidth local glDrawGroundCircle = gl.DrawGroundCircle -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetPositionLosState = Spring.GetPositionLosState -local spGetCameraPosition = Spring.GetCameraPosition -local spGetUnitStockpile = Spring.GetUnitStockpile -local spGetAllUnits = Spring.GetAllUnits -local spGetTeamUnitsByDefs = Spring.GetTeamUnitsByDefs -local spGetTeamList = Spring.GetTeamList -local GetUnitIsStunned = Spring.GetUnitIsStunned +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetPositionLosState = SpringShared.GetPositionLosState +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spGetUnitStockpile = SpringShared.GetUnitStockpile +local spGetAllUnits = SpringShared.GetAllUnits +local spGetTeamUnitsByDefs = SpringShared.GetTeamUnitsByDefs +local spGetTeamList = SpringShared.GetTeamList +local GetUnitIsStunned = SpringShared.GetUnitIsStunned local antiInLos = {} local antiOutLos = {} @@ -112,7 +112,7 @@ function widget:DrawWorldPreUnit() if chobbyInterface then return end - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end local camX, camY, camZ = spGetCameraPosition() @@ -129,7 +129,7 @@ function widget:DrawWorldPreUnit() for uID, pos in pairs(antiInLos) do local x, y, z = spGetUnitPosition(uID) - if x ~= nil and y ~= nil and z ~= nil and Spring.IsSphereInView(x, y, z, pos[4]) then + if x ~= nil and y ~= nil and z ~= nil and SpringUnsynced.IsSphereInView(x, y, z, pos[4]) then drawCircle(uID, pos[4], x, y, z, camX, camY, camZ) end end diff --git a/luaui/Widgets/gui_attack_aoe.lua b/luaui/Widgets/gui_attack_aoe.lua index 56930518cf2..5016d96ebc8 100644 --- a/luaui/Widgets/gui_attack_aoe.lua +++ b/luaui/Widgets/gui_attack_aoe.lua @@ -37,21 +37,21 @@ local rad = math.rad local osClock = os.clock local spGetMyTeamID = Spring.GetMyTeamID -local spGetGroundHeight = Spring.GetGroundHeight -local spGetActiveCommand = Spring.GetActiveCommand -local spGetCameraPosition = Spring.GetCameraPosition -local spGetMouseState = Spring.GetMouseState -local spGetSelectedUnitsSorted = Spring.GetSelectedUnitsSorted -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitRadius = Spring.GetUnitRadius -local spGetUnitStates = Spring.GetUnitStates -local spTraceScreenRay = Spring.TraceScreenRay -local spIsUnitAllied = Spring.IsUnitAllied -local spGetUnitDefID = Spring.GetUnitDefID -local spGetTeamResources = Spring.GetTeamResources -local spGetUnitWeaponTestRange = Spring.GetUnitWeaponTestRange -local spGetUnitStockpile = Spring.GetUnitStockpile -local spGetViewGeometry = Spring.GetViewGeometry +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetSelectedUnitsSorted = SpringUnsynced.GetSelectedUnitsSorted +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitRadius = SpringShared.GetUnitRadius +local spGetUnitStates = SpringShared.GetUnitStates +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetTeamResources = SpringShared.GetTeamResources +local spGetUnitWeaponTestRange = SpringShared.GetUnitWeaponTestRange +local spGetUnitStockpile = SpringShared.GetUnitStockpile +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local CMD_ATTACK = CMD.ATTACK local CMD_UNIT_SET_TARGET = GameCMD.UNIT_SET_TARGET diff --git a/luaui/Widgets/gui_attackrange_gl4.lua b/luaui/Widgets/gui_attackrange_gl4.lua index 28cd328979c..219d2d93f27 100644 --- a/luaui/Widgets/gui_attackrange_gl4.lua +++ b/luaui/Widgets/gui_attackrange_gl4.lua @@ -25,7 +25,7 @@ local mathPi = math.pi -- Localized Spring API for performance local spGetMyTeamID = Spring.GetMyTeamID -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo --------------------------- @@ -467,16 +467,16 @@ local GL_NOTEQUAL = GL.NOTEQUAL local GL_KEEP = 0x1E00 --GL.KEEP local GL_REPLACE = GL.REPLACE --GL.KEEP -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitWeaponVectors = Spring.GetUnitWeaponVectors -local spGetUnitWeaponState = Spring.GetUnitWeaponState -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay -local GetModKeyState = Spring.GetModKeyState -local GetActiveCommand = Spring.GetActiveCommand -local GetSelectedUnits = Spring.GetSelectedUnits +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitWeaponVectors = SpringShared.GetUnitWeaponVectors +local spGetUnitWeaponState = SpringShared.GetUnitWeaponState +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local GetModKeyState = SpringUnsynced.GetModKeyState +local GetActiveCommand = SpringUnsynced.GetActiveCommand +local GetSelectedUnits = SpringUnsynced.GetSelectedUnits local chobbyInterface local CMD_ATTACK = CMD.ATTACK @@ -824,7 +824,7 @@ end local function InitializeBuilders() builders = {} - for _, unitID in ipairs(Spring.GetTeamUnits(spGetMyTeamID())) do + for _, unitID in ipairs(SpringShared.GetTeamUnits(spGetMyTeamID())) do if unitBuilder[spGetUnitDefID(unitID)] then builders[unitID] = true end @@ -964,7 +964,7 @@ local function cycleUnitDisplay(direction) soundEffect = soundEffectOff volume = 0.6 end - Spring.PlaySoundFile(soundEffect, volume, "ui") + SpringUnsynced.PlaySoundFile(soundEffect, volume, "ui") RefreshEverything() end @@ -976,8 +976,8 @@ local function cycleUnitDisplayHandler(_, _, _, data) end function widget:PlayerChanged(playerID) - myAllyTeamID = Spring.GetLocalAllyTeamID() - myTeamID = Spring.GetLocalTeamID() + myAllyTeamID = SpringUnsynced.GetLocalAllyTeamID() + myTeamID = SpringUnsynced.GetLocalTeamID() InitializeBuilders() end @@ -1239,7 +1239,7 @@ function widget:DrawWorld(inMiniMap) if chobbyInterface or not (selUnitCount > 0 or mouseUnit) then return end - if not Spring.IsGUIHidden() and (not WG["topbar"] or not WG["topbar"].showingQuit()) then + if not SpringUnsynced.IsGUIHidden() and (not WG["topbar"] or not WG["topbar"].showingQuit()) then -- For PIP minimap, use thicker lines since PIP is larger than engine minimap local inPip = inMiniMap and WG["minimap"] and WG["minimap"].isDrawingInPip if inPip then @@ -1334,7 +1334,7 @@ end function widget:VisibleUnitRemoved(unitID, unitDefID, unitTeam) unitDefID = unitDefID or spGetUnitDefID(unitID) - unitTeam = unitTeam or Spring.GetUnitTeam(unitID) + unitTeam = unitTeam or SpringShared.GetUnitTeam(unitID) RemoveSelectedUnit(unitID, false) builders[unitID] = nil end diff --git a/luaui/Widgets/gui_awards.lua b/luaui/Widgets/gui_awards.lua index ca13bc1a282..e09c734df9a 100644 --- a/luaui/Widgets/gui_awards.lua +++ b/luaui/Widgets/gui_awards.lua @@ -17,7 +17,7 @@ local mathFloor = math.floor local tableInsert = table.insert -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local glCallList = gl.CallList @@ -42,7 +42,7 @@ local threshold = 150000 local CowAward local OtherAwards -local chobbyLoaded = (Spring.GetMenuName and string.find(string.lower(Spring.GetMenuName()), "chobby") ~= nil) +local chobbyLoaded = (SpringUnsynced.GetMenuName and string.find(string.lower(SpringUnsynced.GetMenuName()), "chobby") ~= nil) local white = "\255" .. string.char(251) .. string.char(251) .. string.char(251) @@ -58,7 +58,7 @@ local function colourNames(teamID) if teamID < 0 then return "" end - local nameColourR, nameColourG, nameColourB, nameColourA = Spring.GetTeamColor(teamID) + local nameColourR, nameColourG, nameColourB, nameColourA = SpringUnsynced.GetTeamColor(teamID) return Spring.Utilities.Color.ToString(nameColourR, nameColourG, nameColourB) end @@ -283,7 +283,7 @@ local function ProcessAwards(awards) drawAwards = true -- don't show graph - Spring.SendCommands("endgraph 0") + SpringUnsynced.SendCommands("endgraph 0") end function widget:MousePress(x, y, button) @@ -295,15 +295,15 @@ function widget:MousePress(x, y, button) -- Leave button if x > widgetX + widgetWidthScaled - quitRightX - mathFloor(5 * widgetScale) and (x < widgetX + widgetWidthScaled - quitRightX + mathFloor(20 * widgetScale) * font:GetTextWidth(Spring.I18N("ui.awards.leave")) + mathFloor(5 * widgetScale)) and (y > widgetY + mathFloor((50 - 5) * widgetScale)) and (y < widgetY + mathFloor((50 + 17 + 5) * widgetScale)) then if chobbyLoaded then - Spring.Reload("") + SpringUnsynced.Reload("") else - Spring.SendCommands("quitforce") + SpringUnsynced.SendCommands("quitforce") end end -- Show Graphs button if (x > widgetX + widgetWidthScaled - graphsRightX - mathFloor(5 * widgetScale)) and (x < widgetX + widgetWidthScaled - graphsRightX + mathFloor(20 * widgetScale) * font:GetTextWidth(Spring.I18N("ui.awards.showGraphs")) + mathFloor(5 * widgetScale)) and (y > widgetY + mathFloor((50 - 5) * widgetScale) and (y < widgetY + mathFloor((50 + 17 + 5) * widgetScale))) then - Spring.SendCommands("endgraph 2") + SpringUnsynced.SendCommands("endgraph 2") if WG["guishader"] then WG["guishader"].RemoveRect("awards") @@ -349,7 +349,7 @@ function widget:DrawScreen() glCallList(FourthAward) end - local x, y = Spring.GetMouseState() + local x, y = SpringUnsynced.GetMouseState() local quitColour local graphColour font2:Begin() @@ -386,18 +386,18 @@ function widget:LanguageChanged() end function widget:Initialize() - Spring.SendCommands("endgraph 2") + SpringUnsynced.SendCommands("endgraph 2") widget:ViewResize(viewScreenX, viewScreenY) widgetHandler:RegisterGlobal("GadgetReceiveAwards", ProcessAwards) -- load a list of players for each team into playerListByTeam - local teamList = Spring.GetTeamList() + local teamList = SpringShared.GetTeamList() for _, teamID in pairs(teamList) do - local playerList = Spring.GetPlayerList(teamID) + local playerList = SpringShared.GetPlayerList(teamID) local list = {} --without specs for _, playerID in pairs(playerList) do - local name, _, isSpec = Spring.GetPlayerInfo(playerID, false) + local name, _, isSpec = SpringShared.GetPlayerInfo(playerID, false) if not isSpec then tableInsert(list, name) end @@ -410,7 +410,7 @@ end function widget:Shutdown() widgetHandler:DeregisterGlobal("GadgetReceiveAwards") - Spring.SendCommands("endgraph 2") + SpringUnsynced.SendCommands("endgraph 2") if Background then gl.DeleteList(Background) end diff --git a/luaui/Widgets/gui_blast_radius.lua b/luaui/Widgets/gui_blast_radius.lua index db55775f8ae..5ca2f68628c 100644 --- a/luaui/Widgets/gui_blast_radius.lua +++ b/luaui/Widgets/gui_blast_radius.lua @@ -38,15 +38,15 @@ local udefTab = UnitDefs local weapNamTab = WeaponDefNames local weapTab = WeaponDefs -local spGetKeyState = Spring.GetKeyState -local spGetModKeyState = Spring.GetModKeyState -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetGameSeconds = Spring.GetGameSeconds -local spGetActiveCommand = Spring.GetActiveCommand -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay -local spEcho = Spring.Echo +local spGetKeyState = SpringUnsynced.GetKeyState +local spGetModKeyState = SpringUnsynced.GetModKeyState +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetGameSeconds = SpringShared.GetGameSeconds +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spEcho = SpringShared.Echo local glColor = gl.Color local glLineWidth = gl.LineWidth @@ -61,8 +61,8 @@ local glBillboard = gl.Billboard local sqrt = math.sqrt local lower = string.lower -local spIsSphereInView = Spring.IsSphereInView -local spGetGroundHeight = Spring.GetGroundHeight +local spIsSphereInView = SpringUnsynced.IsSphereInView +local spGetGroundHeight = SpringShared.GetGroundHeight local font, chobbyInterface @@ -103,7 +103,7 @@ function widget:ViewResize() font = WG["fonts"].getFont(1, 1.5) end -local selectedUnits = Spring.GetSelectedUnits() +local selectedUnits = SpringUnsynced.GetSelectedUnits() function widget:SelectionChanged(sel) selectedUnits = sel end @@ -202,7 +202,7 @@ function DrawBuildMenuBlastRange() return end - local centerX, _, centerZ = Spring.Pos2BuildPos(unitDefID, coords[1], 0, coords[3]) + local centerX, _, centerZ = SpringShared.Pos2BuildPos(unitDefID, coords[1], 0, coords[3]) glLineWidth(blastLineWidth) glColor(expBlastColor[1], expBlastColor[2], expBlastColor[3], blastAlphaValue) diff --git a/luaui/Widgets/gui_build_eta.lua b/luaui/Widgets/gui_build_eta.lua index 028c3c2a406..38019fde320 100644 --- a/luaui/Widgets/gui_build_eta.lua +++ b/luaui/Widgets/gui_build_eta.lua @@ -12,14 +12,14 @@ function widget:GetInfo() } end -local lastGameUpdate = Spring.GetGameSeconds() - -local spGetUnitViewPosition = Spring.GetUnitViewPosition -local spGetGameSeconds = Spring.GetGameSeconds -local spGetGameFrame = Spring.GetGameFrame -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetSpectatingState = Spring.GetSpectatingState +local lastGameUpdate = SpringShared.GetGameSeconds() + +local spGetUnitViewPosition = SpringUnsynced.GetUnitViewPosition +local spGetGameSeconds = SpringShared.GetGameSeconds +local spGetGameFrame = SpringShared.GetGameFrame +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local spec, fullview = spGetSpectatingState() local myAllyTeam = Spring.GetMyAllyTeamID() @@ -69,11 +69,11 @@ end local function init() etaTable = {} - local units = Spring.GetAllUnits() + local units = SpringShared.GetAllUnits() for i = 1, #units do local unitID = units[i] if fullview or spGetUnitAllyTeam(unitID) == myAllyTeam then - etaTable[unitID] = makeETA(unitID, Spring.GetUnitDefID(unitID)) + etaTable[unitID] = makeETA(unitID, SpringShared.GetUnitDefID(unitID)) end end end @@ -204,9 +204,9 @@ local function drawEtaText(timeLeft, yoffset) end function widget:DrawWorld() - if Spring.IsGUIHidden() == false then + if SpringUnsynced.IsGUIHidden() == false then local glStateReady = false - local cx, cy, cz = Spring.GetCameraPosition() + local cx, cy, cz = SpringUnsynced.GetCameraPosition() for unitID, bi in pairs(etaTable) do local ux, uy, uz = spGetUnitViewPosition(unitID) if ux ~= nil then diff --git a/luaui/Widgets/gui_buildbar.lua b/luaui/Widgets/gui_buildbar.lua index 5f88b58f3d5..ca4e10ac95d 100644 --- a/luaui/Widgets/gui_buildbar.lua +++ b/luaui/Widgets/gui_buildbar.lua @@ -17,17 +17,17 @@ local mathAbs = math.abs local mathFloor = math.floor -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local getCurrentMiniMapRotationOption = VFS.Include("luaui/Include/minimap_utils.lua").getCurrentMiniMapRotationOption local ROTATION = VFS.Include("luaui/Include/minimap_utils.lua").ROTATION local vsx, vsy = spGetViewGeometry() -local ui_scale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local ui_scale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) -- saved values local bar_side = 1 --left:0,top:2,right:1,bottom:3 @@ -113,21 +113,21 @@ local GL_SRC_ALPHA = GL.SRC_ALPHA local glBlending = gl.Blending local math_floor = mathFloor local math_ceil = math.ceil -local GetUnitDefID = Spring.GetUnitDefID -local GetMouseState = Spring.GetMouseState -local GetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local GetUnitStates = Spring.GetUnitStates -local DrawUnitCommands = Spring.DrawUnitCommands -local GetFullBuildQueue = Spring.GetFullBuildQueue -local GetUnitIsBuilding = Spring.GetUnitIsBuilding +local GetUnitDefID = SpringShared.GetUnitDefID +local GetMouseState = SpringUnsynced.GetMouseState +local GetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local GetUnitStates = SpringShared.GetUnitStates +local DrawUnitCommands = SpringUnsynced.DrawUnitCommands +local GetFullBuildQueue = SpringShared.GetFullBuildQueue +local GetUnitIsBuilding = SpringShared.GetUnitIsBuilding local glColor = gl.Color local glTexture = gl.Texture local glTexRect = gl.TexRect local RectRound, RectRoundProgress, UiElement, UiUnit, elementCorner -local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode -local anonymousTeamColor = { Spring.GetConfigInt("anonymousColorR", 255) / 255, Spring.GetConfigInt("anonymousColorG", 0) / 255, Spring.GetConfigInt("anonymousColorB", 0) / 255 } +local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode +local anonymousTeamColor = { SpringUnsynced.GetConfigInt("anonymousColorR", 255) / 255, SpringUnsynced.GetConfigInt("anonymousColorG", 0) / 255, SpringUnsynced.GetConfigInt("anonymousColorB", 0) / 255 } ------------------------------------------------------------------------------- -- SOUNDS @@ -323,7 +323,7 @@ local function updateFactoryList() facs = {} local count = 0 - local teamUnits = Spring.GetTeamUnits(myTeamID) + local teamUnits = SpringShared.GetTeamUnits(myTeamID) for num = 1, #teamUnits do local unitID = teamUnits[num] local unitDefID = GetUnitDefID(unitID) @@ -416,7 +416,7 @@ function widget:Initialize() end if not gl.R2tHelper then - Spring.Echo("BuildBar: gl.R2tHelper not available") + SpringShared.Echo("BuildBar: gl.R2tHelper not available") widgetHandler:RemoveWidget() return end @@ -664,13 +664,13 @@ function widget:Update(dt) if WG["info"] then if hoveredFac >= 0 then if not setInfoDisplayUnitID or (hoveredBOpt < 0 and setInfoDisplayUnitID ~= facs[hoveredFac + 1].unitID) then - Spring.PlaySoundFile(sound_hover, 0.8, "ui") + SpringUnsynced.PlaySoundFile(sound_hover, 0.8, "ui") setInfoDisplayUnitID = facs[hoveredFac + 1].unitID WG["info"].displayUnitID(setInfoDisplayUnitID) end elseif hoveredBOpt >= 0 then if setInfoDisplayUnitID and setInfoDisplayUnitDefID ~= facs[openedMenu + 1].buildList[hoveredBOpt + 1] then - Spring.PlaySoundFile(sound_hover, 0.8, "ui") + SpringUnsynced.PlaySoundFile(sound_hover, 0.8, "ui") setInfoDisplayUnitDefID = facs[openedMenu + 1].buildList[hoveredBOpt + 1] WG["info"].displayUnitDefID(setInfoDisplayUnitDefID) end @@ -1368,10 +1368,10 @@ function widget:DrawInMiniMap(sx, sy) if anonymousMode ~= "disabled" then r, g, b = anonymousTeamColor[1], anonymousTeamColor[2], anonymousTeamColor[3] else - r, g, b = Spring.GetTeamColor(myTeamID) + r, g, b = SpringUnsynced.GetTeamColor(myTeamID) end - local alpha = 0.5 + mathAbs((Spring.GetGameSeconds() % 0.25) * 4 - 0.5) - local x, _, z = Spring.GetUnitBasePosition(facs[openedMenu + 1].unitID) + local alpha = 0.5 + mathAbs((SpringShared.GetGameSeconds() % 0.25) * 4 - 0.5) + local x, _, z = SpringShared.GetUnitBasePosition(facs[openedMenu + 1].unitID) if x ~= nil then gl.PointSize(pt * 0.066) @@ -1408,20 +1408,20 @@ local function menuHandler(x, y, button) onoff = { 0 } end spGiveOrderToUnit(factoryUnitID, CMD.REPEAT, onoff, 0) - Spring.PlaySoundFile(sound_click, 0.8, "ui") + SpringUnsynced.PlaySoundFile(sound_click, 0.8, "ui") else - Spring.SelectUnitArray({ factoryUnitID }) + SpringUnsynced.SelectUnitArray({ factoryUnitID }) end elseif button == 3 then - Spring.SelectUnitArray({ factoryUnitID }) - Spring.SetCameraTarget(Spring.GetUnitPosition(factoryUnitID)) + SpringUnsynced.SelectUnitArray({ factoryUnitID }) + SpringUnsynced.SetCameraTarget(SpringShared.GetUnitPosition(factoryUnitID)) end return end local function buildHandler(button) - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() local opt = {} if alt then opt[#opt + 1] = "alt" @@ -1438,11 +1438,11 @@ local function buildHandler(button) if button == 1 then spGiveOrderToUnit(facs[openedMenu + 1].unitID, -facs[openedMenu + 1].buildList[pressedBOpt + 1], {}, opt) - Spring.PlaySoundFile(sound_queue_add, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sound_queue_add, 0.75, "ui") elseif button == 3 then opt[#opt + 1] = "right" spGiveOrderToUnit(facs[openedMenu + 1].unitID, -facs[openedMenu + 1].buildList[pressedBOpt + 1], {}, opt) - Spring.PlaySoundFile(sound_queue_rem, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sound_queue_rem, 0.75, "ui") end end diff --git a/luaui/Widgets/gui_building_grid_gl4.lua b/luaui/Widgets/gui_building_grid_gl4.lua index fbcbbeba90c..236064f58a8 100644 --- a/luaui/Widgets/gui_building_grid_gl4.lua +++ b/luaui/Widgets/gui_building_grid_gl4.lua @@ -27,10 +27,10 @@ local config = { lineColor = { 0.70, 1.0, 0.70 }, -- color of the lines } -local waterLevel = Spring.GetWaterPlaneLevel and Spring.GetWaterPlaneLevel() or 0 +local waterLevel = SpringShared.GetWaterPlaneLevel and SpringShared.GetWaterPlaneLevel() or 0 local cmdShowForUnitDefID -local isPregame = Spring.GetGameFrame() == 0 and not isSpec +local isPregame = SpringShared.GetGameFrame() == 0 and not isSpec local gridVBO = nil -- the vertex buffer object, an array of vec2 coords local gridVAO = nil -- the vertex array object, a way of collecting buffer objects for submission to opengl @@ -109,7 +109,7 @@ void main(void) { ]] local function goodbye(reason) - Spring.Echo("Building Grid GL4 widget exiting with reason: " .. reason) + SpringShared.Echo("Building Grid GL4 widget exiting with reason: " .. reason) widgetHandler:RemoveWidget() end @@ -219,7 +219,7 @@ function widget:Initialize() end function widget:Update() - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() cmdShowForUnitDefID = cmdID ~= nil and cmdID < 0 and -cmdID or nil end @@ -232,8 +232,8 @@ function widget:DrawWorldPreUnit() local waterSurfaceMode = not UnitDefs[showUnitDefID].modCategories.underwater - local mx, my, _ = Spring.GetMouseState() - local _, mousePos = Spring.TraceScreenRay(mx, my, true, false, false, not waterSurfaceMode) + local mx, my, _ = SpringUnsynced.GetMouseState() + local _, mousePos = SpringUnsynced.TraceScreenRay(mx, my, true, false, false, not waterSurfaceMode) if not mousePos then return diff --git a/luaui/Widgets/gui_buildmenu.lua b/luaui/Widgets/gui_buildmenu.lua index 2aa785e38b2..2f22e727113 100644 --- a/luaui/Widgets/gui_buildmenu.lua +++ b/luaui/Widgets/gui_buildmenu.lua @@ -18,11 +18,11 @@ local mathFloor = math.floor local mathMax = math.max -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spGetGameSeconds = Spring.GetGameSeconds +local spGetGameFrame = SpringShared.GetGameFrame +local spGetGameSeconds = SpringShared.GetGameSeconds local spGetMyTeamID = Spring.GetMyTeamID -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState include("keysym.h.lua") local unitBlocking = VFS.Include("luaui/Include/unitBlocking.lua") @@ -118,15 +118,15 @@ local vsx, vsy = spGetViewGeometry() local ordermenuLeft = mathFloor(vsx / 5) local advplayerlistLeft = vsx * 0.8 -local ui_opacity = Spring.GetConfigFloat("ui_opacity", 0.7) -local ui_scale = Spring.GetConfigFloat("ui_scale", 1) +local ui_opacity = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7) +local ui_scale = SpringUnsynced.GetConfigFloat("ui_scale", 1) local units = VFS.Include("luaui/configs/unit_buildmenu_config.lua") local isSpec = spGetSpectatingState() local myTeamID = spGetMyTeamID() -local startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") +local startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") local disableInput = disableInputWhenSpec and isSpec local backgroundRect = { 0, 0, 0, 0 } @@ -197,17 +197,17 @@ local function refreshUnitDefs() end end -local spIsUnitSelected = Spring.IsUnitSelected -local spGetSelectedUnitsCount = Spring.GetSelectedUnitsCount -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetActiveCommand = Spring.GetActiveCommand -local spGetActiveCmdDescs = Spring.GetActiveCmdDescs -local spGetCmdDescIndex = Spring.GetCmdDescIndex -local spGetUnitDefID = Spring.GetUnitDefID -local spGetTeamRulesParam = Spring.GetTeamRulesParam -local spGetMouseState = Spring.GetMouseState -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitIsBuilding = Spring.GetUnitIsBuilding +local spIsUnitSelected = SpringUnsynced.IsUnitSelected +local spGetSelectedUnitsCount = SpringUnsynced.GetSelectedUnitsCount +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetActiveCmdDescs = SpringUnsynced.GetActiveCmdDescs +local spGetCmdDescIndex = SpringUnsynced.GetCmdDescIndex +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetTeamRulesParam = SpringShared.GetTeamRulesParam +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitIsBuilding = SpringShared.GetUnitIsBuilding local SelectedUnitsCount = spGetSelectedUnitsCount() @@ -608,7 +608,7 @@ function widget:Update(dt) SelectedUnitsCount = spGetSelectedUnitsCount() if SelectedUnitsCount > 0 then - local sel = Spring.GetSelectedUnits() + local sel = SpringUnsynced.GetSelectedUnits() for _, unitID in ipairs(sel) do local uDefID = spGetUnitDefID(unitID) if units.isFactory[uDefID] then @@ -693,7 +693,7 @@ function widget:Update(dt) widget:ViewResize() end - disableInput = Spring.IsGodModeEnabled() and false or (disableInputWhenSpec and isSpec) + disableInput = SpringShared.IsGodModeEnabled() and false or (disableInputWhenSpec and isSpec) end end @@ -957,7 +957,7 @@ function widget:DrawScreen() local hovering = false if math_isInRect(x, y, backgroundRect[1], backgroundRect[2], backgroundRect[3], backgroundRect[4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") hovering = true end @@ -972,7 +972,7 @@ function widget:DrawScreen() local uDefID = -cmds[cellRectID].id WG["buildmenu"].hoverID = uDefID gl.Color(1, 1, 1, 1) - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if WG["tooltip"] and not meta then -- when meta: unitstats does the tooltip local text @@ -1140,8 +1140,8 @@ function widget:DrawWorld() return end - if startDefID ~= Spring.GetTeamRulesParam(myTeamID, "startUnit") then - startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") + if startDefID ~= SpringShared.GetTeamRulesParam(myTeamID, "startUnit") then + startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") doUpdate = true end end @@ -1213,7 +1213,7 @@ end local function updateQuotaNumber(unitDefID, count) if WG.Quotas then local quotaChanged = false - for _, builderID in ipairs(Spring.GetSelectedUnits()) do + for _, builderID in ipairs(SpringUnsynced.GetSelectedUnits()) do local uDefID = spGetUnitDefID(builderID) if units.isFactory[uDefID] and table.contains(unitBuildOptions[uDefID], unitDefID) then local quotas = WG.Quotas.getQuotas() @@ -1230,7 +1230,7 @@ local function updateQuotaNumber(unitDefID, count) end local function changeQuotas(uDefID, quantity) - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if ctrl then quantity = quantity * modKeyMultiplier.ctrl end @@ -1241,7 +1241,7 @@ local function changeQuotas(uDefID, quantity) end function widget:MousePress(x, y, button) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if WG["topbar"] and WG["topbar"].showingQuit() then @@ -1269,10 +1269,10 @@ function widget:MousePress(x, y, button) if cmds[cellRectID] and cmds[cellRectID].id and unitTranslatedHumanName[-cmds[cellRectID].id] and math_isInRect(x, y, cellRect[1], cellRect[2], cellRect[3], cellRect[4]) and not units.unitRestricted[-cmds[cellRectID].id] then local uDefID = cmds[cellRectID].id --WARNING: THIS IS -unitDefID, not unitDefID local setQuotas = isOnQuotaBuildMode(-uDefID) - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if button ~= 3 then if playSounds then - Spring.PlaySoundFile(sound_queue_add, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sound_queue_add, 0.75, "ui") end if setQuotas and not alt then changeQuotas(-uDefID, 1) @@ -1285,7 +1285,7 @@ function widget:MousePress(x, y, button) if isRepeatMex then WG["areamex"].setAreaMexType(uDefID) end - Spring.SetActiveCommand(cmd, 1, true, false, alt, ctrl, meta, shift) + SpringUnsynced.SetActiveCommand(cmd, 1, true, false, alt, ctrl, meta, shift) end end else @@ -1293,18 +1293,18 @@ function widget:MousePress(x, y, button) local function decreaseQuota() if changeQuotas(-uDefID, modKeyMultiplier.right) and playSounds then - Spring.PlaySoundFile(sound_queue_rem, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sound_queue_rem, 0.75, "ui") end end local function decreaseQueue() if queueCount > 0 and playSounds then - Spring.PlaySoundFile(sound_queue_rem, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sound_queue_rem, 0.75, "ui") end if preGamestartPlayer then setPreGamestartDefID(-cmds[cellRectID].id) elseif spGetCmdDescIndex(cmds[cellRectID].id) then - Spring.SetActiveCommand(spGetCmdDescIndex(cmds[cellRectID].id), 3, false, true, Spring.GetModKeyState()) + SpringUnsynced.SetActiveCommand(spGetCmdDescIndex(cmds[cellRectID].id), 3, false, true, SpringUnsynced.GetModKeyState()) end end @@ -1360,9 +1360,9 @@ local function buildUnitHandler(_, _, _, data) -- Find the buildcycle for current key and iterate on it local pressedKey, pressedScan - for k, v in pairs(Spring.GetPressedKeys()) do + for k, v in pairs(SpringUnsynced.GetPressedKeys()) do if v and tonumber(k) then - local key = Spring.GetKeySymbol(tonumber(k)) + local key = SpringUnsynced.GetKeySymbol(tonumber(k)) if key and #key == 1 then pressedKey = key break @@ -1371,10 +1371,10 @@ local function buildUnitHandler(_, _, _, data) end -- check if engine supports GetPressedScans first, adjust when/if https://github.com/beyond-all-reason/spring/pull/388 is deployed - local pressedScans = Spring.GetPressedScans and Spring.GetPressedScans() or {} + local pressedScans = SpringUnsynced.GetPressedScans and SpringUnsynced.GetPressedScans() or {} for k, v in pairs(pressedScans) do if v and tonumber(k) then - local scan = Spring.GetScanSymbol(tonumber(k)) + local scan = SpringUnsynced.GetScanSymbol(tonumber(k)) if scan and #scan == 4 then -- quick hack to avoid modifiers pressedScan = scan break @@ -1390,7 +1390,7 @@ local function buildUnitHandler(_, _, _, data) -- Clear and reuse temp table instead of creating new one clearTable(buildCycleTemp) local buildCycleCount = 0 - for _, keybind in ipairs(Spring.GetKeyBindings(pressedKey, pressedScan)) do + for _, keybind in ipairs(SpringUnsynced.GetKeyBindings(pressedKey, pressedScan)) do if string_sub(keybind.command, 1, 10) == "buildunit_" then local uDefName = string_sub(keybind.command, 11) local uDef = UnitDefNames[uDefName] @@ -1630,7 +1630,7 @@ function widget:GetConfigData() defaultColls = defaultColls, stickToBottom = stickToBottom, maxPosY = maxPosY, - gameID = Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID"), + gameID = Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID"), alwaysShow = alwaysShow, } end diff --git a/luaui/Widgets/gui_buildspacing.lua b/luaui/Widgets/gui_buildspacing.lua index d0f5ff1cf8d..10f38828ab2 100644 --- a/luaui/Widgets/gui_buildspacing.lua +++ b/luaui/Widgets/gui_buildspacing.lua @@ -17,10 +17,10 @@ function widget:MousePress(mx, my, button) --local alt,ctrl,meta,shift = Spring.GetModKeyState() if button == 4 then -- Spring.SetActiveCommand("selfd") - Spring.SendCommands("buildspacing inc") + SpringUnsynced.SendCommands("buildspacing inc") return true elseif button == 5 then - Spring.SendCommands("buildspacing dec") + SpringUnsynced.SendCommands("buildspacing dec") return true end return false diff --git a/luaui/Widgets/gui_cache_icons.lua b/luaui/Widgets/gui_cache_icons.lua index c72b59cc1cd..d17ff8e7a52 100644 --- a/luaui/Widgets/gui_cache_icons.lua +++ b/luaui/Widgets/gui_cache_icons.lua @@ -14,16 +14,16 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local iconTypes = VFS.Include("gamedata/icontypes.lua") -local vsx, vsy = Spring.GetViewGeometry() +local vsx, vsy = SpringUnsynced.GetViewGeometry() local delayedCacheUnitIcons local delayedCacheUnitIconsTimer = 0 local cachedUnitIcons = false local startUnits = { UnitDefNames.armcom.id, UnitDefNames.corcom.id } -if Spring.GetModOptions().experimentallegionfaction then +if SpringShared.GetModOptions().experimentallegionfaction then startUnits[#startUnits + 1] = UnitDefNames.legcom.id end local startBuildOptions = {} diff --git a/luaui/Widgets/gui_camera_anchors.lua b/luaui/Widgets/gui_camera_anchors.lua index bedb5e5664e..56cc0f035ba 100644 --- a/luaui/Widgets/gui_camera_anchors.lua +++ b/luaui/Widgets/gui_camera_anchors.lua @@ -18,10 +18,10 @@ function widget:GetInfo() } end -local GetCameraState = Spring.GetCameraState -local SetCameraState = Spring.SetCameraState -local GetConfigInt = Spring.GetConfigInt -local SendCommands = Spring.SendCommands +local GetCameraState = SpringUnsynced.GetCameraState +local SetCameraState = SpringUnsynced.SetCameraState +local GetConfigInt = SpringUnsynced.GetConfigInt +local SendCommands = SpringUnsynced.SendCommands function widget:Initialize() widgetHandler:AddAction("set_camera_anchor", SetCameraAnchor, nil, "p") @@ -36,7 +36,7 @@ function SetCameraAnchor(_, _, args) cameraAnchors[anchorId] = cameraState - Spring.Echo("Camera anchor set: " .. anchorId) + SpringShared.Echo("Camera anchor set: " .. anchorId) return true end diff --git a/luaui/Widgets/gui_center_n_select.lua b/luaui/Widgets/gui_center_n_select.lua index e9d9bea5fe2..ce2477d59a9 100644 --- a/luaui/Widgets/gui_center_n_select.lua +++ b/luaui/Widgets/gui_center_n_select.lua @@ -22,18 +22,18 @@ local go = true -------------------------------------------------------------------------------- function widget:Update() - local t = Spring.GetGameSeconds() - local isSpec = select(3, Spring.GetPlayerInfo(Spring.GetMyPlayerID(), false)) + local t = SpringShared.GetGameSeconds() + local isSpec = select(3, SpringShared.GetPlayerInfo(Spring.GetMyPlayerID(), false)) if isSpec or t > 10 then widgetHandler:RemoveWidget() return end if t > 0 then - local unitArray = Spring.GetTeamUnits(Spring.GetMyTeamID()) + local unitArray = SpringShared.GetTeamUnits(Spring.GetMyTeamID()) if go and unitArray[1] then - local x, y, z = Spring.GetUnitPosition(unitArray[1]) - Spring.SetCameraTarget(x, y, z) - Spring.SelectUnitArray({ unitArray[1] }) + local x, y, z = SpringShared.GetUnitPosition(unitArray[1]) + SpringUnsynced.SetCameraTarget(x, y, z) + SpringUnsynced.SelectUnitArray({ unitArray[1] }) go = false end if not go then diff --git a/luaui/Widgets/gui_changelog_info.lua b/luaui/Widgets/gui_changelog_info.lua index 1defcaf0ad4..75d53290564 100644 --- a/luaui/Widgets/gui_changelog_info.lua +++ b/luaui/Widgets/gui_changelog_info.lua @@ -17,8 +17,8 @@ local mathFloor = math.floor local mathMax = math.max -- Localized Spring API for performance -local spGetMouseState = Spring.GetMouseState -local spGetViewGeometry = Spring.GetViewGeometry +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local vsx, vsy = spGetViewGeometry() @@ -45,7 +45,7 @@ local centerPosY = 0.5 local screenX = mathFloor((vsx * centerPosX) - (screenWidth / 2)) local screenY = mathFloor((vsy * centerPosY) + (screenHeight / 2)) -local spIsGUIHidden = Spring.IsGUIHidden +local spIsGUIHidden = SpringUnsynced.IsGUIHidden local glCreateList = gl.CreateList local glCallList = gl.CallList local glDeleteList = gl.DeleteList @@ -299,7 +299,7 @@ function widget:DrawScreen() local x, y, pressed = spGetMouseState() if math_isInRect(x, y, screenX, screenY - screenHeight, screenX + screenWidth, screenY) or math_isInRect(x, y, titleRect[1], titleRect[2], titleRect[3], titleRect[4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end if changelogFile then local lineKey = 1 @@ -389,7 +389,7 @@ function mouseEvent(x, y, button, release) end changelogList = gl.CreateList(DrawWindow) if playSounds then - Spring.PlaySoundFile(buttonclick, 0.6, "ui") + SpringUnsynced.PlaySoundFile(buttonclick, 0.6, "ui") end break end @@ -459,7 +459,7 @@ function widget:Initialize() end widget:ViewResize() else - Spring.Echo("Changelog: couldn't load the changelog file") + SpringShared.Echo("Changelog: couldn't load the changelog file") widgetHandler:RemoveWidget() end end diff --git a/luaui/Widgets/gui_chat.lua b/luaui/Widgets/gui_chat.lua index 264ae171b97..c3698e7b5c9 100644 --- a/luaui/Widgets/gui_chat.lua +++ b/luaui/Widgets/gui_chat.lua @@ -22,9 +22,9 @@ local mathMin = math.min -- Localized Spring API for performance local spGetMyTeamID = Spring.GetMyTeamID -local spGetMouseState = Spring.GetMouseState -local spEcho = Spring.Echo -local spGetSpectatingState = Spring.GetSpectatingState +local spGetMouseState = SpringUnsynced.GetMouseState +local spEcho = SpringShared.Echo +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local LineTypes = { Console = -1, @@ -67,8 +67,8 @@ local config = { allowMultiAutocomplete = true, allowMultiAutocompleteMax = 10, soundErrorsLimit = Spring.Utilities.IsDevMode() and 999 or 10, - ui_scale = Spring.GetConfigFloat("ui_scale", 1), - ui_opacity = Spring.GetConfigFloat("ui_opacity", 0.7), + ui_scale = SpringUnsynced.GetConfigFloat("ui_scale", 1), + ui_opacity = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7), widgetScale = 1, maxLinesScroll = 16, -- maxLinesScrollFull hide = false, @@ -76,8 +76,8 @@ local config = { fontsizeMult = 1, scrollingPosY = 0.66, consolePosY = 0.9, - hideSpecChat = (Spring.GetConfigInt("HideSpecChat", 0) == 1), - hideSpecChatPlayer = (Spring.GetConfigInt("HideSpecChatPlayer", 1) == 1), + hideSpecChat = (SpringUnsynced.GetConfigInt("HideSpecChat", 0) == 1), + hideSpecChatPlayer = (SpringUnsynced.GetConfigInt("HideSpecChatPlayer", 1) == 1), playSound = true, sndChatFile = "beep4", sndChatFileVolume = 0.55, @@ -143,7 +143,7 @@ local state = { lastUnitShare = nil, lastLineUnitShare = nil, lastDrawUiUpdate = os.clock(), - myName = Spring.GetPlayerInfo(Spring.GetMyPlayerID(), false), + myName = SpringShared.GetPlayerInfo(Spring.GetMyPlayerID(), false), mySpec = spGetSpectatingState(), myTeamID = spGetMyTeamID(), myAllyTeamID = Spring.GetMyAllyTeamID(), @@ -198,15 +198,15 @@ local gameOver = state.gameOver local prevGameID, prevOrgLines = state.prevGameID, state.prevOrgLines local ignoredAccounts = state.ignoredAccounts -local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode -local anonymousTeamColor = { Spring.GetConfigInt("anonymousColorR", 255) / 255, Spring.GetConfigInt("anonymousColorG", 0) / 255, Spring.GetConfigInt("anonymousColorB", 0) / 255 } +local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode +local anonymousTeamColor = { SpringUnsynced.GetConfigInt("anonymousColorR", 255) / 255, SpringUnsynced.GetConfigInt("anonymousColorG", 0) / 255, SpringUnsynced.GetConfigInt("anonymousColorB", 0) / 255 } -- Keep only essential locals for GL/Spring/strings (heavily used in loops) local glPopMatrix, glPushMatrix, glDeleteList, glCreateList, glCallList, glTranslate, glColor = gl.PopMatrix, gl.PushMatrix, gl.DeleteList, gl.CreateList, gl.CallList, gl.Translate, gl.Color local string_lines, schar, slen, ssub, sfind = string.lines, string.char, string.len, string.sub, string.find local math_isInRect, floor, clock = math.isInRect, mathFloor, os.clock -local spGetTeamColor, spGetPlayerInfo, spPlaySoundFile = Spring.GetTeamColor, Spring.GetPlayerInfo, Spring.PlaySoundFile -local spGetGameFrame, spGetTeamInfo = Spring.GetGameFrame, Spring.GetTeamInfo +local spGetTeamColor, spGetPlayerInfo, spPlaySoundFile = SpringUnsynced.GetTeamColor, SpringShared.GetPlayerInfo, SpringUnsynced.PlaySoundFile +local spGetGameFrame, spGetTeamInfo = SpringShared.GetGameFrame, SpringShared.GetTeamInfo local ColorString, ColorIsDark = Spring.Utilities and Spring.Utilities.Color and Spring.Utilities.Color.ToString, Spring.Utilities and Spring.Utilities.Color and Spring.Utilities.Color.ColorIsDark local soundErrors = {} @@ -495,7 +495,7 @@ local autocompleteCommands = { } local playernames = {} -local playersList = Spring.GetPlayerList() +local playersList = SpringShared.GetPlayerList() local chatProcessors = {} local unitTranslatedHumanName = {} local autocompleteText @@ -555,8 +555,8 @@ end widget:LanguageChanged() local function getAIName(teamID) - local _, _, _, name, _, options = Spring.GetAIInfo(teamID) - local niceName = Spring.GetGameRulesParam("ainame_" .. teamID) + local _, _, _, name, _, options = SpringShared.GetAIInfo(teamID) + local niceName = SpringShared.GetGameRulesParam("ainame_" .. teamID) if niceName then name = niceName if Spring.Utilities.ShowDevUI() and options.profile then @@ -774,7 +774,7 @@ local function addChatLine(gameFrame, lineType, name, nameText, text, orgLineID, end -- play sound for new player/spectator chat - if not ignore and #orgLines == orgLineID and (lineType == LineTypes.Player or lineType == LineTypes.Spectator) and playSound and not Spring.IsGUIHidden() then + if not ignore and #orgLines == orgLineID and (lineType == LineTypes.Player or lineType == LineTypes.Spectator) and playSound and not SpringUnsynced.IsGUIHidden() then spPlaySoundFile(sndChatFile, sndChatFileVolume, nil, "ui") end end @@ -796,7 +796,7 @@ local function cancelChatInput() WG["guishader"].RemoveRect("chatinput") WG["guishader"].RemoveRect("chatinputautocomplete") end - Spring.SDLStopTextInput() + SpringUnsynced.SDLStopTextInput() widgetHandler.textOwner = nil -- non handler = true: widgetHandler:DisownText() updateDrawUi = true end @@ -804,7 +804,7 @@ end local function commonUnitName(unitIDs) local commonUnitDefID = nil for _, unitID in pairs(unitIDs) do - local unitDefID = Spring.GetUnitDefID(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) -- unitDefID will be nil if shared units are visible only as unidentified radar dots -- (when spectating with PlayerView ON from enemy team's point of view) @@ -851,8 +851,8 @@ end -- Helper function to check if spectator messages should be hidden local function shouldHideSpecMessage() -- Check config values directly to ensure we have the latest settings - local currentHideSpecChat = (Spring.GetConfigInt("HideSpecChat", 0) == 1) - local currentHideSpecChatPlayer = (Spring.GetConfigInt("HideSpecChatPlayer", 1) == 1) + local currentHideSpecChat = (SpringUnsynced.GetConfigInt("HideSpecChat", 0) == 1) + local currentHideSpecChatPlayer = (SpringUnsynced.GetConfigInt("HideSpecChatPlayer", 1) == 1) return currentHideSpecChat and (not currentHideSpecChatPlayer or not mySpec) end @@ -1167,7 +1167,7 @@ function widget:UnitTaken(unitID, _, oldTeamID, newTeamID) local allyTeamShare = (oldAllyTeamID == myAllyTeamID and newAllyTeamID == myAllyTeamID) local selfShare = (oldTeamID == newTeamID) -- may happen if took other player - local _, _, _, captureProgress, _ = Spring.GetUnitHealth(unitID) + local _, _, _, captureProgress, _ = SpringShared.GetUnitHealth(unitID) local captured = (captureProgress == 1) if (not mySpec and not allyTeamShare) or selfShare or captured then return @@ -1328,13 +1328,13 @@ function widget:Update(dt) -- detect team colors changes local changeDetected = false local changedPlayers = {} - local teams = Spring.GetTeamList() + local teams = SpringShared.GetTeamList() for i = 1, #teams do local r, g, b = spGetTeamColor(teams[i]) if teamColorKeys[teams[i]] ~= r .. "_" .. g .. "_" .. b then teamColorKeys[teams[i]] = r .. "_" .. g .. "_" .. b changeDetected = true - for _, playerID in ipairs(Spring.GetPlayerList(teams[i])) do + for _, playerID in ipairs(SpringShared.GetPlayerList(teams[i])) do local name = spGetPlayerInfo(playerID, false) name = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerID)) or name changedPlayers[name] = true @@ -1379,9 +1379,9 @@ function widget:Update(dt) end -- detect spectator filter change - if hideSpecChat ~= (Spring.GetConfigInt("HideSpecChat", 0) == 1) or hideSpecChatPlayer ~= (Spring.GetConfigInt("HideSpecChatPlayer", 1) == 1) then - hideSpecChat = (Spring.GetConfigInt("HideSpecChat", 0) == 1) - hideSpecChatPlayer = (Spring.GetConfigInt("HideSpecChatPlayer", 1) == 1) + if hideSpecChat ~= (SpringUnsynced.GetConfigInt("HideSpecChat", 0) == 1) or hideSpecChatPlayer ~= (SpringUnsynced.GetConfigInt("HideSpecChatPlayer", 1) == 1) then + hideSpecChat = (SpringUnsynced.GetConfigInt("HideSpecChat", 0) == 1) + hideSpecChatPlayer = (SpringUnsynced.GetConfigInt("HideSpecChatPlayer", 1) == 1) for i = 1, #chatLines do if chatLines[i].lineType == LineTypes.Spectator then if shouldHideSpecMessage() then @@ -1415,7 +1415,7 @@ function widget:Update(dt) historyMode = false setCurrentChatLine(#chatLines) elseif math_isInRect(x, y, activationArea[1], activationArea[2], activationArea[3], activationArea[4]) then - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if showHistoryWhenCtrlShift and ctrl and shift then if math_isInRect(x, y, consoleActivationArea[1], consoleActivationArea[2], consoleActivationArea[3], consoleActivationArea[4]) then historyMode = "console" @@ -1438,7 +1438,7 @@ function widget:RecvLuaMsg(msg, playerID) if msg:sub(1, 18) == "LobbyOverlayActive" then chobbyInterface = (msg:sub(1, 19) == "LobbyOverlayActive1") if not chobbyInterface then - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! end end end @@ -1809,7 +1809,7 @@ drawTextInput = function() -- button hover local x, y, b = spGetMouseState() if inputButtonRect[1] and math_isInRect(x, y, inputButtonRect[1], inputButtonRect[2], inputButtonRect[3], inputButtonRect[4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") glColor(1, 1, 1, 0.075) RectRound(inputButtonRect[1], inputButtonRect[2], inputButtonRect[3], inputButtonRect[4], elementCorner * 0.6, 1, 0, 0, 1) end @@ -1829,7 +1829,7 @@ function widget:DrawScreen() return end - local _, ctrl, _, _ = Spring.GetModKeyState() + local _, ctrl, _, _ = SpringUnsynced.GetModKeyState() local x, y, b = spGetMouseState() local chatlogHeightDiff = historyMode and floor(vsy * (scrollingPosY - posY)) or 0 if hovering and WG["guishader"] then @@ -1917,12 +1917,12 @@ function widget:DrawScreen() if b then -- mapmark highlight if chatLines[i].coords then - Spring.SetCameraTarget(chatLines[i].coords[1], chatLines[i].coords[2], chatLines[i].coords[3]) + SpringUnsynced.SetCameraTarget(chatLines[i].coords[1], chatLines[i].coords[2], chatLines[i].coords[3]) end -- unit share if chatLines[i].selectUnits then - Spring.SelectUnitArray(chatLines[i].selectUnits) - Spring.SendCommands("viewselection") + SpringUnsynced.SelectUnitArray(chatLines[i].selectUnits) + SpringUnsynced.SendCommands("viewselection") end end end @@ -2093,7 +2093,7 @@ local function autocomplete(text, fresh) end function widget:TextInput(char) -- if it isnt working: chobby probably hijacked it - if handleTextInput and not chobbyInterface and not Spring.IsGUIHidden() and showTextInput then + if handleTextInput and not chobbyInterface and not SpringUnsynced.IsGUIHidden() and showTextInput then -- If there's a selection, delete it first if inputSelectionStart and inputSelectionStart ~= inputTextPosition then local selStart = math.min(inputSelectionStart, inputTextPosition) @@ -2134,11 +2134,11 @@ function widget:KeyRelease() end function widget:KeyPress(key) - if Spring.IsGUIHidden() or not handleTextInput then + if SpringUnsynced.IsGUIHidden() or not handleTextInput then return end - local alt, ctrl, _, shift = Spring.GetModKeyState() + local alt, ctrl, _, shift = SpringUnsynced.GetModKeyState() if key == 13 then -- RETURN (keypad enter = 271) if showTextInput then @@ -2155,13 +2155,13 @@ function widget:KeyPress(key) -- send chat/cmd if inputText ~= "" then if ssub(inputText, 1, 1) == "/" then - Spring.SendCommands(ssub(inputText, 2)) + SpringUnsynced.SendCommands(ssub(inputText, 2)) else local badWord = findBadWords(inputText) if badWord ~= nil and inputText ~= lastMessage then - addChatLine(Spring.GetGameFrame(), LineTypes.System, "Moderation", "\255\255\000\000" .. Spring.I18N("ui.chat.moderation.prefix"), Spring.I18N("ui.chat.moderation.blocked", { badWord = badWord })) + addChatLine(SpringShared.GetGameFrame(), LineTypes.System, "Moderation", "\255\255\000\000" .. Spring.I18N("ui.chat.moderation.prefix"), Spring.I18N("ui.chat.moderation.blocked", { badWord = badWord })) else - Spring.SendCommands("say " .. inputMode .. inputText) + SpringUnsynced.SendCommands("say " .. inputMode .. inputText) end lastMessage = inputText end @@ -2200,7 +2200,7 @@ function widget:KeyPress(key) inputMode = mySpec and "s:" or "a:" end -- again just to be safe, had report locking could still happen - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! end updateTextInputDlist = true @@ -2220,7 +2220,7 @@ function widget:KeyPress(key) inputTextPosition = selStart inputSelectionStart = nil end - local clipboardText = Spring.GetClipboard() + local clipboardText = SpringUnsynced.GetClipboard() inputText = utf8.sub(inputText, 1, inputTextPosition) .. clipboardText .. utf8.sub(inputText, inputTextPosition + 1) inputTextPosition = inputTextPosition + utf8.len(clipboardText) if string.len(inputText) > maxTextInputChars then @@ -2238,7 +2238,7 @@ function widget:KeyPress(key) local selStart = math.min(inputSelectionStart, inputTextPosition) local selEnd = math.max(inputSelectionStart, inputTextPosition) local selectedText = utf8.sub(inputText, selStart + 1, selEnd) - Spring.SetClipboard(selectedText) + SpringUnsynced.SetClipboard(selectedText) end elseif ctrl and key == 120 then -- CTRL + X @@ -2246,7 +2246,7 @@ function widget:KeyPress(key) local selStart = math.min(inputSelectionStart, inputTextPosition) local selEnd = math.max(inputSelectionStart, inputTextPosition) local selectedText = utf8.sub(inputText, selStart + 1, selEnd) - Spring.SetClipboard(selectedText) + SpringUnsynced.SetClipboard(selectedText) inputText = utf8.sub(inputText, 1, selStart) .. utf8.sub(inputText, selEnd + 1) inputTextPosition = selStart inputSelectionStart = nil @@ -2435,7 +2435,7 @@ function widget:KeyPress(key) end function widget:MousePress(x, y, button) - if button == 1 and handleTextInput and showTextInput and inputButton and inputButtonRect and not Spring.IsGUIHidden() and math_isInRect(x, y, inputButtonRect[1], inputButtonRect[2], inputButtonRect[3], inputButtonRect[4]) then + if button == 1 and handleTextInput and showTextInput and inputButton and inputButtonRect and not SpringUnsynced.IsGUIHidden() and math_isInRect(x, y, inputButtonRect[1], inputButtonRect[2], inputButtonRect[3], inputButtonRect[4]) then if inputMode == "a:" then inputMode = "" elseif inputMode == "s:" then @@ -2449,8 +2449,8 @@ function widget:MousePress(x, y, button) end function widget:MouseWheel(up, value) - if historyMode and not Spring.IsGUIHidden() then - local alt, ctrl, meta, shift = Spring.GetModKeyState() + if historyMode and not SpringUnsynced.IsGUIHidden() then + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if historyMode == "chat" then local scrollCount = 0 local scrollAmount = (shift and maxLinesScroll or (ctrl and 3 or 1)) @@ -2530,7 +2530,7 @@ function widget:AddConsoleLine(lines, priority) end function widget:ViewResize() - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() widgetScale = vsy * 0.00075 * ui_scale @@ -2618,7 +2618,7 @@ function widget:PlayerChanged(playerID) if isSpec ~= playernames[name].isSpec then playernames[name][2] = isSpec if isSpec then - playernames[name][8] = Spring.GetGameFrame() -- log frame of death + playernames[name][8] = SpringShared.GetGameFrame() -- log frame of death end end end @@ -2651,7 +2651,7 @@ local function hidespecchatCmd(_, _, params) else hideSpecChat = not hideSpecChat end - Spring.SetConfigInt("HideSpecChat", hideSpecChat and 1 or 0) + SpringUnsynced.SetConfigInt("HideSpecChat", hideSpecChat and 1 or 0) if hideSpecChat then spEcho("Hiding all spectator chat") else @@ -2665,7 +2665,7 @@ local function hidespecchatplayerCmd(_, _, params) else hideSpecChatPlayer = not hideSpecChatPlayer end - Spring.SetConfigInt("HideSpecChatPlayer", hideSpecChatPlayer and 1 or 0) + SpringUnsynced.SetConfigInt("HideSpecChatPlayer", hideSpecChatPlayer and 1 or 0) if hideSpecChat then spEcho("Hiding all spectator chat when player") else @@ -2684,7 +2684,7 @@ local function preventhistorymodeCmd(_, _, params) end function widget:Initialize() - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! -- Ensure ColorString and ColorIsDark are initialized if not ColorString and Spring.Utilities and Spring.Utilities.Color then @@ -2697,8 +2697,8 @@ function widget:Initialize() end -- Initialize team data - local gaiaTeamID = Spring.GetGaiaTeamID() - local teams = Spring.GetTeamList() + local gaiaTeamID = SpringShared.GetGaiaTeamID() + local teams = SpringShared.GetTeamList() for i = 1, #teams do local teamID = teams[i] local r, g, b = spGetTeamColor(teamID) @@ -2727,7 +2727,7 @@ function widget:Initialize() widget:ViewResize() widget:PlayerChanged(Spring.GetMyPlayerID()) - Spring.SendCommands("console 0") + SpringUnsynced.SendCommands("console 0") WG["chat"] = {} WG["chat"].isInputActive = function() @@ -2759,7 +2759,7 @@ function widget:Initialize() if not handleTextInput then cancelChatInput() end - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! end WG["chat"].getChatVolume = function() return sndChatFileVolume @@ -2868,8 +2868,8 @@ function widget:GetConfigData(data) end return { - gameFrame = Spring.GetGameFrame(), - gameID = Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID"), + gameFrame = SpringShared.GetGameFrame(), + gameID = Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID"), orgLines = gameOver and nil or orgLines, inputHistory = inputHistoryLimited, maxLines = maxLines, @@ -2892,7 +2892,7 @@ end function widget:SetConfigData(data) if data.orgLines ~= nil then - if Spring.GetGameFrame() > 0 or (data.gameID and data.gameID == (Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID"))) then + if SpringShared.GetGameFrame() > 0 or (data.gameID and data.gameID == (Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID"))) then if data.playernames then playernames = data.playernames end diff --git a/luaui/Widgets/gui_clearmapmarks.lua b/luaui/Widgets/gui_clearmapmarks.lua index 982b67de21c..24c98999956 100644 --- a/luaui/Widgets/gui_clearmapmarks.lua +++ b/luaui/Widgets/gui_clearmapmarks.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local iconTexture = ":n:LuaUI/Images/mapmarksfx/eraser.dds" local iconSize = 18 @@ -66,7 +66,7 @@ end local function updatePosition(force) if WG["advplayerlist_api"] ~= nil then - local vsx, vsy = Spring.GetViewGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() local margin = WG.FlowUI.elementPadding xPos = vsx - margin local prevPos = advplayerlistPos @@ -114,7 +114,7 @@ end function widget:DrawScreen() if drawlist[1] ~= nil then - local mx, my = Spring.GetMouseState() + local mx, my = SpringUnsynced.GetMouseState() glPushMatrix() glTranslate(xPos, yPos, 0) if math_isInRect(mx, my, xPos - usedImgSize, yPos, xPos, yPos + usedImgSize) then @@ -136,12 +136,12 @@ end function widget:MouseRelease(mx, my, mb) if mb == 1 and math_isInRect(mx, my, xPos - usedImgSize, yPos, xPos, yPos + usedImgSize) then - Spring.SendCommands({ "clearmapmarks" }) + SpringUnsynced.SendCommands({ "clearmapmarks" }) updatePosition(true) if Script.LuaUI("ClearMapMarks") then Script.LuaUI.ClearMapMarks() end - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if ctrl then continuouslyClean = not continuouslyClean WG.clearmapmarks.continuous = continuouslyClean diff --git a/luaui/Widgets/gui_com_nametags.lua b/luaui/Widgets/gui_com_nametags.lua index d35e3fb0320..acbae4e03a9 100644 --- a/luaui/Widgets/gui_com_nametags.lua +++ b/luaui/Widgets/gui_com_nametags.lua @@ -13,29 +13,29 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spGetViewGeometry = Spring.GetViewGeometry -local spWorldToScreenCoords = Spring.WorldToScreenCoords -local spGetSpectatingState = Spring.GetSpectatingState -local spGetUnitTeam = Spring.GetUnitTeam -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetTeamInfo = Spring.GetTeamInfo -local spGetPlayerList = Spring.GetPlayerList -local spGetTeamColor = Spring.GetTeamColor -local spGetUnitDefID = Spring.GetUnitDefID -local spGetTeamUnitsByDefs = Spring.GetTeamUnitsByDefs -local spIsUnitVisible = Spring.IsUnitVisible -local spIsUnitIcon = Spring.IsUnitIcon -local spGetCameraPosition = Spring.GetCameraPosition -local spGetUnitPosition = Spring.GetUnitPosition -local spGetTeamLuaAI = Spring.GetTeamLuaAI -local spGetGameRulesParam = Spring.GetGameRulesParam -local spGetTeamList = Spring.GetTeamList -local spGetGaiaTeamID = Spring.GetGaiaTeamID -local spGetModOptions = Spring.GetModOptions -local spGetConfigString = Spring.GetConfigString -local spIsGUIHidden = Spring.IsGUIHidden +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spWorldToScreenCoords = SpringUnsynced.WorldToScreenCoords +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetPlayerList = SpringShared.GetPlayerList +local spGetTeamColor = SpringUnsynced.GetTeamColor +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetTeamUnitsByDefs = SpringShared.GetTeamUnitsByDefs +local spIsUnitVisible = SpringUnsynced.IsUnitVisible +local spIsUnitIcon = SpringUnsynced.IsUnitIcon +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetTeamLuaAI = SpringShared.GetTeamLuaAI +local spGetGameRulesParam = SpringShared.GetGameRulesParam +local spGetTeamList = SpringShared.GetTeamList +local spGetGaiaTeamID = SpringShared.GetGaiaTeamID +local spGetModOptions = SpringShared.GetModOptions +local spGetConfigString = SpringUnsynced.GetConfigString +local spIsGUIHidden = SpringUnsynced.IsGUIHidden -- Localized Lua functions local mathFloor = math.floor @@ -109,7 +109,7 @@ local fonticon = glLoadFont(fontfile, fontfileSize * fontfileScale2, fontfileOut local singleTeams = false local teamListLen = #spGetTeamList() -local allyTeamListLen = #Spring.GetAllyTeamList() +local allyTeamListLen = #SpringShared.GetAllyTeamList() if teamListLen - 1 == allyTeamListLen - 1 then singleTeams = true end diff --git a/luaui/Widgets/gui_commanderhurt.lua b/luaui/Widgets/gui_commanderhurt.lua index 34986e30e3f..600c475c01b 100644 --- a/luaui/Widgets/gui_commanderhurt.lua +++ b/luaui/Widgets/gui_commanderhurt.lua @@ -13,9 +13,9 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState --------------------------------------------------------------------------------------------------- -- Declarations @@ -50,7 +50,7 @@ end function widget:Initialize() createList() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then widget:PlayerChanged() end end @@ -63,7 +63,7 @@ function widget:PlayerChanged(playerID) end function widget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer) - if damage > 3 and unitTeam == myTeamID and comUnitDefIDs[unitDefID] and not Spring.IsUnitVisible(unitID) then + if damage > 3 and unitTeam == myTeamID and comUnitDefIDs[unitDefID] and not SpringUnsynced.IsUnitVisible(unitID) then if spGetSpectatingState() then widgetHandler:RemoveWidget() return diff --git a/luaui/Widgets/gui_commands_fx.lua b/luaui/Widgets/gui_commands_fx.lua index cc34d447420..f492a07b246 100644 --- a/luaui/Widgets/gui_commands_fx.lua +++ b/luaui/Widgets/gui_commands_fx.lua @@ -17,7 +17,7 @@ local mathMax = math.max -- Localized Spring API for performance local spGetMyTeamID = Spring.GetMyTeamID -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState -- future: hotkey to show all current cmds? (like current shift+space) -- handle set target @@ -49,7 +49,7 @@ local CMDS = { local os_clock = os.clock local mathFloor = math.floor -local GaiaTeamID = Spring.GetGaiaTeamID() +local GaiaTeamID = SpringShared.GetGaiaTeamID() local myTeamID = spGetMyTeamID() local mySpec = spGetSpectatingState() local hidden @@ -142,17 +142,17 @@ local totalCommands = 0 local unitCommand = {} -- most recent key in command table of order for unitID local osClock -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitCommands = Spring.GetUnitCommands -local spIsUnitInView = Spring.IsUnitInView -local spIsSphereInView = Spring.IsSphereInView -local spValidUnitID = Spring.ValidUnitID -local spValidFeatureID = Spring.ValidFeatureID -local spGetFeaturePosition = Spring.GetFeaturePosition -local spIsGUIHidden = Spring.IsGUIHidden -local spLoadCmdColorsConfig = Spring.LoadCmdColorsConfig -local spGetGameFrame = Spring.GetGameFrame -local spGetUnitTeam = Spring.GetUnitTeam +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitCommands = SpringShared.GetUnitCommands +local spIsUnitInView = SpringUnsynced.IsUnitInView +local spIsSphereInView = SpringUnsynced.IsSphereInView +local spValidUnitID = SpringShared.ValidUnitID +local spValidFeatureID = SpringShared.ValidFeatureID +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spIsGUIHidden = SpringUnsynced.IsGUIHidden +local spLoadCmdColorsConfig = SpringUnsynced.LoadCmdColorsConfig +local spGetGameFrame = SpringShared.GetGameFrame +local spGetUnitTeam = SpringShared.GetUnitTeam local glDepthTest = gl.DepthTest local glBlending = gl.Blending @@ -269,7 +269,7 @@ local function InitGL4() uniformFloat = { u_lineTexLen = lineTextureLength }, }) if not shader then - Spring.Echo("[CommandsFX2] GL4 shader failed: " .. tostring(gl.GetShaderLog())) + SpringShared.Echo("[CommandsFX2] GL4 shader failed: " .. tostring(gl.GetShaderLog())) return false end @@ -406,9 +406,9 @@ end local teamColor = {} local function loadTeamColors() - local teams = Spring.GetTeamList() + local teams = SpringShared.GetTeamList() for i = 1, #teams do - local r, g, b = Spring.GetTeamColor(teams[i]) + local r, g, b = SpringUnsynced.GetTeamColor(teams[i]) local min = 0.12 teamColor[teams[i]] = { mathMax(r, min), mathMax(g, min), mathMax(b, min), 0.33 } end @@ -446,9 +446,9 @@ end local function resetEnabledTeams() enabledTeams = {} - local t = Spring.GetTeamList() + local t = SpringShared.GetTeamList() for _, teamID in ipairs(t) do - if not filterAIteams or not select(4, Spring.GetTeamInfo(teamID, false)) then + if not filterAIteams or not select(4, SpringShared.GetTeamInfo(teamID, false)) then enabledTeams[teamID] = true end end @@ -495,7 +495,7 @@ function widget:Initialize() end if not InitGL4() then - Spring.Echo("[CommandsFX2] GL4 initialization failed, disabling widget") + SpringShared.Echo("[CommandsFX2] GL4 initialization failed, disabling widget") widgetHandler:RemoveWidget(self) return end diff --git a/luaui/Widgets/gui_controller_test.lua b/luaui/Widgets/gui_controller_test.lua index a08a0efc229..644b71054a6 100644 --- a/luaui/Widgets/gui_controller_test.lua +++ b/luaui/Widgets/gui_controller_test.lua @@ -12,7 +12,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local connectedController local reportState = false diff --git a/luaui/Widgets/gui_converter_usage.lua b/luaui/Widgets/gui_converter_usage.lua index c6daddeed20..a62a9591111 100644 --- a/luaui/Widgets/gui_converter_usage.lua +++ b/luaui/Widgets/gui_converter_usage.lua @@ -13,9 +13,9 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetMouseState = Spring.GetMouseState +local spGetMouseState = SpringUnsynced.GetMouseState -local vsx, vsy = Spring.GetViewGeometry() +local vsx, vsy = SpringUnsynced.GetViewGeometry() local widgetScale = (0.80 + (vsx * vsy / 6000000)) local font2 @@ -25,7 +25,7 @@ local dlistGuishader, dlistCU local area = { 0, 0, 0, 0 } local spGetMyTeamID = Spring.GetMyTeamID -local spGetTeamRulesParam = Spring.GetTeamRulesParam +local spGetTeamRulesParam = SpringShared.GetTeamRulesParam local glCreateList = gl.CreateList local glCallList = gl.CallList @@ -128,7 +128,7 @@ function widget:DrawScreen() if area[1] then local x, y = spGetMouseState() if math.isInRect(x, y, area[1], area[2], area[3], area[4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end end end diff --git a/luaui/Widgets/gui_cursor.lua b/luaui/Widgets/gui_cursor.lua index c85a85d97ee..d4a8c6e0658 100644 --- a/luaui/Widgets/gui_cursor.lua +++ b/luaui/Widgets/gui_cursor.lua @@ -19,7 +19,7 @@ local mathAbs = math.abs local Settings = {} Settings["cursorSet"] = "icexuick" Settings["cursorSize"] = 100 -Settings["sizeMult"] = Spring.GetConfigFloat("cursorsize", 1) +Settings["sizeMult"] = SpringUnsynced.GetConfigFloat("cursorsize", 1) Settings["version"] = 6 -- just so it wont restore configdata on load if it differs format local force = true @@ -49,8 +49,8 @@ function NearestValue(table, number) end function widget:ViewResize() - local ssx, ssy = Spring.GetScreenGeometry() -- doesnt change when you unplug external display - autoCursorSize = 100 * (0.6 + (ssx * ssy / 10000000)) * Spring.GetConfigFloat("cursorsize", 1) + local ssx, ssy = SpringUnsynced.GetScreenGeometry() -- doesnt change when you unplug external display + autoCursorSize = 100 * (0.6 + (ssx * ssy / 10000000)) * SpringUnsynced.GetConfigFloat("cursorsize", 1) SetCursor(Settings["cursorSet"]) end @@ -74,10 +74,10 @@ function widget:Initialize() SetCursor(value) end WG["cursors"].getsizemult = function() - return Spring.GetConfigFloat("cursorsize", 1) + return SpringUnsynced.GetConfigFloat("cursorsize", 1) end WG["cursors"].setsizemult = function(value) - Spring.SetConfigFloat("cursorsize", value) + SpringUnsynced.SetConfigFloat("cursorsize", value) widget:ViewResize() end end @@ -86,7 +86,7 @@ function widget:Shutdown() WG["cursors"] = nil local file = VFS.LoadFile("cmdcolors.txt") if file then - Spring.LoadCmdColorsConfig(file) + SpringUnsynced.LoadCmdColorsConfig(file) end end @@ -135,7 +135,7 @@ function SetCursor(cursorSet) "uimove", } for i = 1, #cursorNames do - Spring.ReplaceMouseCursor(cursorNames[i], cursorDir .. "/" .. cursorNames[i], (cursorNames[i] == "cursornormal")) + SpringUnsynced.ReplaceMouseCursor(cursorNames[i], cursorDir .. "/" .. cursorNames[i], (cursorNames[i] == "cursornormal")) end --local files = VFS.DirList("anims/"..cursorDir.."/") @@ -150,17 +150,17 @@ function SetCursor(cursorSet) local file = VFS.LoadFile("cmdcolors_" .. cursorSet .. ".txt") if file then - Spring.LoadCmdColorsConfig(file) + SpringUnsynced.LoadCmdColorsConfig(file) end -- hide engine unit selection box if WG.selectedunits or WG.teamplatter or WG.highlightselunits then - Spring.LoadCmdColorsConfig("unitBox 0 1 0 0") + SpringUnsynced.LoadCmdColorsConfig("unitBox 0 1 0 0") end -- Hide metal extractor circles on non-metal maps if WG["resource_spot_finder"] and not WG["resource_spot_finder"].isMetalMap then - Spring.LoadCmdColorsConfig("rangeExtract 1.0 0.3 0.3 0.0") + SpringUnsynced.LoadCmdColorsConfig("rangeExtract 1.0 0.3 0.3 0.0") end end end @@ -172,9 +172,9 @@ end function widget:SetConfigData(data) if data and type(data) == "table" and data.version then if data.version < 6 and data.sizeMult then - Spring.SetConfigFloat("cursorsize", data.sizeMult) + SpringUnsynced.SetConfigFloat("cursorsize", data.sizeMult) end Settings = data - Settings["sizeMult"] = Spring.GetConfigFloat("cursorsize", 1) + Settings["sizeMult"] = SpringUnsynced.GetConfigFloat("cursorsize", 1) end end diff --git a/luaui/Widgets/gui_defenserange_gl4.lua b/luaui/Widgets/gui_defenserange_gl4.lua index b2f2ad40936..030d41d77f9 100644 --- a/luaui/Widgets/gui_defenserange_gl4.lua +++ b/luaui/Widgets/gui_defenserange_gl4.lua @@ -20,8 +20,8 @@ local mathMax = math.max local tableInsert = table.insert -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetUnitTeam = Spring.GetUnitTeam +local spEcho = SpringShared.Echo +local spGetUnitTeam = SpringShared.GetUnitTeam -- GL4 dev Notes: -- AA should be purple :D @@ -404,7 +404,7 @@ end --Button display configuration --position only relevant if no saved config data found -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local spec, fullview = spGetSpectatingState() local myAllyTeam = Spring.GetMyAllyTeamID() local numallyteams = 2 @@ -432,9 +432,9 @@ local glStencilOp = gl.StencilOp local GL_KEEP = 0x1E00 --GL.KEEP local GL_REPLACE = GL.REPLACE --GL.KEEP -local spGetPositionLosState = Spring.GetPositionLosState -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition +local spGetPositionLosState = SpringShared.GetPositionLosState +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition local chobbyInterface @@ -598,7 +598,7 @@ function widget:Initialize() end end myAllyTeam = Spring.GetMyAllyTeamID() - local allyteamlist = Spring.GetAllyTeamList() + local allyteamlist = SpringShared.GetAllyTeamList() --spEcho("# of allyteams = ", #allyteamlist) numallyteams = #allyteamlist @@ -629,7 +629,7 @@ local function UnitDetected(unitID, unitDefID, unitTeam, noUpload) -- otherwise we must add it! --local weapons = unitWeapons[unitDefID] - local alliedUnit = (Spring.GetUnitAllyTeam(unitID) == myAllyTeam) + local alliedUnit = (SpringShared.GetUnitAllyTeam(unitID) == myAllyTeam) local x, y, z, mpx, mpy, mpz, apx, apy, apz = spGetUnitPosition(unitID, true, true) --for weaponNum = 1, #weapons do @@ -644,7 +644,7 @@ local function UnitDetected(unitID, unitDefID, unitTeam, noUpload) local weaponID = i local ringParams = unitDefRings[unitDefID]["rings"][i] local x, y, z, mpx, mpy, mpz, apx, apy, apz = spGetUnitPosition(unitID, true, true) - local wpx, wpy, wpz, wdx, wdy, wdz = Spring.GetUnitWeaponVectors(unitID, weaponID) + local wpx, wpy, wpz, wdx, wdy, wdz = SpringShared.GetUnitWeaponVectors(unitID, weaponID) --spEcho("Defranges: unitID", unitID,x,y,z,"weaponID", weaponID, "y", y, "mpy", mpy,"wpy", wpy) -- Now this is a truly terrible hack, we cache each unitDefID's max weapon turret height at position 18 in the table @@ -695,7 +695,7 @@ function widget:VisibleUnitsChanged(extVisibleUnits, extNumVisibleUnits) -- the set of visible units changed. Now is a good time to reevalueate our life choices -- This happens when we move from team to team, or when we move from spec to other -- my - spec, fullview = Spring.GetSpectatingState() + spec, fullview = SpringUnsynced.GetSpectatingState() if (not enabledAsSpec) and spec then spEcho("Defense Range GL4 disabled in spectating state") widget:RemoveWidget() @@ -721,7 +721,7 @@ local function checkEnemyUnitConfirmedDead(unitID, defense) local _, losState, _ = spGetPositionLosState(x, y, z) --spEcho("checkEnemyUnitConfirmedDead",unitID, losState, spGetUnitDefID(unitID), Spring.GetUnitIsDead(unitID)) if losState then -- visible - if Spring.GetUnitIsDead(unitID) ~= false then -- If its cloaked and jammed, we cant see it i think + if SpringShared.GetUnitIsDead(unitID) ~= false then -- If its cloaked and jammed, we cant see it i think return true end end @@ -770,9 +770,9 @@ function widget:FeatureCreated(featureID, allyTeam) -- check if the feature we created could be related to a defense that we currently have active? -- ugh this will require a unitdefid based hash and some other nasty tricks -- check if the feature was created outside of LOS - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) if featureDefID and featureDefIDtoUnitDefID[featureDefID] then - local fx, fy, fz = Spring.GetFeaturePosition(featureID) + local fx, fy, fz = SpringShared.GetFeaturePosition(featureID) local poshash = floor(fx / 8) * 4096 + floor(fz / 8) local unitID = defensePosHash[poshash] if unitID then @@ -856,7 +856,7 @@ function widget:Update(dt) -- rebuild from whatever visibleUnits API you have local extVisibleUnits = (WG.unittrackerapi and WG.unittrackerapi.visibleUnits) or (function() local t = {} - for _, uid in ipairs(Spring.GetAllUnits()) do + for _, uid in ipairs(SpringShared.GetAllUnits()) do t[uid] = spGetUnitDefID(uid) end return t @@ -912,7 +912,7 @@ function widget:Update(dt) --spEcho("removestep", removestep , scanned) end -- DRAW THE ATTACK RING FOR THE ACTIVELY BUILDING UNIT - local cmdID = select(2, Spring.GetActiveCommand()) + local cmdID = select(2, SpringUnsynced.GetActiveCommand()) -- remove from queue every frame cause mouse will probably move anyway -- we kinda also need to remove if the allyenemy state changed if buildUnitDefID ~= nil then @@ -943,13 +943,13 @@ function widget:Update(dt) -- Ergo we should rather gate addition on buttonConfig in visibleUnitCreated -- instead of during the draw pass - local mx, my, lp, mp, rp, offscreen = Spring.GetMouseState() - local _, coords = Spring.TraceScreenRay(mx, my, true) + local mx, my, lp, mp, rp, offscreen = SpringUnsynced.GetMouseState() + local _, coords = SpringUnsynced.TraceScreenRay(mx, my, true) --spEcho(cmdID, "Attempting to draw rings at") --spEcho(mx, my, coords[1], coords[2], coords[3]) if coords and coords[1] and coords[2] and coords[3] then - local bpx, bpy, bpz = Spring.Pos2BuildPos(buildUnitDefID, coords[1], coords[2], coords[3]) + local bpx, bpy, bpz = SpringShared.Pos2BuildPos(buildUnitDefID, coords[1], coords[2], coords[3]) local allystring = "ally" for i, weaponType in pairs(unitDefRings[buildUnitDefID]["weapons"]) do local allystring = "ally" @@ -987,8 +987,8 @@ local drawcounts = {} local cameraHeightFactor = 0 local function GetCameraHeightFactor() -- returns a smoothstepped value between 0 and 1 for height based rescaling of line width. - local camX, camY, camZ = Spring.GetCameraPosition() - local camheight = camY - mathMax(Spring.GetGroundHeight(camX, camZ), 0) + local camX, camY, camZ = SpringUnsynced.GetCameraPosition() + local camheight = camY - mathMax(SpringShared.GetGroundHeight(camX, camZ), 0) -- Smoothstep to half line width as camera goes over 2k height to 4k height --genType t; /* Or genDType t; */ --t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); @@ -1050,7 +1050,7 @@ function widget:DrawWorld() if chobbyInterface then return end - if not Spring.IsGUIHidden() and (not WG["topbar"] or not WG["topbar"].showingQuit()) then + if not SpringUnsynced.IsGUIHidden() and (not WG["topbar"] or not WG["topbar"].showingQuit()) then cameraHeightFactor = GetCameraHeightFactor() * 0.5 + 0.5 glTexture(0, "$heightmap") glTexture(1, "$info") @@ -1090,7 +1090,7 @@ function widget:DrawWorld() glTexture(0, false) glTexture(1, false) glDepthTest(false) - if false and Spring.GetDrawFrame() % 60 == 0 then + if false and SpringUnsynced.GetDrawFrame() % 60 == 0 then local s = "drawcounts: " for k, v in pairs(drawcounts) do s = s .. " " .. tostring(k) .. ":" .. tostring(v) diff --git a/luaui/Widgets/gui_easyFacing.lua b/luaui/Widgets/gui_easyFacing.lua index 97e1339f899..752e49a8f4a 100644 --- a/luaui/Widgets/gui_easyFacing.lua +++ b/luaui/Widgets/gui_easyFacing.lua @@ -16,7 +16,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame -- 1.1 Tweaks by Pako, big thx! @@ -48,16 +48,16 @@ for udefID, def in ipairs(UnitDefs) do unitZsize[udefID] = def.zsize end -local spGetModKeyState = Spring.GetModKeyState -local spGetGameSeconds = Spring.GetGameSeconds -local spGetActiveCommand = Spring.GetActiveCommand -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay -local spGetCameraVectors = Spring.GetCameraVectors -local spWarpMouse = Spring.WarpMouse -local spGetBuildFacing = Spring.GetBuildFacing -local spSetBuildFacing = Spring.SetBuildFacing -local spPos2BuildPos = Spring.Pos2BuildPos +local spGetModKeyState = SpringUnsynced.GetModKeyState +local spGetGameSeconds = SpringShared.GetGameSeconds +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetCameraVectors = SpringUnsynced.GetCameraVectors +local spWarpMouse = SpringUnsynced.WarpMouse +local spGetBuildFacing = SpringUnsynced.GetBuildFacing +local spSetBuildFacing = SpringUnsynced.SetBuildFacing +local spPos2BuildPos = SpringShared.Pos2BuildPos local floor = math.floor local atan2 = math.atan2 @@ -76,7 +76,7 @@ local glScale = gl.Scale local GL_TRIANGLES = GL.TRIANGLES local function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -295,7 +295,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end diff --git a/luaui/Widgets/gui_ecostats.lua b/luaui/Widgets/gui_ecostats.lua index 194f7df1577..d460b57be01 100644 --- a/luaui/Widgets/gui_ecostats.lua +++ b/luaui/Widgets/gui_ecostats.lua @@ -33,37 +33,37 @@ local select = select local osClock = os.clock -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spEcho = Spring.Echo -local spGetSpectatingState = Spring.GetSpectatingState -local spGetTeamUnitsByDefs = Spring.GetTeamUnitsByDefs -local spGetGameSeconds = Spring.GetGameSeconds -local spGetGameSpeed = Spring.GetGameSpeed -local spGetTeamUnitCount = Spring.GetTeamUnitCount +local spEcho = SpringShared.Echo +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetTeamUnitsByDefs = SpringShared.GetTeamUnitsByDefs +local spGetGameSeconds = SpringShared.GetGameSeconds +local spGetGameSpeed = SpringUnsynced.GetGameSpeed +local spGetTeamUnitCount = SpringShared.GetTeamUnitCount local spGetMyAllyTeamID = Spring.GetMyAllyTeamID -local spGetTeamList = Spring.GetTeamList -local spGetTeamInfo = Spring.GetTeamInfo -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetTeamColor = Spring.GetTeamColor -local spGetTeamResources = Spring.GetTeamResources -local spGetUnitResources = Spring.GetUnitResources +local spGetTeamList = SpringShared.GetTeamList +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetTeamColor = SpringUnsynced.GetTeamColor +local spGetTeamResources = SpringShared.GetTeamResources +local spGetUnitResources = SpringShared.GetUnitResources local spGetMyPlayerID = Spring.GetMyPlayerID -local spGetGaiaTeamID = Spring.GetGaiaTeamID -local spGetAllyTeamList = Spring.GetAllyTeamList -local spIsReplay = Spring.IsReplay -local spGetLocalAllyTeamID = Spring.GetLocalAllyTeamID -local spGetViewGeometry = Spring.GetViewGeometry -local spGetTeamStartPosition = Spring.GetTeamStartPosition -local spGetTeamUnitDefCount = Spring.GetTeamUnitDefCount -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetAllUnits = Spring.GetAllUnits -local spGetTeamUnitsByDefs = Spring.GetTeamUnitsByDefs -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetMouseState = Spring.GetMouseState -local spSetMouseCursor = Spring.SetMouseCursor -local spGetConfigFloat = Spring.GetConfigFloat +local spGetGaiaTeamID = SpringShared.GetGaiaTeamID +local spGetAllyTeamList = SpringShared.GetAllyTeamList +local spIsReplay = SpringUnsynced.IsReplay +local spGetLocalAllyTeamID = SpringUnsynced.GetLocalAllyTeamID +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetTeamStartPosition = SpringShared.GetTeamStartPosition +local spGetTeamUnitDefCount = SpringShared.GetTeamUnitDefCount +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetAllUnits = SpringShared.GetAllUnits +local spGetTeamUnitsByDefs = SpringShared.GetTeamUnitsByDefs +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetMouseState = SpringUnsynced.GetMouseState +local spSetMouseCursor = SpringUnsynced.SetMouseCursor +local spGetConfigFloat = SpringUnsynced.GetConfigFloat -- Localized GL API local glColor = gl.Color @@ -689,7 +689,7 @@ local function removeGuiShaderRects() if tooltipAreas[key] ~= nil then WG["tooltip"].RemoveTooltip(key) tooltipAreas[key] = nil - local teams = Spring.GetTeamList(aID) + local teams = SpringShared.GetTeamList(aID) for _, tID in ipairs(teams) do WG["tooltip"].RemoveTooltip(eco.ecoTeamKey[tID] or ("ecostats_team_" .. tID)) end @@ -1355,36 +1355,36 @@ function widget:MousePress(x, y, button) if com then local cx, cy, cz - local camState = Spring.GetCameraState() - cx, cy, cz = Spring.GetUnitPosition(com) + local camState = SpringUnsynced.GetCameraState() + cx, cy, cz = SpringShared.GetUnitPosition(com) if camState and cx then camState.px = cx camState.py = cy camState.pz = cz camState.height = 800 - Spring.SetCameraState(camState, 0.75) + SpringUnsynced.SetCameraState(camState, 0.75) if inSpecMode then - Spring.SelectUnitArray({ com }) + SpringUnsynced.SelectUnitArray({ com }) end elseif cx then - Spring.SetCameraTarget(cx, cy, cz, 0.5) + SpringUnsynced.SetCameraTarget(cx, cy, cz, 0.5) end end elseif not ctrlDown then local sx = teamData[teamID].startx local sz = teamData[teamID].starty if sx ~= nil and sz ~= nil then - local sy = Spring.GetGroundHeight(sx, sz) - local camState = Spring.GetCameraState() + local sy = SpringShared.GetGroundHeight(sx, sz) + local camState = SpringUnsynced.GetCameraState() if camState and sx and sz and sx > 0 and sz > 0 then camState.px = sx camState.py = sy camState.pz = sz camState.height = 5000 - Spring.SetCameraState(camState, 2) + SpringUnsynced.SetCameraState(camState, 2) elseif sx then - Spring.SetCameraTarget(sx, sy, sz, 0.5) + SpringUnsynced.SetCameraTarget(sx, sy, sz, 0.5) end end end diff --git a/luaui/Widgets/gui_emp_decloak_range.lua b/luaui/Widgets/gui_emp_decloak_range.lua index e0721d1d458..23a61de4497 100644 --- a/luaui/Widgets/gui_emp_decloak_range.lua +++ b/luaui/Widgets/gui_emp_decloak_range.lua @@ -25,7 +25,7 @@ local mathSin = math.sin local mathPi = math.pi -- Localized Spring API for performance -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState -------------------------------------------------------------------------------- -- OPTIONS @@ -55,18 +55,18 @@ local glLineWidth = gl.LineWidth local glDepthTest = gl.DepthTest local glDrawGroundCircle = gl.DrawGroundCircle -local spGetAllUnits = Spring.GetAllUnits -local spGetTeamUnitsByDefs = Spring.GetTeamUnitsByDefs -local spGetTeamList = Spring.GetTeamList -local spGetCameraPosition = Spring.GetCameraPosition -local spGetUnitPosition = Spring.GetUnitPosition -local spIsSphereInView = Spring.IsSphereInView -local spIsUnitSelected = Spring.IsUnitSelected -local spValidUnitID = Spring.ValidUnitID -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitIsCloaked = Spring.GetUnitIsCloaked -local spGetGameSeconds = Spring.GetGameSeconds +local spGetAllUnits = SpringShared.GetAllUnits +local spGetTeamUnitsByDefs = SpringShared.GetTeamUnitsByDefs +local spGetTeamList = SpringShared.GetTeamList +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spGetUnitPosition = SpringShared.GetUnitPosition +local spIsSphereInView = SpringUnsynced.IsSphereInView +local spIsUnitSelected = SpringUnsynced.IsUnitSelected +local spValidUnitID = SpringShared.ValidUnitID +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitIsCloaked = SpringShared.GetUnitIsCloaked +local spGetGameSeconds = SpringShared.GetGameSeconds -------------------------------------------------------------------------------- -- COMMAND CONSTANTS @@ -211,7 +211,7 @@ end -- DRAWING -------------------------------------------------------------------------------- function widget:DrawWorldPreUnit() - if chobbyInterface or Spring.IsGUIHidden() then + if chobbyInterface or SpringUnsynced.IsGUIHidden() then return end diff --git a/luaui/Widgets/gui_enemy_spotter.lua b/luaui/Widgets/gui_enemy_spotter.lua index 863d34e7beb..626f6b8a023 100644 --- a/luaui/Widgets/gui_enemy_spotter.lua +++ b/luaui/Widgets/gui_enemy_spotter.lua @@ -34,10 +34,10 @@ local glDepthTest = gl.DepthTest local glTexture = gl.Texture local GL_POINTS = GL.POINTS -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam local myAllyTeamID = Spring.GetMyAllyTeamID() -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() local unitScale = {} local unitDecoration = {} @@ -55,10 +55,10 @@ end local teamLeader = {} local allyTeamLeader = {} -local teams = Spring.GetTeamList() +local teams = SpringShared.GetTeamList() for i = 1, #teams do local teamID = teams[i] - local allyTeamID = select(6, Spring.GetTeamInfo(teamID, false)) + local allyTeamID = select(6, SpringShared.GetTeamInfo(teamID, false)) if not allyTeamLeader[allyTeamID] then allyTeamLeader[allyTeamID] = teamID -- assign which team color to use for whole allyteam end @@ -100,7 +100,7 @@ end local drawFrame = 0 function widget:DrawWorldPreUnit() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end drawFrame = drawFrame + 1 @@ -138,7 +138,7 @@ end function widget:VisibleUnitsChanged(extVisibleUnits, extNumVisibleUnits) InstanceVBOTable.clearInstanceTable(enemyspotterVBO) -- clear all instances for unitID, unitDefID in pairs(extVisibleUnits) do - AddUnit(unitID, unitDefID, Spring.GetUnitTeam(unitID), true) -- add them with noUpload = true + AddUnit(unitID, unitDefID, SpringShared.GetUnitTeam(unitID), true) -- add them with noUpload = true end InstanceVBOTable.uploadAllElements(enemyspotterVBO) -- upload them all end @@ -167,7 +167,7 @@ local function init() if WG["unittrackerapi"] and WG["unittrackerapi"].visibleUnits then widget:VisibleUnitsChanged(WG["unittrackerapi"].visibleUnits, nil) else - Spring.Echo("Enemy spotter needs unittrackerapi to work!") + SpringShared.Echo("Enemy spotter needs unittrackerapi to work!") widgetHandler:RemoveWidget() return false end diff --git a/luaui/Widgets/gui_factionpicker.lua b/luaui/Widgets/gui_factionpicker.lua index 383b1a7e4a3..704c7edab16 100644 --- a/luaui/Widgets/gui_factionpicker.lua +++ b/luaui/Widgets/gui_factionpicker.lua @@ -16,8 +16,8 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local factions = {} @@ -33,9 +33,9 @@ local bgBorder = bgBorderOrg local myTeamID = Spring.GetMyTeamID() local stickToBottom = true -local startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") +local startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") do - local validStartUnits = string.split(Spring.GetTeamRulesParam(myTeamID, "validStartUnits") or Spring.GetGameRulesParam("validStartUnits"), "|") + local validStartUnits = string.split(SpringShared.GetTeamRulesParam(myTeamID, "validStartUnits") or SpringShared.GetGameRulesParam("validStartUnits"), "|") for i, unitID_string in ipairs(validStartUnits) do -- TODO: figure out a better approach to this as sidedata faction names and language file keys do not match local unitID = tonumber(unitID_string) @@ -58,7 +58,7 @@ do end end if #factions == 0 then - Spring.Log(gadget:GetInfo().name, LOG.ERROR, "No Start Options Recived") + SpringShared.Log(gadget:GetInfo().name, LOG.ERROR, "No Start Options Recived") return false end @@ -71,7 +71,7 @@ local vsx, vsy = spGetViewGeometry() local sound_button = "LuaUI/Sounds/buildbar_waypoint.wav" -local ui_scale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local ui_scale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) local isSpec = spGetSpectatingState() local backgroundRect = {} @@ -115,7 +115,7 @@ local function drawFactionpicker() mathFloor(backgroundRect[3] - padding - (cellSize * (i - 1))), mathFloor(backgroundRect[2] + cellSize), } - local disabled = Spring.GetTeamRulesParam(myTeamID, "startUnit") ~= factions[i].startUnit + local disabled = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") ~= factions[i].startUnit if disabled then glColor(0.55, 0.55, 0.55, 1) else @@ -216,13 +216,13 @@ function widget:ViewResize() end function widget:Initialize() - if isSpec or Spring.GetGameFrame() > 0 then + if isSpec or SpringShared.GetGameFrame() > 0 then widgetHandler:RemoveWidget() return end - if Spring.GetModOptions().scenariooptions then - local scenarioopts = string.base64Decode(Spring.GetModOptions().scenariooptions) + if SpringShared.GetModOptions().scenariooptions then + local scenarioopts = string.base64Decode(SpringShared.GetModOptions().scenariooptions) scenarioopts = Json.decode(scenarioopts) if scenarioopts and scenarioopts.disablefactionpicker == true then widgetHandler:RemoveWidget() @@ -283,15 +283,15 @@ function widget:Update(dt) end function widget:DrawScreen() - local x, y, b = Spring.GetMouseState() + local x, y, b = SpringUnsynced.GetMouseState() if not WG["topbar"] or not WG["topbar"].showingQuit() then if math_isInRect(x, y, backgroundRect[1], backgroundRect[2], backgroundRect[3], backgroundRect[4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end end - if startDefID ~= Spring.GetTeamRulesParam(myTeamID, "startUnit") then - startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") + if startDefID ~= SpringShared.GetTeamRulesParam(myTeamID, "startUnit") then + startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") doUpdate = true end @@ -359,10 +359,10 @@ function widget:MousePress(x, y, button) for i, faction in pairs(factions) do if math_isInRect(x, y, factionRect[i][1], factionRect[i][2], factionRect[i][3], factionRect[i][4]) then if playSounds then - Spring.PlaySoundFile(sound_button, 0.6, "ui") + SpringUnsynced.PlaySoundFile(sound_button, 0.6, "ui") end -- tell initial spawn - Spring.SendLuaRulesMsg("changeStartUnit" .. tostring(factions[i].startUnit)) + SpringUnsynced.SendLuaRulesMsg("changeStartUnit" .. tostring(factions[i].startUnit)) break end end diff --git a/luaui/Widgets/gui_flanking_icons.lua b/luaui/Widgets/gui_flanking_icons.lua index bf59594fec8..6e59df9143b 100644 --- a/luaui/Widgets/gui_flanking_icons.lua +++ b/luaui/Widgets/gui_flanking_icons.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState -- Configurable Parts: local texture = "luaui/images/flank_icon.tga" @@ -39,11 +39,11 @@ end local spec, fullview = spGetSpectatingState() local allyTeamID = Spring.GetMyAllyTeamID() -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitRadius = Spring.GetUnitRadius -local spGetUnitFlanking = Spring.GetUnitFlanking -local spGetGameFrame = Spring.GetGameFrame -local spIsUnitAllied = Spring.IsUnitAllied +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitRadius = SpringShared.GetUnitRadius +local spGetUnitFlanking = SpringShared.GetUnitFlanking +local spGetGameFrame = SpringShared.GetGameFrame +local spIsUnitAllied = SpringUnsynced.IsUnitAllied local instanceCache = { 0, @@ -101,11 +101,11 @@ function widget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer) end function widget:DrawWorldPreUnit() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if flankingVBO.usedElements > 0 then - local disticon = 27 * Spring.GetConfigInt("UnitIconDist", 200) -- iconLength = unitIconDist * unitIconDist * 750.0f; + local disticon = 27 * SpringUnsynced.GetConfigInt("UnitIconDist", 200) -- iconLength = unitIconDist * unitIconDist * 750.0f; glTexture(0, texture) flankingShader:Activate() flankingShader:SetUniform("iconDistance", disticon) diff --git a/luaui/Widgets/gui_flowui.lua b/luaui/Widgets/gui_flowui.lua index 8229355b3f9..a4c364e4ccb 100644 --- a/luaui/Widgets/gui_flowui.lua +++ b/luaui/Widgets/gui_flowui.lua @@ -19,17 +19,17 @@ local mathMin = math.min local mathPi = math.pi -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry WG.FlowUI = WG.FlowUI or {} WG.FlowUI.version = 1 WG.FlowUI.initialized = false -WG.FlowUI.opacity = Spring.GetConfigFloat("ui_opacity", 0.7) +WG.FlowUI.opacity = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7) WG.FlowUI.clampedOpacity = mathMax(0.75, WG.FlowUI.opacity) -WG.FlowUI.scale = Spring.GetConfigFloat("ui_scale", 1) -WG.FlowUI.tileOpacity = Spring.GetConfigFloat("ui_tileopacity", 0.014) -WG.FlowUI.tileScale = Spring.GetConfigFloat("ui_tilescale", 7) +WG.FlowUI.scale = SpringUnsynced.GetConfigFloat("ui_scale", 1) +WG.FlowUI.tileOpacity = SpringUnsynced.GetConfigFloat("ui_tileopacity", 0.014) +WG.FlowUI.tileScale = SpringUnsynced.GetConfigFloat("ui_tilescale", 7) WG.FlowUI.tileSize = WG.FlowUI.tileScale -- Guishader display list lifecycle helpers @@ -107,7 +107,7 @@ function widget:Shutdown() end function widget:DrawScreenEffects() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end end diff --git a/luaui/Widgets/gui_fonthandler.lua b/luaui/Widgets/gui_fonthandler.lua index 25ad5b96e9e..105b2c6fa7e 100644 --- a/luaui/Widgets/gui_fonthandler.lua +++ b/luaui/Widgets/gui_fonthandler.lua @@ -16,21 +16,21 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local vsx, vsy = spGetViewGeometry() -local defaultFont = "fonts/" .. Spring.GetConfigString("bar_font", "Poppins-Regular.otf") -local defaultFont2 = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") -local defaultFont3 = "fonts/monospaced/" .. Spring.GetConfigString("bar_font3", "SourceCodePro-Medium.otf") +local defaultFont = "fonts/" .. SpringUnsynced.GetConfigString("bar_font", "Poppins-Regular.otf") +local defaultFont2 = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") +local defaultFont3 = "fonts/monospaced/" .. SpringUnsynced.GetConfigString("bar_font3", "SourceCodePro-Medium.otf") local defaultSize = 34 local defaultOutlineStrength = 1.7 local defaultOutlineSize -- assigned in ViewResize -local ui_scale = Spring.GetConfigFloat("ui_scale", 1) +local ui_scale = SpringUnsynced.GetConfigFloat("ui_scale", 1) local fonts = {} local fontScale = 1 @@ -130,7 +130,7 @@ function widget:GetConfigData() end function widget:SetConfigData(data) - if Spring.GetGameFrame() > 0 then + if SpringShared.GetGameFrame() > 0 then if data.fonts ~= nil then fonts = data.fonts -- not sure why BYAR.lua just shows empty table while it has the fonts when restoring o_0 fontScale = data.fontScale diff --git a/luaui/Widgets/gui_game_type_info.lua b/luaui/Widgets/gui_game_type_info.lua index c511bb91afd..2640277fa02 100644 --- a/luaui/Widgets/gui_game_type_info.lua +++ b/luaui/Widgets/gui_game_type_info.lua @@ -27,7 +27,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local vsx, vsy = spGetViewGeometry() local widgetScale = 0.80 + (vsx * vsy / 6000000) @@ -36,13 +36,13 @@ local glPopMatrix = gl.PopMatrix local glPushMatrix = gl.PushMatrix local glScale = gl.Scale local glTranslate = gl.Translate -local spGetGameSeconds = Spring.GetGameSeconds +local spGetGameSeconds = SpringShared.GetGameSeconds local messages = {} local font -local draftMode = Spring.GetModOptions().draft_mode +local draftMode = SpringShared.GetModOptions().draft_mode function widget:ViewResize() vsx, vsy = spGetViewGeometry() @@ -67,14 +67,14 @@ function widget:ViewResize() end function widget:Initialize() - if Spring.GetModOptions().deathmode == "neverend" then + if SpringShared.GetModOptions().deathmode == "neverend" then widgetHandler:RemoveWidget() return end messages[1] = {} - if Spring.GetModOptions().deathmode == "own_com" then + if SpringShared.GetModOptions().deathmode == "own_com" then messages[3] = {} end @@ -85,7 +85,7 @@ end function widget:LanguageChanged() local key - local deathmode = Spring.GetModOptions().deathmode + local deathmode = SpringShared.GetModOptions().deathmode if deathmode == "killall" then key = "killAllUnits" diff --git a/luaui/Widgets/gui_gameinfo.lua b/luaui/Widgets/gui_gameinfo.lua index e5d82a42310..9de677fa50f 100644 --- a/luaui/Widgets/gui_gameinfo.lua +++ b/luaui/Widgets/gui_gameinfo.lua @@ -18,7 +18,7 @@ local mathMax = math.max local tableInsert = table.insert -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local titlecolor = "\255\255\205\100" local keycolor = "" @@ -35,7 +35,7 @@ local raptorsEnabled = Spring.Utilities.Gametype.IsRaptors() local content = "" local tidal = Game.tidal -local map_tidal = Spring.GetModOptions().map_tidal +local map_tidal = SpringShared.GetModOptions().map_tidal local reclaimable_metal = 0 local reclaimable_energy = 0 @@ -48,8 +48,8 @@ elseif map_tidal == "high" then tidal = 23 end -if Spring.GetTidal then - tidal = Spring.GetTidal() +if SpringShared.GetTidal then + tidal = SpringShared.GetTidal() end -- modoptions @@ -335,9 +335,9 @@ function widget:DrawScreen() end showOnceMore = false - local x, y, pressed = Spring.GetMouseState() + local x, y, pressed = SpringUnsynced.GetMouseState() if math_isInRect(x, y, screenX, screenY - screenHeight, screenX + screenWidth, screenY) or math_isInRect(x, y, titleRect[1], titleRect[2], titleRect[3], titleRect[4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end else @@ -383,7 +383,7 @@ function widget:MouseRelease(x, y, button) end function mouseEvent(x, y, button, release) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return false end @@ -469,10 +469,10 @@ local function closeInfoHandler() end end -local spGetAllFeatures = Spring.GetAllFeatures -local spGetFeatureResources = Spring.GetFeatureResources -local spGetFeatureTeam = Spring.GetFeatureTeam -local spGetGaiaTeamID = Spring.GetGaiaTeamID +local spGetAllFeatures = SpringShared.GetAllFeatures +local spGetFeatureResources = SpringShared.GetFeatureResources +local spGetFeatureTeam = SpringShared.GetFeatureTeam +local spGetGaiaTeamID = SpringShared.GetGaiaTeamID local gaiaTeamId = spGetGaiaTeamID() function widget:GamePreload() diff --git a/luaui/Widgets/gui_geothermalspots.lua b/luaui/Widgets/gui_geothermalspots.lua index 87aa1908982..57dd1613abf 100644 --- a/luaui/Widgets/gui_geothermalspots.lua +++ b/luaui/Widgets/gui_geothermalspots.lua @@ -17,8 +17,8 @@ local mathSin = math.sin local mathCos = math.cos -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spGetSpectatingState = Spring.GetSpectatingState +local spGetGameFrame = SpringShared.GetGameFrame +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local showValue = false local metalViewOnly = false @@ -30,11 +30,11 @@ local opacity = 0.5 local innersize = 3.0 -- outersize-innersize = circle width local outersize = 3.32 -- outersize-innersize = circle width -local spIsGUIHidden = Spring.IsGUIHidden -local spGetUnitsInSphere = Spring.GetUnitsInSphere -local spGetUnitDefID = Spring.GetUnitDefID -local spGetGroundHeight = Spring.GetGroundHeight -local spGetMapDrawMode = Spring.GetMapDrawMode +local spIsGUIHidden = SpringUnsynced.IsGUIHidden +local spGetUnitsInSphere = SpringShared.GetUnitsInSphere +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetMapDrawMode = SpringUnsynced.GetMapDrawMode local spots = {} local numSpots = 0 @@ -66,9 +66,9 @@ for defID, def in pairs(FeatureDefs) do end end -local spGetAllFeatures = Spring.GetAllFeatures -local spGetFeatureDefID = Spring.GetFeatureDefID -local spGetFeaturePosition = Spring.GetFeaturePosition +local spGetAllFeatures = SpringShared.GetAllFeatures +local spGetFeatureDefID = SpringShared.GetFeatureDefID +local spGetFeaturePosition = SpringShared.GetFeaturePosition local showGeothermalUnits = false local function checkGeothermalFeatures() @@ -175,7 +175,7 @@ void main(void) ]] local function goodbye(reason) - Spring.Echo("Geothermalspots GL4 widget exiting with reason: " .. reason) + SpringShared.Echo("Geothermalspots GL4 widget exiting with reason: " .. reason) widgetHandler:RemoveWidget() end @@ -393,7 +393,7 @@ end function widget:ViewResize() local old_vsx, old_vsy = vsx, vsy - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() if old_vsx ~= vsx or old_vsy ~= vsy then widget:Initialize() end diff --git a/luaui/Widgets/gui_given_units.lua b/luaui/Widgets/gui_given_units.lua index e2cbb52db79..1ccbf9b9b4c 100644 --- a/luaui/Widgets/gui_given_units.lua +++ b/luaui/Widgets/gui_given_units.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame -- config local selectedFadeTime = 0.75 @@ -24,10 +24,10 @@ local timeoutTime = 6.5 -- better icon because bloom makes the letters unreadable local glDrawListAtUnit = gl.DrawListAtUnit -local spIsGUIHidden = Spring.IsGUIHidden -local spGetUnitDefID = Spring.GetUnitDefID -local spIsUnitInView = Spring.IsUnitInView -local spGetCameraDirection = Spring.GetCameraDirection +local spIsGUIHidden = SpringUnsynced.IsGUIHidden +local spGetUnitDefID = SpringShared.GetUnitDefID +local spIsUnitInView = SpringUnsynced.IsUnitInView +local spGetCameraDirection = SpringUnsynced.GetCameraDirection local drawList local givenUnits = {} @@ -35,7 +35,7 @@ local unitScale = {} local unitHeight = {} local sec = 0 local prevCam = { spGetCameraDirection() } -local myTeamID = Spring.GetLocalTeamID() +local myTeamID = SpringUnsynced.GetLocalTeamID() local gameStarted, selectionChanged @@ -68,7 +68,7 @@ end -------------------------------------------------------------------------------- function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -83,7 +83,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end drawList = gl.CreateList(DrawIcon) @@ -99,7 +99,7 @@ function widget:Update(dt) sec = 0 if selectionChanged then selectionChanged = nil - local selectedUnitsCount = Spring.GetSelectedUnitsSorted() + local selectedUnitsCount = SpringUnsynced.GetSelectedUnitsSorted() for uDID, unit in pairs(selectedUnitsCount) do for i = 1, #unit do local unitID = unit[i] @@ -174,9 +174,9 @@ function widget:UnitGiven(unitID, unitDefID, newTeam, oldTeam) if newTeam == myTeamID then AddGivenUnit(unitID) if lastreceiveframe < spGetGameFrame() then - local x, y, z = Spring.GetUnitPosition(unitID) + local x, y, z = SpringShared.GetUnitPosition(unitID) if x and y and z then - Spring.SetLastMessagePosition(x, y, z) + SpringUnsynced.SetLastMessagePosition(x, y, z) end lastreceiveframe = spGetGameFrame() end diff --git a/luaui/Widgets/gui_gridmenu.lua b/luaui/Widgets/gui_gridmenu.lua index 700dad6800b..d3272227f67 100644 --- a/luaui/Widgets/gui_gridmenu.lua +++ b/luaui/Widgets/gui_gridmenu.lua @@ -26,13 +26,13 @@ end ------------------------------------------------------------------------------- --- CACHED VALUES ------------------------------------------------------------------------------- -local spGetCmdDescIndex = Spring.GetCmdDescIndex -local spGetActiveCommand = Spring.GetActiveCommand -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitIsBuilding = Spring.GetUnitIsBuilding -local spGetSelectedUnitsSorted = Spring.GetSelectedUnitsSorted -local spGiveOrderToUnit = Spring.GiveOrderToUnit +local spGetCmdDescIndex = SpringUnsynced.GetCmdDescIndex +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitIsBuilding = SpringShared.GetUnitIsBuilding +local spGetSelectedUnitsSorted = SpringUnsynced.GetSelectedUnitsSorted +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit local math_floor = math.floor local math_ceil = math.ceil @@ -164,7 +164,7 @@ include("keysym.h.lua") local unitBlocking = VFS.Include("luaui/Include/unitBlocking.lua") local keyConfig = VFS.Include("luaui/configs/keyboard_layouts.lua") -local currentLayout = Spring.GetConfigString("KeyboardLayout", "qwerty") +local currentLayout = SpringUnsynced.GetConfigString("KeyboardLayout", "qwerty") local categoryKeys = {} local keyLayout = {} local nextPageKey @@ -217,7 +217,7 @@ end local RectRound, RectRoundProgress, UiUnit, UiElement, UiButton, elementCorner, TexRectRound local ui_opacity, ui_scale -local vsx, vsy = Spring.GetViewGeometry() +local vsx, vsy = SpringUnsynced.GetViewGeometry() local ordermenuLeft = math.floor(vsx / 5) local advplayerlistLeft = vsx * 0.8 @@ -329,7 +329,7 @@ end -- starting units local startUnits = { UnitDefNames.armcom.id, UnitDefNames.corcom.id } -if Spring.GetModOptions().experimentallegionfaction then +if SpringShared.GetModOptions().experimentallegionfaction then startUnits[#startUnits + 1] = UnitDefNames.legcom.id end local startBuildOptions = {} @@ -396,12 +396,12 @@ local function setHoveredRectTooltip(rect, text, title, clicked) end local function updateHoverState() - local x, y, left, _, right = Spring.GetMouseState() + local x, y, left, _, right = SpringUnsynced.GetMouseState() local isAboveBg = backgroundRect:contains(x, y) local isAboveBuilders = not isAboveBg and selectedBuildersCount > 1 and (buildersRect:contains(x, y) or nextBuilderRect:contains(x, y)) if isAboveBuilders then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") -- builder buttons if nextBuilderRect:contains(x, y) then @@ -438,7 +438,7 @@ local function updateHoverState() return end - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") for _, cellRect in pairs(cellRects) do if cellRect:contains(x, y) then @@ -551,7 +551,7 @@ local function updateQuotaNumber(unitDefID, quantity) end local cellRect = cellRects[cellId] if WG.Quotas then - for _, builderID in ipairs(Spring.GetSelectedUnitsSorted()[activeBuilder]) do + for _, builderID in ipairs(SpringUnsynced.GetSelectedUnitsSorted()[activeBuilder]) do local quotas = WG.Quotas.getQuotas() quotas[builderID] = quotas[builderID] or {} quotas[builderID][unitDefID] = quotas[builderID][unitDefID] or 0 @@ -559,9 +559,9 @@ local function updateQuotaNumber(unitDefID, quantity) cellRect.opts.quotanumber = quotas[builderID][unitDefID] end if quantity > 0 then - Spring.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") else - Spring.PlaySoundFile(CONFIG.sound_queue_rem, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_rem, 0.75, "ui") end end redraw = true @@ -870,7 +870,7 @@ local function refreshCommands() return end elseif builderIsFactory then - local activeCmdDescs = Spring.GetUnitCmdDescs(activeBuilderID) + local activeCmdDescs = SpringShared.GetUnitCmdDescs(activeBuilderID) if activeCmdDescs then gridOpts = grid.getSortedGridForLab(activeBuilder, activeCmdDescs) @@ -903,7 +903,7 @@ end local function getActionHotkey(action) local key - for _, keybinding in pairs(Spring.GetActionHotKeys(action)) do + for _, keybinding in pairs(SpringUnsynced.GetActionHotKeys(action)) do if (not key) or keybinding:len() < key:len() then key = keybinding end @@ -924,7 +924,7 @@ local function getGridKey(action) end local function reloadBindings() - currentLayout = Spring.GetConfigString("KeyboardLayout", "qwerty") + currentLayout = SpringUnsynced.GetConfigString("KeyboardLayout", "qwerty") keyLayout = { {}, {}, {} } @@ -965,10 +965,10 @@ local function setLabBuildMode(value) end local function setActiveCommand(cmd, button, leftClick, rightClick) - local didChangeCmd = button and Spring.SetActiveCommand(cmd, button, leftClick, rightClick, Spring.GetModKeyState()) or Spring.SetActiveCommand(cmd) + local didChangeCmd = button and SpringUnsynced.SetActiveCommand(cmd, button, leftClick, rightClick, SpringUnsynced.GetModKeyState()) or SpringUnsynced.SetActiveCommand(cmd) if not didChangeCmd then - Spring.Echo(" Unable to change active command", cmd) + SpringShared.Echo(" Unable to change active command", cmd) return end @@ -1079,7 +1079,7 @@ local function gridmenuCategoryHandler(_, _, args) return end if builderIsFactory and useLabBuildMode and not labBuildModeActive then - Spring.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") setLabBuildMode(true) refreshCommands() return true @@ -1089,7 +1089,7 @@ local function gridmenuCategoryHandler(_, _, args) return end - local alt, ctrl, meta, _ = Spring.GetModKeyState() + local alt, ctrl, meta, _ = SpringUnsynced.GetModKeyState() if alt or ctrl or meta then return end @@ -1130,7 +1130,7 @@ local function gridmenuKeyHandler(_, _, args, _, isRepeat) return currentCategory and true or false end - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if builderIsFactory then local quantity = 1 @@ -1155,9 +1155,9 @@ local function gridmenuKeyHandler(_, _, args, _, isRepeat) if quantity < 0 then quantity = quantity * -1 removing = true - Spring.PlaySoundFile(CONFIG.sound_queue_rem, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_rem, 0.75, "ui") else - Spring.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") end --if quantity is more than 100, more than 20 or more than 5 then use engine logic for better performance (fewer for loops inside queueUnit()) quantity = multiQueue(uDefID, quantity, 100, { "ctrl", "shift", alt and "alt", removing and "right" }) @@ -1270,8 +1270,8 @@ function widget:Initialize() end myTeamID = Spring.GetMyTeamID() - isSpec = Spring.GetSpectatingState() - isPregame = Spring.GetGameFrame() == 0 and not isSpec + isSpec = SpringUnsynced.GetSpectatingState() + isPregame = SpringShared.GetGameFrame() == 0 and not isSpec WG["gridmenu"] = {} WG["buildmenu"] = {} @@ -1301,7 +1301,7 @@ function widget:Initialize() -- Get our starting unit if isPregame then - startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") + startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") end widget:ViewResize() @@ -1309,7 +1309,7 @@ function widget:Initialize() if isPregame then refreshCommands() else - widget:SelectionChanged(Spring.GetSelectedUnits()) + widget:SelectionChanged(SpringUnsynced.GetSelectedUnits()) end WG["gridmenu"].getAlwaysReturn = function() @@ -1470,7 +1470,7 @@ end -- Set up all of the UI positioning function widget:ViewResize() - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() local widgetSpaceMargin = WG.FlowUI.elementMargin bgpadding = WG.FlowUI.elementPadding @@ -1624,7 +1624,7 @@ function widget:Update(dt) sec = sec + dt if sec > 0.33 then sec = 0 - if delayRefresh and Spring.GetGameSeconds() >= delayRefresh then + if delayRefresh and SpringShared.GetGameSeconds() >= delayRefresh then redraw = true doUpdate = true updateGrid() @@ -1654,7 +1654,7 @@ function widget:Update(dt) end disableInput = CONFIG.disableInputWhenSpec and isSpec - if Spring.IsGodModeEnabled() then + if SpringShared.IsGodModeEnabled() then disableInput = false end end @@ -1687,7 +1687,7 @@ function widget:Update(dt) -- PERF: Maybe make this slow-ish-update? if isPregame then local previousStartDefID = startDefID - startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") + startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") -- Don't update unless defid has changed doUpdate = previousStartDefID ~= startDefID @@ -2197,7 +2197,7 @@ function widget:KeyRelease(key) end function widget:MousePress(x, y, button) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if WG["topbar"] and WG["topbar"].showingQuit() then @@ -2208,7 +2208,7 @@ function widget:MousePress(x, y, button) if activeBuilder then if pages > 1 then if nextPageRect and nextPageRect:contains(x, y) then - Spring.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") nextPageHandler() return true end @@ -2216,7 +2216,7 @@ function widget:MousePress(x, y, button) if currentCategory or labBuildModeActive then if backRect and backRect:contains(x, y) then - Spring.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") clearCategory() return true end @@ -2224,7 +2224,7 @@ function widget:MousePress(x, y, button) if useLabBuildMode and builderIsFactory and not labBuildModeActive then if labBuildModeRect:contains(x, y) then - Spring.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") setLabBuildMode(true) updateGrid() return true @@ -2252,7 +2252,7 @@ function widget:MousePress(x, y, button) for cat, catRect in pairs(catRects) do if catRect:contains(x, y) then setCurrentCategory(cat) - Spring.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") return true end end @@ -2261,7 +2261,7 @@ function widget:MousePress(x, y, button) for _, cellRect in pairs(cellRects) do local unitDefID = cellRect.opts.uDefID if unitDefID and unitTranslatedHumanName[unitDefID] and cellRect:contains(x, y) and not cellRect.opts.disabled then - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if button ~= 3 then if builderIsFactory and WG.Quotas and WG.Quotas.isOnQuotaMode(activeBuilderID) and not alt then local amount = 1 @@ -2274,7 +2274,7 @@ function widget:MousePress(x, y, button) updateQuotaNumber(unitDefID, amount) return true end - Spring.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_add, 0.75, "ui") if isPregame then setPregameBlueprint(unitDefID) @@ -2294,7 +2294,7 @@ function widget:MousePress(x, y, button) end local function decreaseQueue() - Spring.PlaySoundFile(CONFIG.sound_queue_rem, 0.75, "ui") + SpringUnsynced.PlaySoundFile(CONFIG.sound_queue_rem, 0.75, "ui") setActiveCommand(spGetCmdDescIndex(-unitDefID), 3, false, true) end @@ -2508,7 +2508,7 @@ function widget:UnitCmdDone(unitID, unitDefID, unitTeam, cmdID, cmdParams, optio end -- If factory is in repeat, queue does not change, except if it is alt-queued - local factoryRepeat = select(4, Spring.GetUnitStates(unitID, false, true)) + local factoryRepeat = select(4, SpringShared.GetUnitStates(unitID, false, true)) if factoryRepeat and not options.alt then return @@ -2590,7 +2590,7 @@ function widget:GameStart() end function widget:PlayerChanged() - isSpec = Spring.GetSpectatingState() + isSpec = SpringUnsynced.GetSpectatingState() myTeamID = Spring.GetMyTeamID() end @@ -2603,7 +2603,7 @@ function widget:GetConfigData() showRadarIcon = showRadarIcon, showGroupIcon = showGroupIcon, stickToBottom = stickToBottom, - gameID = Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID"), + gameID = Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID"), alwaysShow = alwaysShow, ctrlKeyModifier = modKeyMultiplier.keyPress.ctrl, shiftKeyModifier = modKeyMultiplier.keyPress.shift, @@ -2646,8 +2646,8 @@ end function widget:UnitBlocked(unitDefID, reasons) units.unitRestricted[unitDefID] = next(reasons) ~= nil units.unitHidden[unitDefID] = reasons["hidden"] ~= nil - if not delayRefresh or delayRefresh < Spring.GetGameSeconds() then - delayRefresh = Spring.GetGameSeconds() + 0.5 -- delay so multiple sequential UnitBlocked calls are batched in a single update. + if not delayRefresh or delayRefresh < SpringShared.GetGameSeconds() then + delayRefresh = SpringShared.GetGameSeconds() + 0.5 -- delay so multiple sequential UnitBlocked calls are batched in a single update. end end diff --git a/luaui/Widgets/gui_ground_ao_plates_features_gl4.lua b/luaui/Widgets/gui_ground_ao_plates_features_gl4.lua index 7987c2cab05..4dc534608f6 100644 --- a/luaui/Widgets/gui_ground_ao_plates_features_gl4.lua +++ b/luaui/Widgets/gui_ground_ao_plates_features_gl4.lua @@ -13,8 +13,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetSpectatingState = Spring.GetSpectatingState +local spEcho = SpringShared.Echo +local spGetSpectatingState = SpringUnsynced.GetSpectatingState --------------- Configurables ------------------- local decalAlpha = 0.66 @@ -98,8 +98,8 @@ local GL_BACK = GL.BACK local GL_LEQUAL = GL.LEQUAL local function AddPrimitiveAtUnit(featureID, featureDefID, noUpload) - local gf = Spring.GetGameFrame() - featureDefID = featureDefID or Spring.GetFeatureDefID(featureID) + local gf = SpringShared.GetGameFrame() + featureDefID = featureDefID or SpringShared.GetFeatureDefID(featureID) if featureDefID == nil or featureDefIDtoDecalInfo[featureDefID] == nil then return @@ -145,7 +145,7 @@ end local function ProcessAllFeatures() InstanceVBOTable.clearInstanceTable(groundPlateVBO) - local features = Spring.GetAllFeatures() + local features = SpringShared.GetAllFeatures() --spEcho("Refreshing Ground Plates", #features) for _, featureID in ipairs(features) do AddPrimitiveAtUnit(featureID, nil, true) @@ -161,7 +161,7 @@ function widget:DrawWorldPreUnit() end if groundPlateVBO.usedElements > 0 then - local disticon = Spring.GetConfigInt("FeatureFadeDistance", 200) -- iconLength = unitIconDist * unitIconDist * 750.0f; + local disticon = SpringUnsynced.GetConfigInt("FeatureFadeDistance", 200) -- iconLength = unitIconDist * unitIconDist * 750.0f; glCulling(GL_BACK) glDepthTest(GL_LEQUAL) gl.DepthMask(false) --"BK OpenGL state resets", default is already false, could remove @@ -293,8 +293,8 @@ function widget:TextCommand(command) end end if #matches > 0 then - local mx, my, mb = Spring.GetMouseState() - local _, coords = Spring.TraceScreenRay(mx, my, true) + local mx, my, mb = SpringUnsynced.GetMouseState() + local _, coords = SpringUnsynced.TraceScreenRay(mx, my, true) local maxx = math.ceil(math.sqrt(#matches)) local size = 80 local i = 1 @@ -302,7 +302,7 @@ function widget:TextCommand(command) for z = coords[3], coords[3] + size * maxx, size do for x = coords[1], coords[1] + size * maxx, size do if i <= #matches then - commandqueue[#commandqueue + 1] = string.format("give %s @%d,%d,%d", matches[i], x, Spring.GetGroundHeight(x, z), z) + commandqueue[#commandqueue + 1] = string.format("give %s @%d,%d,%d", matches[i], x, SpringShared.GetGroundHeight(x, z), z) i = i + 1 end end @@ -314,7 +314,7 @@ end function widget:GameFrame() if #commandqueue > 0 then - Spring.SendCommands({ commandqueue[#commandqueue] }) + SpringUnsynced.SendCommands({ commandqueue[#commandqueue] }) commandqueue[#commandqueue] = nil end end diff --git a/luaui/Widgets/gui_ground_ao_plates_gl4.lua b/luaui/Widgets/gui_ground_ao_plates_gl4.lua index b89850f69d4..4e885ddce2e 100644 --- a/luaui/Widgets/gui_ground_ao_plates_gl4.lua +++ b/luaui/Widgets/gui_ground_ao_plates_gl4.lua @@ -14,7 +14,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -- Configurable Parts: local groundaoplatealpha = 1.0 @@ -43,8 +43,8 @@ local glDepthMask = gl.DepthMask local GL_BACK = GL.BACK local GL_LEQUAL = GL.LEQUAL local GL_POINTS = GL.POINTS -local spGetUnitDefID = Spring.GetUnitDefID -local spGetGameFrame = Spring.GetGameFrame +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetGameFrame = SpringShared.GetGameFrame local function AddPrimitiveAtUnit(unitID, unitDefID, noUpload, reason) local gf = spGetGameFrame() diff --git a/luaui/Widgets/gui_healthbars_gl4.lua b/luaui/Widgets/gui_healthbars_gl4.lua index ccbc9d4ff23..68863782107 100644 --- a/luaui/Widgets/gui_healthbars_gl4.lua +++ b/luaui/Widgets/gui_healthbars_gl4.lua @@ -16,15 +16,15 @@ end local mathMin = math.min -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitHealth = Spring.GetUnitHealth -local spGetUnitPosition = Spring.GetUnitPosition -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo -local spGetUnitTeam = Spring.GetUnitTeam -local spGetSpectatingState = Spring.GetSpectatingState -local spGetFeaturePosition = Spring.GetFeaturePosition -local spIsPosInLos = Spring.IsPosInLos +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spIsPosInLos = SpringShared.IsPosInLos -- wellity wellity the time has come, and yes, this is design documentation -- what can we do with 64 verts per healthbars? @@ -360,7 +360,7 @@ end local spec, fullview = spGetSpectatingState() local myAllyTeamID = Spring.GetMyAllyTeamID() -local GetUnitWeaponState = Spring.GetUnitWeaponState +local GetUnitWeaponState = SpringShared.GetUnitWeaponState local chobbyInterface @@ -498,7 +498,7 @@ for udefID, unitDef in pairs(UnitDefs) do end end unitDefHeights[udefID] = unitDef.height - unitDefSizeMultipliers[udefID] = mathMin(1.45, math.max(0.85, (Spring.GetUnitDefDimensions(udefID).radius / 150) + mathMin(0.6, unitDef.power / 4000))) + mathMin(0.6, unitDef.health / 22000) + unitDefSizeMultipliers[udefID] = mathMin(1.45, math.max(0.85, (SpringShared.GetUnitDefDimensions(udefID).radius / 150) + mathMin(0.6, unitDef.power / 4000))) + mathMin(0.6, unitDef.health / 22000) if unitDef.canStockpile then unitDefCanStockpile[udefID] = unitDef.canStockpile end @@ -604,7 +604,7 @@ local function addBarForUnit(unitID, unitDefID, barname, reason) return end -- we already have this bar ! - if unitDefID == nil or Spring.ValidUnitID(unitID) == false or Spring.GetUnitIsDead(unitID) == true then -- dead or invalid + if unitDefID == nil or SpringShared.ValidUnitID(unitID) == false or SpringShared.GetUnitIsDead(unitID) == true then -- dead or invalid if debugmode then Spring.Debug.TraceEcho("Tried to add a bar to dead/invalid/nounitdef unit", unitID, unitdefID, barname) end @@ -615,9 +615,9 @@ local function addBarForUnit(unitID, unitDefID, barname, reason) if debugmode then spEcho("A unit has no bars yet", UnitDefs[unitDefID].name, spGetUnitPosition(unitID)) Spring.Debug.TraceFullEcho() - Spring.SendCommands({ "pause 1" }) + SpringUnsynced.SendCommands({ "pause 1" }) spEcho("No bars unit, last seen at", unitID) - Spring.MarkerAddPoint(spGetUnitPosition(unitID)) + SpringUnsynced.MarkerAddPoint(spGetUnitPosition(unitID)) end unitBars[unitID] = 1 end @@ -679,7 +679,7 @@ end local function addBarsForUnit(unitID, unitDefID, unitTeam, unitAllyTeam, reason) -- TODO, actually, we need to check for all of these for stuff entering LOS - if unitDefID == nil or Spring.ValidUnitID(unitID) == false or Spring.GetUnitIsDead(unitID) == true then + if unitDefID == nil or SpringShared.ValidUnitID(unitID) == false or SpringShared.GetUnitIsDead(unitID) == true then if debugmode then spEcho("Tried to add a bar to a dead or invalid unit", unitID, "at", spGetUnitPosition(unitID), reason) end @@ -690,13 +690,13 @@ local function addBarsForUnit(unitID, unitDefID, unitTeam, unitAllyTeam, reason) -- This is optionally passed, and it only important in one edge case: -- If a unit is captured and thus immediately become outside of LOS, then the getunitallyteam is still the old ally team according to getUnitAllyTEam, and not the new allyteam. - unitAllyTeam = unitAllyTeam or Spring.GetUnitAllyTeam(unitID) + unitAllyTeam = unitAllyTeam or SpringShared.GetUnitAllyTeam(unitID) local health, maxHealth, paralyzeDamage, capture, build = spGetUnitHealth(unitID) if (fullview or (unitAllyTeam == myAllyTeamID) or (unitDefHideDamage[unitDefID] == nil)) and (unitDefIgnore[unitDefID] == nil) then if debugmode and health == nil then spEcho("Trying to add a healthbar to nil health unit", unitID, unitDefID) local ux, uy, uz = spGetUnitPosition(unitID) - Spring.MarkerAddPoint(ux, uy, uz, "health") + SpringUnsynced.MarkerAddPoint(ux, uy, uz, "health") end addBarForUnit(unitID, unitDefID, "health", reason) end @@ -707,7 +707,7 @@ local function addBarsForUnit(unitID, unitDefID, unitTeam, unitAllyTeam, reason) elseif unitDefReactiveArmor[unitDefID] then unitReactiveArmorWatch[unitID] = unitDefReactiveArmor[unitDefID] addBarForUnit(unitID, unitDefID, "shield", reason) - local armorHealth = Spring.GetUnitRulesParam(unitID, "reactiveArmorHealth") + local armorHealth = SpringShared.GetUnitRulesParam(unitID, "reactiveArmorHealth") if armorHealth then uniformcache[1] = armorHealth / unitDefReactiveArmor[unitDefID] gl.SetUnitBufferUniforms(unitID, uniformcache, 2) @@ -742,7 +742,7 @@ local function addBarsForUnit(unitID, unitDefID, unitTeam, unitAllyTeam, reason) if paralyzeDamage > 0 then --TODO - if Spring.GetUnitIsStunned(unitID) then + if SpringShared.GetUnitIsStunned(unitID) then if unitParalyzedWatch[unitID] == nil then -- already paralyzed unitParalyzedWatch[unitID] = 0.0 -- if unit was already empd, remove that bar @@ -780,7 +780,7 @@ local function addBarToFeature(featureID, barname) if debugmode then Spring.Debug.TraceEcho() end - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) local bt = barTypeMap[barname] @@ -870,13 +870,13 @@ local function init() unitStockPileWatch = {} unitReloadWatch = {} unitBars = {} - for i, unitID in ipairs(Spring.GetAllUnits()) do -- gets radar blips too! + for i, unitID in ipairs(SpringShared.GetAllUnits()) do -- gets radar blips too! -- probably shouldnt be adding non-visible units if fullview then addBarsForUnit(unitID, spGetUnitDefID(unitID), spGetUnitTeam(unitID), nil, "initfullview") else - local losstate = Spring.GetUnitLosState(unitID, myAllyTeamID) + local losstate = SpringShared.GetUnitLosState(unitID, myAllyTeamID) if losstate.los then addBarsForUnit(unitID, spGetUnitDefID(unitID), spGetUnitTeam(unitID), nil, "initlos") --spEcho(unitID, "IS in los") @@ -892,8 +892,8 @@ local function initfeaturebars() InstanceVBOTable.clearInstanceTable(featureHealthVBO) InstanceVBOTable.clearInstanceTable(featureResurrectVBO) InstanceVBOTable.clearInstanceTable(featureReclaimVBO) - for i, featureID in ipairs(Spring.GetAllFeatures()) do - local featureDefID = Spring.GetFeatureDefID(featureID) + for i, featureID in ipairs(SpringShared.GetAllFeatures()) do + local featureDefID = SpringShared.GetFeatureDefID(featureID) --local resurrectname = Spring.GetFeatureResurrect(featureID) --if resurrectname then -- resurrectableFeatures[featureID] = true @@ -959,7 +959,7 @@ end --function widget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer) local function UnitParalyzeDamageHealthbars(unitID, unitDefID, damage) - if Spring.GetUnitIsStunned(unitID) then -- DO NOTE THAT: return: nil | bool stunned_or_inbuild, bool stunned, bool inbuild + if SpringShared.GetUnitIsStunned(unitID) then -- DO NOTE THAT: return: nil | bool stunned_or_inbuild, bool stunned, bool inbuild if unitParalyzedWatch[unitID] == nil then -- already paralyzed unitParalyzedWatch[unitID] = 0.0 -- if unit was already empd, remove that bar @@ -1123,7 +1123,7 @@ function widget:GameFrame(n) -- check shields and armor if n % 3 == 0 then for unitID, oldshieldPower in pairs(unitShieldWatch) do - local shieldOn, shieldPower = Spring.GetUnitShieldState(unitID) + local shieldOn, shieldPower = SpringShared.GetUnitShieldState(unitID) if shieldOn == false then shieldPower = 0.0 end @@ -1140,7 +1140,7 @@ function widget:GameFrame(n) -- todo: armor should be completely different but idk how to set up a new bar type for unitID, oldArmorValue in pairs(unitReactiveArmorWatch) do - local newArmorValue = Spring.GetUnitRulesParam(unitID, "reactiveArmorHealth") + local newArmorValue = SpringShared.GetUnitRulesParam(unitID, "reactiveArmorHealth") if newArmorValue ~= oldArmorValue then if newArmorValue == nil then removeBarFromUnit(unitID, "shield", "unitReactiveArmorWatch") @@ -1177,7 +1177,7 @@ function widget:GameFrame(n) -- check Paralyzed units if (n + 2) % 3 == 0 then for unitID, paralyzetime in pairs(unitParalyzedWatch) do - if Spring.GetUnitIsStunned(unitID) then + if SpringShared.GetUnitIsStunned(unitID) then local health, maxHealth, paralyzeDamage, capture, build = spGetUnitHealth(unitID) --uniformcache[1] = math.floor((paralyzeDamage - maxHealth)) / (maxHealth * empDecline)) if paralyzeDamage then @@ -1218,7 +1218,7 @@ function widget:GameFrame(n) -- check stockpile progress if (n % 5) == 2 then for unitID, stockpilebuild in pairs(unitStockPileWatch) do - local numStockpiled, numStockpileQued, stockpileBuild = Spring.GetUnitStockpile(unitID) + local numStockpiled, numStockpileQued, stockpileBuild = SpringShared.GetUnitStockpile(unitID) if stockpileBuild and stockpileBuild ~= stockpilebuild then -- we somehow need to forward 3 vars, all 3 of the above. packed into a float, this is nasty --spEcho("Stockpiling", numStockpiled, numStockpileQued, stockpileBuild) @@ -1237,14 +1237,14 @@ end local rezreclaim = { 0.0, 1.0 } function widget:FeatureCreated(featureID) - local featureDefID = Spring.GetFeatureDefID(featureID) + local featureDefID = SpringShared.GetFeatureDefID(featureID) local gameFrame = spGetGameFrame() -- some map-supplied features dont have a model, in these cases modelpath == "" if FeatureDefs[featureDefID].name ~= "geovent" and FeatureDefs[featureDefID].modelpath ~= "" then --spEcho(FeatureDefs[featureDefID].name) --featureBars[featureID] = 0 -- this is already done in AddBarToFeature - local health, maxhealth, rezProgress = Spring.GetFeatureHealth(featureID) + local health, maxhealth, rezProgress = SpringShared.GetFeatureHealth(featureID) if gameFrame > 0 then addBarToFeature(featureID, "featurehealth") @@ -1265,7 +1265,7 @@ function widget:FeatureCreated(featureID) addBarToFeature(featureID, "featureresurrect") end - local _, _, _, _, reclaimLeft = Spring.GetFeatureResources(featureID) + local _, _, _, _, reclaimLeft = SpringShared.GetFeatureResources(featureID) if reclaimLeft < 1.0 then addBarToFeature(featureID, "featurereclaim") @@ -1294,7 +1294,7 @@ function widget:DrawWorld() if chobbyInterface then return end - if not drawWhenGuiHidden and Spring.IsGUIHidden() then + if not drawWhenGuiHidden and SpringUnsynced.IsGUIHidden() then return end @@ -1302,7 +1302,7 @@ function widget:DrawWorld() --spEcho("healthBarVBO",healthBarVBO.usedElements, "featureHealthVBO",featureHealthVBO.usedElements) end if healthBarVBO.usedElements > 0 or featureHealthVBO.usedElements > 0 then -- which quite strictly, is impossible anyway - local disticon = Spring.GetConfigInt("UnitIconDistance", 200) * 27.5 -- iconLength = unitIconDist * unitIconDist * 750.0f; + local disticon = SpringUnsynced.GetConfigInt("UnitIconDistance", 200) * 27.5 -- iconLength = unitIconDist * unitIconDist * 750.0f; gl.DepthTest(true) gl.DepthMask(true) gl.Texture(0, healthbartexture) diff --git a/luaui/Widgets/gui_idle_builders.lua b/luaui/Widgets/gui_idle_builders.lua index a9b7329474f..f001672c0e0 100644 --- a/luaui/Widgets/gui_idle_builders.lua +++ b/luaui/Widgets/gui_idle_builders.lua @@ -17,10 +17,10 @@ local mathFloor = math.floor local mathMax = math.max -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local alwaysShow = true -- always show AT LEAST the label local alwaysShowLabel = true -- always show the label regardless @@ -43,13 +43,13 @@ local spec = spGetSpectatingState() local widgetSpaceMargin, backgroundPadding, elementCorner, RectRound, UiElement, UiUnit -local spValidUnitID = Spring.ValidUnitID -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt +local spValidUnitID = SpringShared.ValidUnitID +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt -local spGetMouseState = Spring.GetMouseState -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spGetFactoryCommandCount = Spring.GetFactoryCommandCount +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spGetFactoryCommandCount = SpringShared.GetFactoryCommandCount local myTeamID = Spring.GetMyTeamID() local floor = mathFloor @@ -62,7 +62,7 @@ local GL_SRC_ALPHA = GL.SRC_ALPHA local GL_ONE = GL.ONE local GL_ONE_MINUS_SRC_ALPHA = GL.ONE_MINUS_SRC_ALPHA -local uiScale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local uiScale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) local height = setHeight * uiScale local posX = 0 local posY = 0 @@ -75,7 +75,7 @@ local hovered = false local prevHovered = false local numIcons = 0 local hoveredIcon -local selectedUnits = Spring.GetSelectedUnits() or {} +local selectedUnits = SpringUnsynced.GetSelectedUnits() or {} local buildmenuShowingPosY = 0 local buildmenuAlwaysShow = false local buildmenuIsShowing = true @@ -110,7 +110,7 @@ end function widget:VisibleUnitsChanged(extVisibleUnits, extNumVisibleUnits) for unitID, unitDefID in pairs(extVisibleUnits) do - widget:VisibleUnitAdded(unitID, unitDefID, Spring.GetUnitTeam(unitID)) + widget:VisibleUnitAdded(unitID, unitDefID, SpringShared.GetUnitTeam(unitID)) end end @@ -551,7 +551,7 @@ end local sec = 0 local sec2 = 0 -local timerStart = Spring.GetTimer() +local timerStart = SpringUnsynced.GetTimer() local function Update() if spGetGameFrame() <= initializeGameFrame and initializeGameFrame ~= 0 then return @@ -564,8 +564,8 @@ local function Update() if WG["topbar"] and WG["topbar"].showingQuit() then return end - local now = Spring.GetTimer() - local dt = Spring.DiffTimers(now, timerStart) + local now = SpringUnsynced.GetTimer() + local dt = SpringUnsynced.DiffTimers(now, timerStart) timerStart = now doUpdate = false @@ -600,7 +600,7 @@ local function Update() WG["tooltip"].ShowTooltip("idlebuilders", tooltipAddition, nil, nil, tooltipTitle) end - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") if b then sec = sec + 0.4 end @@ -663,12 +663,12 @@ function widget:DrawScreen() end function widget:MousePress(x, y, button) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if backgroundRect and math_isInRect(x, y, backgroundRect[1], backgroundRect[2], backgroundRect[3], backgroundRect[4]) then - local _, _, _, shift = Spring.GetModKeyState() + local _, _, _, shift = SpringUnsynced.GetModKeyState() if button == 1 or button == 3 then for i, v in pairs(iconButtons) do if math_isInRect(x, y, iconButtons[i][1], iconButtons[i][2], iconButtons[i][3], iconButtons[i][4]) then @@ -689,13 +689,13 @@ function widget:MousePress(x, y, button) end units = { idleList[unitDefID][num] } end - Spring.SelectUnitArray(units) + SpringUnsynced.SelectUnitArray(units) end if button == 3 then - Spring.SendCommands("viewselection") + SpringUnsynced.SendCommands("viewselection") end if playSounds then - Spring.PlaySoundFile((button == 3 and rightclick or leftclick), soundVolume, "ui") + SpringUnsynced.PlaySoundFile((button == 3 and rightclick or leftclick), soundVolume, "ui") end return true end diff --git a/luaui/Widgets/gui_info.lua b/luaui/Widgets/gui_info.lua index 6a3b0c3a8fb..37cf1a83461 100644 --- a/luaui/Widgets/gui_info.lua +++ b/luaui/Widgets/gui_info.lua @@ -31,14 +31,14 @@ local showEngineTooltip = false -- straight up display old engine delivered text local iconTypes = VFS.Include("gamedata/icontypes.lua") -local vsx, vsy = Spring.GetViewGeometry() +local vsx, vsy = SpringUnsynced.GetViewGeometry() local hoverType, hoverData = "", "" local customHoverType, customHoverData = nil, nil -- For external widgets (like PIP) to supply hover info local sound_button = "LuaUI/Sounds/buildbar_add.wav" local sound_button2 = "LuaUI/Sounds/buildbar_rem.wav" -local ui_scale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local ui_scale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) local backgroundRect = { 0, 0, 0, 0 } local currentTooltip = "" @@ -73,26 +73,26 @@ local contentWidth, bfcolormap, selUnitTypes local RectRound, UiElement, UiUnit, elementCorner -local spGetCurrentTooltip = Spring.GetCurrentTooltip -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetSelectedUnitsCounts = Spring.GetSelectedUnitsCounts -local spGetSelectedUnitsSorted = Spring.GetSelectedUnitsSorted -local spGetSelectedUnitsCount = Spring.GetSelectedUnitsCount -local SelectedUnitsCount = Spring.GetSelectedUnitsCount() -local selectedUnits = Spring.GetSelectedUnits() -local spGetUnitDefID = Spring.GetUnitDefID -local spGetFeatureDefID = Spring.GetFeatureDefID -local spTraceScreenRay = Spring.TraceScreenRay -local spGetMouseState = Spring.GetMouseState -local spGetModKeyState = Spring.GetModKeyState -local spSelectUnitArray = Spring.SelectUnitArray -local spGetTeamUnitsSorted = Spring.GetTeamUnitsSorted -local spSelectUnitMap = Spring.SelectUnitMap -local spGetUnitHealth = Spring.GetUnitHealth -local spGetUnitResources = Spring.GetUnitResources -local spGetUnitExperience = Spring.GetUnitExperience -local spGetUnitWeaponState = Spring.GetUnitWeaponState -local spGetUnitRulesParam = Spring.GetUnitRulesParam +local spGetCurrentTooltip = SpringUnsynced.GetCurrentTooltip +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetSelectedUnitsCounts = SpringUnsynced.GetSelectedUnitsCounts +local spGetSelectedUnitsSorted = SpringUnsynced.GetSelectedUnitsSorted +local spGetSelectedUnitsCount = SpringUnsynced.GetSelectedUnitsCount +local SelectedUnitsCount = SpringUnsynced.GetSelectedUnitsCount() +local selectedUnits = SpringUnsynced.GetSelectedUnits() +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetFeatureDefID = SpringShared.GetFeatureDefID +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetModKeyState = SpringUnsynced.GetModKeyState +local spSelectUnitArray = SpringUnsynced.SelectUnitArray +local spGetTeamUnitsSorted = SpringShared.GetTeamUnitsSorted +local spSelectUnitMap = SpringUnsynced.SelectUnitMap +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetUnitResources = SpringShared.GetUnitResources +local spGetUnitExperience = SpringShared.GetUnitExperience +local spGetUnitWeaponState = SpringShared.GetUnitWeaponState +local spGetUnitRulesParam = SpringShared.GetUnitRulesParam local spColorString = Spring.Utilities.Color.ToString local math_floor = math.floor @@ -105,7 +105,7 @@ local string_lines = string.lines local os_clock = os.clock local myTeamID = Spring.GetMyTeamID() -local mySpec = Spring.GetSpectatingState() +local mySpec = SpringUnsynced.GetSpectatingState() local GL_QUADS = GL.QUADS local glTexture = gl.Texture @@ -586,7 +586,7 @@ local unitOrder = {} -- retrieves from buildmenu in initialize local unitDisabled = {} local minWaterUnitDepth = -11 local showWaterUnits = false -local _, _, mapMinWater, _ = Spring.GetGroundExtremes() +local _, _, mapMinWater, _ = SpringShared.GetGroundExtremes() if mapMinWater <= minWaterUnitDepth then showWaterUnits = true end @@ -606,9 +606,9 @@ local function checkGeothermalFeatures() geoThermalFeatures[defID] = true end end - local features = Spring.GetAllFeatures() + local features = SpringShared.GetAllFeatures() for i = 1, #features do - if geoThermalFeatures[Spring.GetFeatureDefID(features[i])] then + if geoThermalFeatures[SpringShared.GetFeatureDefID(features[i])] then showGeothermalUnits = true break end @@ -633,13 +633,13 @@ end function widget:PlayerChanged(playerID) myTeamID = Spring.GetMyTeamID() - mySpec = Spring.GetSpectatingState() + mySpec = SpringUnsynced.GetSpectatingState() end function widget:ViewResize() ViewResizeUpdate = true - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() width = 0.2125 height = 0.14 * ui_scale @@ -705,7 +705,7 @@ function widget:GameFrame() end function widget:Initialize() - isPregame = Spring.GetGameFrame() < 1 + isPregame = SpringShared.GetGameFrame() < 1 refreshUnitInfo() @@ -787,8 +787,8 @@ function widget:Initialize() end end - Spring.SetDrawSelectionInfo(false) -- disables springs default display of selected units count - Spring.SendCommands("tooltip 0") + SpringUnsynced.SetDrawSelectionInfo(false) -- disables springs default display of selected units count + SpringUnsynced.SendCommands("tooltip 0") if WG["rankicons"] then rankTextures = WG["rankicons"].getRankTextures() @@ -802,8 +802,8 @@ function widget:Initialize() end function widget:Shutdown() - Spring.SetDrawSelectionInfo(true) --disables springs default display of selected units count - Spring.SendCommands("tooltip 1") + SpringUnsynced.SetDrawSelectionInfo(true) --disables springs default display of selected units count + SpringUnsynced.SendCommands("tooltip 1") if infoBgTex then gl.DeleteTexture(infoBgTex) end @@ -851,7 +851,7 @@ function widget:Update(dt) rankTextures = WG["rankicons"].getRankTextures() end - local _, _, mapMinWater, _ = Spring.GetGroundExtremes() + local _, _, mapMinWater, _ = SpringShared.GetGroundExtremes() if mapMinWater <= minWaterUnitDepth then if not showWaterUnits then showWaterUnits = true @@ -886,7 +886,7 @@ function widget:Update(dt) lastUpdateClock = os_clock() end - if displayUnitID and not Spring.ValidUnitID(displayUnitID) then + if displayUnitID and not SpringShared.ValidUnitID(displayUnitID) then displayMode = "text" displayUnitID = nil displayUnitDefID = nil @@ -1210,8 +1210,8 @@ local function drawSelection() end local function GetAIName(teamID) - local _, _, _, name, _, options = Spring.GetAIInfo(teamID) - local niceName = Spring.GetGameRulesParam("ainame_" .. teamID) + local _, _, _, name, _, options = SpringShared.GetAIInfo(teamID) + local niceName = SpringShared.GetGameRulesParam("ainame_" .. teamID) if niceName then name = niceName --if Spring.Utilities.ShowDevUI() and options.profile then @@ -1372,15 +1372,15 @@ local function drawUnitInfo() end -- display unit owner name - local teamID = Spring.GetUnitTeam(displayUnitID) + local teamID = SpringShared.GetUnitTeam(displayUnitID) if mySpec or (myTeamID ~= teamID) then - local _, playerID, _, isAiTeam = Spring.GetTeamInfo(teamID, false) - local name = Spring.GetPlayerInfo(playerID, false) + local _, playerID, _, isAiTeam = SpringShared.GetTeamInfo(teamID, false) + local name = SpringShared.GetPlayerInfo(playerID, false) name = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerID)) or name if isAiTeam then name = GetAIName(teamID) end - if not mySpec and Spring.GetModOptions().teamcolors_anonymous_mode ~= "disabled" then + if not mySpec and SpringShared.GetModOptions().teamcolors_anonymous_mode ~= "disabled" then name = anonymousName end if name then @@ -1388,7 +1388,7 @@ local function drawUnitInfo() --if not mySpec and Spring.GetModOptions().teamcolors_anonymous_mode ~= 'disabled' then -- name = ColourString(Spring.GetConfigInt("anonymousColorR", 255)/255, Spring.GetConfigInt("anonymousColorG", 0)/255, Spring.GetConfigInt("anonymousColorB", 0)/255) .. name --else - name = spColorString(Spring.GetTeamColor(teamID)) .. name + name = spColorString(SpringUnsynced.GetTeamColor(teamID)) .. name --end font2:Print(name, backgroundRect[3] - bgpadding - bgpadding, backgroundRect[2] + (fontSizeOwner * 0.44), fontSizeOwner, "or") end @@ -1476,8 +1476,8 @@ local function drawUnitInfo() glColor(1, 1, 1, 1) -- draw transported unit list - elseif displayMode == "unit" and unitDefInfo[displayUnitDefID].transport and (Spring.GetUnitIsTransporting(displayUnitID) and #Spring.GetUnitIsTransporting(displayUnitID) or 0) > 0 then - local units = Spring.GetUnitIsTransporting(displayUnitID) + elseif displayMode == "unit" and unitDefInfo[displayUnitDefID].transport and (SpringShared.GetUnitIsTransporting(displayUnitID) and #SpringShared.GetUnitIsTransporting(displayUnitID) or 0) > 0 then + local units = SpringShared.GetUnitIsTransporting(displayUnitID) if #units > 0 then gridHeight = math_ceil(height * 0.975) local rows = 2 @@ -1573,7 +1573,7 @@ local function drawUnitInfo() if displayMode == "unit" then -- get lots of unit info from functions: https://springrts.com/wiki/Lua_SyncedRead if unitDefInfo[displayUnitDefID].mainWeapon ~= nil then - maxRange = Spring.GetUnitWeaponState(displayUnitID, unitDefInfo[displayUnitDefID].mainWeapon, "range") + maxRange = SpringShared.GetUnitWeaponState(displayUnitID, unitDefInfo[displayUnitDefID].mainWeapon, "range") else maxRange = range end @@ -1786,7 +1786,7 @@ local function drawEngineTooltip() end if hoverType == "ground" then local desc, coords = spTraceScreenRay(mouseX, mouseY, true) - local groundType1, groundType2, metal, hardness, tankSpeed, botSpeed, hoverSpeed, shipSpeed, receiveTracks = Spring.GetGroundInfo(coords[1], coords[3]) + local groundType1, groundType2, metal, hardness, tankSpeed, botSpeed, hoverSpeed, shipSpeed, receiveTracks = SpringShared.GetGroundInfo(coords[1], coords[3]) local text = "" local height = 0 font:Begin(true) @@ -1795,7 +1795,7 @@ local function drawEngineTooltip() if displayMapPosition then font:Print(tooltipValueColor .. math.floor(hoverData[1]) .. ",", backgroundRect[1] + contentPadding, backgroundRect[4] - contentPadding - (fontSize * 0.8) - height, fontSize, "o") font:Print(math.floor(hoverData[3]), backgroundRect[1] + contentPadding + (fontSize * 3.2), backgroundRect[4] - contentPadding - (fontSize * 0.8) - height, fontSize, "o") - font:Print(tooltipLabelTextColor .. Spring.I18N("ui.info.elevation") .. " " .. tooltipValueColor .. math.floor(Spring.GetGroundHeight(coords[1], coords[3])), backgroundRect[1] + contentPadding + (fontSize * 6.6), backgroundRect[4] - contentPadding - (fontSize * 0.8) - height, fontSize, "o") + font:Print(tooltipLabelTextColor .. Spring.I18N("ui.info.elevation") .. " " .. tooltipValueColor .. math.floor(SpringShared.GetGroundHeight(coords[1], coords[3])), backgroundRect[1] + contentPadding + (fontSize * 6.6), backgroundRect[4] - contentPadding - (fontSize * 0.8) - height, fontSize, "o") height = height + heightStep end if tankSpeed ~= 1 or botSpeed ~= 1 or hoverSpeed ~= 1 or (shipSpeed ~= 1 and coords[2] <= 0) then @@ -1834,7 +1834,7 @@ local function drawEngineTooltip() --end font:End() elseif hoverType == "feature" then - local featureDefID = Spring.GetFeatureDefID(hoverData) + local featureDefID = SpringShared.GetFeatureDefID(hoverData) local text = FeatureDefs[featureDefID].tooltip local height = 0 if text == "" then @@ -1851,7 +1851,7 @@ local function drawEngineTooltip() font:SetTextColor(1, 1, 1, 1) font:SetOutlineColor(0.1, 0.1, 0.1, 1) text = "" - local metal, _, energy, _ = Spring.GetFeatureResources(hoverData) + local metal, _, energy, _ = SpringShared.GetFeatureResources(hoverData) if energy > 0 then height = height + heightStep text = tooltipLabelTextColor .. Spring.I18N("ui.info.energy") .. " \255\255\255\000" .. string.formatSI(energy) @@ -1919,7 +1919,7 @@ local function LeftMouseButton(unitDefID, unitTable) selectedUnits = spGetSelectedUnits() SelectedUnitsCount = spGetSelectedUnitsCount() if acted then - Spring.PlaySoundFile(sound_button, 0.5, "ui") + SpringUnsynced.PlaySoundFile(sound_button, 0.5, "ui") end end @@ -1927,16 +1927,16 @@ local function MiddleMouseButton(unitDefID, unitTable) local alt, ctrl, meta, shift = spGetModKeyState() if ctrl then -- center the view on the entire selection - Spring.SendCommands(viewSelectionCmd) + SpringUnsynced.SendCommands(viewSelectionCmd) else -- center the view on this type on unit spSelectUnitArray(unitTable) - Spring.SendCommands(viewSelectionCmd) + SpringUnsynced.SendCommands(viewSelectionCmd) spSelectUnitArray(selectedUnits) end selectedUnits = spGetSelectedUnits() SelectedUnitsCount = spGetSelectedUnitsCount() - Spring.PlaySoundFile(sound_button, 0.5, "ui") + SpringUnsynced.PlaySoundFile(sound_button, 0.5, "ui") end local function RightMouseButton(unitDefID, unitTable) @@ -1959,11 +1959,11 @@ local function RightMouseButton(unitDefID, unitTable) spSelectUnitMap(rightMouseButtonMap) selectedUnits = spGetSelectedUnits() SelectedUnitsCount = spGetSelectedUnitsCount() - Spring.PlaySoundFile(sound_button2, 0.5, "ui") + SpringUnsynced.PlaySoundFile(sound_button2, 0.5, "ui") end function widget:MousePress(x, y, button) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if infoShows and math_isInRect(x, y, backgroundRect[1], backgroundRect[2], backgroundRect[3], backgroundRect[4]) then @@ -1979,12 +1979,12 @@ local function unloadTransport(transportID, unitID, x, z, shift, depth) end local radius = 20 * depth local orgX, orgZ = x, z - local y = Spring.GetGroundHeight(x, z) + local y = SpringShared.GetGroundHeight(x, z) local unitSphereRadius = 60 -- too low value will result in unload conflicts - local areaUnits = Spring.GetUnitsInSphere(x, y, z, unitSphereRadius) + local areaUnits = SpringShared.GetUnitsInSphere(x, y, z, unitSphereRadius) if #areaUnits == 0 then -- unblocked spot! unloadParams[1], unloadParams[2], unloadParams[3], unloadParams[4] = x, y, z, unitID - Spring.GiveOrderToUnit(transportID, CMD.UNLOAD_UNIT, unloadParams, shift and shiftTable or emptyTable) + SpringSynced.GiveOrderToUnit(transportID, CMD.UNLOAD_UNIT, unloadParams, shift and shiftTable or emptyTable) else -- unload is blocked by unit at ground just lets find free alternative spot in a radius around it local samples = 8 @@ -1994,13 +1994,13 @@ local function unloadTransport(transportID, unitID, x, z, shift, depth) x = x + (radius * math.cos(i * sideAngle)) z = z + (radius * math.sin(i * sideAngle)) if x > 0 and z > 0 and x < mapSizeX and z < mapSizeZ then - y = Spring.GetGroundHeight(x, z) - areaUnits = Spring.GetUnitsInSphere(x, y, z, unitSphereRadius) + y = SpringShared.GetGroundHeight(x, z) + areaUnits = SpringShared.GetUnitsInSphere(x, y, z, unitSphereRadius) if #areaUnits == 0 then -- unblocked spot! - local areaFeatures = Spring.GetFeaturesInSphere(x, y, z, unitSphereRadius) + local areaFeatures = SpringShared.GetFeaturesInSphere(x, y, z, unitSphereRadius) if #areaFeatures == 0 then unloadParams[1], unloadParams[2], unloadParams[3], unloadParams[4] = x, y, z, unitID - Spring.GiveOrderToUnit(transportID, CMD.UNLOAD_UNIT, unloadParams, shift and shiftTable or emptyTable) + SpringSynced.GiveOrderToUnit(transportID, CMD.UNLOAD_UNIT, unloadParams, shift and shiftTable or emptyTable) foundUnloadSpot = true break end @@ -2015,7 +2015,7 @@ local function unloadTransport(transportID, unitID, x, z, shift, depth) end function widget:MouseRelease(x, y, button) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end @@ -2052,22 +2052,22 @@ function widget:MouseRelease(x, y, button) -- transported unit list if displayMode == "unit" and button == 1 then - local units = Spring.GetUnitIsTransporting(displayUnitID) + local units = SpringShared.GetUnitIsTransporting(displayUnitID) if units and #units > 0 then for cellID, unitID in pairs(units) do if cellRect[cellID] and math_isInRect(x, y, cellRect[cellID][1], cellRect[cellID][2], cellRect[cellID][3], cellRect[cellID][4]) then - local x, y, z = Spring.GetUnitPosition(displayUnitID) + local x, y, z = SpringShared.GetUnitPosition(displayUnitID) local alt, ctrl, meta, shift = spGetModKeyState() if shift then - local cmdQueue = Spring.GetUnitCommands(displayUnitID, 35) or {} + local cmdQueue = SpringShared.GetUnitCommands(displayUnitID, 35) or {} if cmdQueue[1] then if cmdQueue[#cmdQueue] and cmdQueue[#cmdQueue].id == CMD.MOVE and cmdQueue[#cmdQueue].params[3] then x, z = cmdQueue[#cmdQueue].params[1], cmdQueue[#cmdQueue].params[3] -- remove the last move command (to replace it with the unload cmd after) - Spring.GiveOrderToUnit(displayUnitID, CMD.STOP, emptyTable, 0) + SpringSynced.GiveOrderToUnit(displayUnitID, CMD.STOP, emptyTable, 0) for c = 1, #cmdQueue do if c < #cmdQueue then - Spring.GiveOrderToUnit(displayUnitID, cmdQueue[c].id, cmdQueue[c].params, shiftTable) + SpringSynced.GiveOrderToUnit(displayUnitID, cmdQueue[c].id, cmdQueue[c].params, shiftTable) end end end @@ -2139,7 +2139,7 @@ function widget:DrawScreen() -- widget hovered if infoShows and math_isInRect(x, y, backgroundRect[1], backgroundRect[2], backgroundRect[3], backgroundRect[4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") -- selection grid if displayMode == "selection" and selectionCells and selectionCells[1] and cellRect then @@ -2204,7 +2204,7 @@ function widget:DrawScreen() -- transport load list if displayMode == "unit" and unitDefInfo[displayUnitDefID].transport and cellRect then - local units = Spring.GetUnitIsTransporting(displayUnitID) + local units = SpringShared.GetUnitIsTransporting(displayUnitID) if #units > 0 then for cellID, unitID in pairs(units) do @@ -2274,7 +2274,7 @@ function checkChanges() activeCmdID = WG["pregame-build"] and WG["pregame-build"].getPreGameDefID() activeCmdID = activeCmdID and -activeCmdID else - activeCmdID = select(2, Spring.GetActiveCommand()) + activeCmdID = select(2, SpringUnsynced.GetActiveCommand()) end -- buildmenu unitdef @@ -2287,7 +2287,7 @@ function checkChanges() elseif activeCmdID and activeCmdID < 0 then displayMode = "unitdef" displayUnitDefID = -activeCmdID - elseif cfgDisplayUnitID and Spring.ValidUnitID(cfgDisplayUnitID) then + elseif cfgDisplayUnitID and SpringShared.ValidUnitID(cfgDisplayUnitID) then displayMode = "unit" displayUnitID = cfgDisplayUnitID displayUnitDefID = spGetUnitDefID(displayUnitID) @@ -2326,7 +2326,7 @@ function checkChanges() local newTooltip = featureDef.translatedDescription or "" if featureDef.reclaimable then - local metal, _, energy, _ = Spring.GetFeatureResources(featureID) + local metal, _, energy, _ = SpringShared.GetFeatureResources(featureID) local reclaimText = Spring.I18N("ui.reclaimInfo.metal", { metal = string.formatSI(metal) }) .. "\255\255\255\128" .. " " .. Spring.I18N("ui.reclaimInfo.energy", { energy = string.formatSI(energy) }) newTooltip = newTooltip .. "\n\n" .. reclaimText end @@ -2368,7 +2368,7 @@ function checkChanges() if displayMode == "text" and isPregame then if not mySpec then displayMode = "unitdef" - displayUnitDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") + displayUnitDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") hideBuildlist = true else emptyInfo = true diff --git a/luaui/Widgets/gui_infolos.lua b/luaui/Widgets/gui_infolos.lua index b774cf26206..59b752e96f7 100644 --- a/luaui/Widgets/gui_infolos.lua +++ b/luaui/Widgets/gui_infolos.lua @@ -19,7 +19,7 @@ end local mathMax = math.max -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local GL_RGBA32F_ARB = 0x8814 -------------------------------------------------------------------------------- @@ -72,7 +72,7 @@ local shaderConfig = { } --------------------------------------------------------------------------- -local alwaysColor, losColor, radarColor, jamColor, radarColor2 = Spring.GetLosViewColors() --unused +local alwaysColor, losColor, radarColor, jamColor, radarColor2 = SpringUnsynced.GetLosViewColors() --unused local outputAlpha = 0.07 local numFastUpdates = 10 -- how many quick updates to do on large-scale changes local updateRate = 2 -- on each Nth frame @@ -153,9 +153,9 @@ local function UpdateInfoLOSTexture(count) infoShader:SetUniformFloat("outputAlpha", outputAlpha) for i = 1, count do if i == count then - infoShader:SetUniformFloat("time", (Spring.GetDrawFrame() + 0) / 1000) + infoShader:SetUniformFloat("time", (SpringUnsynced.GetDrawFrame() + 0) / 1000) else - infoShader:SetUniformFloat("time", (Spring.GetDrawFrame() + math.random()) / 1000) + infoShader:SetUniformFloat("time", (SpringUnsynced.GetDrawFrame() + math.random()) / 1000) end gl.RenderToTexture(infoTextures[currentAllyTeam], renderToTextureFunc) end @@ -191,7 +191,7 @@ function widget:Initialize() end currentAllyTeam = Spring.GetMyAllyTeamID() - for _, a in ipairs(Spring.GetAllyTeamList()) do + for _, a in ipairs(SpringShared.GetAllyTeamList()) do infoTextures[a] = CreateLosTexture() end diff --git a/luaui/Widgets/gui_keybind_info.lua b/luaui/Widgets/gui_keybind_info.lua index 68f1cb1e8fe..ea60ddb8fda 100644 --- a/luaui/Widgets/gui_keybind_info.lua +++ b/luaui/Widgets/gui_keybind_info.lua @@ -18,7 +18,7 @@ local mathFloor = math.floor local mathMax = math.max -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local keyConfig = VFS.Include("luaui/configs/keyboard_layouts.lua") local currentLayout @@ -200,7 +200,7 @@ end local function refreshText() actionHotkeys = VFS.Include("luaui/Include/action_hotkeys.lua") - currentLayout = Spring.GetConfigString("KeyboardLayout", "qwerty") + currentLayout = SpringUnsynced.GetConfigString("KeyboardLayout", "qwerty") keybindsText = { { type = lineType.title, text = Spring.I18N("ui.keybinds.chat.title") }, @@ -366,9 +366,9 @@ function widget:DrawScreen() end showOnceMore = false - local x, y, pressed = Spring.GetMouseState() + local x, y, pressed = SpringUnsynced.GetMouseState() if math_isInRect(x, y, screenX, screenY - screenHeight, screenX + screenWidth, screenY) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end else if WG["guishader"] then @@ -385,7 +385,7 @@ function widget:KeyPress(key) end local function mouseEvent(x, y, button, release) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return false end diff --git a/luaui/Widgets/gui_language.lua b/luaui/Widgets/gui_language.lua index ad626115165..5c63e9b6028 100644 --- a/luaui/Widgets/gui_language.lua +++ b/luaui/Widgets/gui_language.lua @@ -38,7 +38,7 @@ function widget:Initialize() WG["language"] = {} WG["language"].setLanguage = function(language) - Spring.SetConfigString("language", language) + SpringUnsynced.SetConfigString("language", language) Spring.I18N.setLanguage(language) if Script.LuaUI("LanguageChanged") then @@ -47,7 +47,7 @@ function widget:Initialize() end WG["language"].setEnglishUnitNames = function(value) - Spring.SetConfigInt("language_english_unit_names", value and 1 or 0) + SpringUnsynced.SetConfigInt("language_english_unit_names", value and 1 or 0) if Script.LuaUI("LanguageChanged") then Script.LuaUI.LanguageChanged() diff --git a/luaui/Widgets/gui_los_view_gl4.lua b/luaui/Widgets/gui_los_view_gl4.lua index 911398f3b3e..ff564274e96 100644 --- a/luaui/Widgets/gui_los_view_gl4.lua +++ b/luaui/Widgets/gui_los_view_gl4.lua @@ -14,7 +14,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -------------------------------------------------------------------------------- --- TODO: @@ -66,7 +66,7 @@ function widget:PlayerChanged(playerID) end function widget:ViewResize() - vsx, vsy, vpx, vpy = Spring.GetViewGeometry() + vsx, vsy, vpx, vpy = SpringUnsynced.GetViewGeometry() if ScreenCopyTexture then gl.DeleteTexture(ScreenCopyTexture) end diff --git a/luaui/Widgets/gui_mapinfo.lua b/luaui/Widgets/gui_mapinfo.lua index e2d28ae5032..2dc196c1210 100644 --- a/luaui/Widgets/gui_mapinfo.lua +++ b/luaui/Widgets/gui_mapinfo.lua @@ -16,7 +16,7 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local scale = 1 local offset = 5 @@ -28,9 +28,9 @@ local dlistAmount = 20 -- amount of dlists created, one for each opacity value -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -local spGetCameraPosition = Spring.GetCameraPosition -local spGetGroundHeight = Spring.GetGroundHeight -local spIsAABBInView = Spring.IsAABBInView +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spGetGroundHeight = SpringShared.GetGroundHeight +local spIsAABBInView = SpringUnsynced.IsAABBInView local glColor = gl.Color local glScale = gl.Scale @@ -206,7 +206,7 @@ function widget:Shutdown() end function widget:DrawWorld() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end diff --git a/luaui/Widgets/gui_mapmarks_fx.lua b/luaui/Widgets/gui_mapmarks_fx.lua index ff81b8c1e27..44d20911ecb 100644 --- a/luaui/Widgets/gui_mapmarks_fx.lua +++ b/luaui/Widgets/gui_mapmarks_fx.lua @@ -13,9 +13,9 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetTeamColor = Spring.GetTeamColor +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetTeamColor = SpringUnsynced.GetTeamColor -- Localized gl functions local glBlending = gl.Blending @@ -199,7 +199,7 @@ function widget:DrawWorldPreUnit() if chobbyInterface then return end - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if WG.clearmapmarks and WG.clearmapmarks.continuous then diff --git a/luaui/Widgets/gui_messages.lua b/luaui/Widgets/gui_messages.lua index 251a27cf1c8..711fac69855 100644 --- a/luaui/Widgets/gui_messages.lua +++ b/luaui/Widgets/gui_messages.lua @@ -31,7 +31,7 @@ local charDelay = 0.022 local maxLines = 4 local lineTTL = 15 -local ui_scale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local ui_scale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) local widgetScale = (((vsx + vsy) / 2000) * 0.55) * (0.95 + (ui_scale - 1) / 1.5) local glPopMatrix = gl.PopMatrix @@ -48,11 +48,11 @@ local lineMaxWidth = 0 local font, buildmenuBottomPosition -local hideSpecChat = tonumber(Spring.GetConfigInt("HideSpecChat", 0) or 0) == 1 +local hideSpecChat = tonumber(SpringUnsynced.GetConfigInt("HideSpecChat", 0) or 0) == 1 local string_lines = string.lines function widget:ViewResize() - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() lineMaxWidth = lineMaxWidth / widgetScale widgetScale = (((vsx + vsy) / 2000) * 0.55) * (0.95 + (ui_scale - 1) / 1.5) lineMaxWidth = lineMaxWidth * widgetScale @@ -175,8 +175,8 @@ function widget:Update(dt) uiSec = uiSec + dt if uiSec > 0.5 then uiSec = 0 - if hideSpecChat ~= tonumber(Spring.GetConfigInt("HideSpecChat", 0) or 0) == 1 then - hideSpecChat = tonumber(Spring.GetConfigInt("HideSpecChat", 0) or 0) == 1 + if hideSpecChat ~= tonumber(SpringUnsynced.GetConfigInt("HideSpecChat", 0) or 0) == 1 then + hideSpecChat = tonumber(SpringUnsynced.GetConfigInt("HideSpecChat", 0) or 0) == 1 end if WG["buildmenu"] and WG["buildmenu"].getBottomPosition then local prevbuildmenuBottomPos = buildmenuBottomPos @@ -274,7 +274,7 @@ function widget:GetConfigData(data) end function widget:SetConfigData(data) - if Spring.GetGameFrame() > 0 and data.messageLines ~= nil then + if SpringShared.GetGameFrame() > 0 and data.messageLines ~= nil then messageLines = data.messageLines currentLine = #messageLines currentTypewriterLine = currentLine diff --git a/luaui/Widgets/gui_metalspots.lua b/luaui/Widgets/gui_metalspots.lua index f770cca8b1e..ff0ba4c2292 100644 --- a/luaui/Widgets/gui_metalspots.lua +++ b/luaui/Widgets/gui_metalspots.lua @@ -23,10 +23,10 @@ local stringFormat = string.format local stringFind = string.find -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spEcho = Spring.Echo -local spGetSpectatingState = Spring.GetSpectatingState +local spEcho = SpringShared.Echo +local spGetSpectatingState = SpringUnsynced.GetSpectatingState --2023.05.21 TODO list -- Add occupied circle to center @@ -51,7 +51,7 @@ local spGetSpectatingState = Spring.GetSpectatingState -- move font init into initialize instead of load -- untie from os.clock thats stupid too -if Spring.GetModOptions().unit_restrictions_noextractorDefs then +if SpringShared.GetModOptions().unit_restrictions_noextractorDefs then return end @@ -72,12 +72,12 @@ local maxScale = 4 -- ignore spots above this scale (probably metalmap) local extractorRadius = Game.extractorRadius * 1.2 -local spGetUnitsInSphere = Spring.GetUnitsInSphere -local spGetUnitDefID = Spring.GetUnitDefID -local spGetGroundHeight = Spring.GetGroundHeight -local spGetMapDrawMode = Spring.GetMapDrawMode -local spIsUnitAllied = Spring.IsUnitAllied -local spIsGUIHidden = Spring.IsGUIHidden +local spGetUnitsInSphere = SpringShared.GetUnitsInSphere +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetMapDrawMode = SpringUnsynced.GetMapDrawMode +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spIsGUIHidden = SpringUnsynced.IsGUIHidden local mySpots = {} -- {spotKey = {x = spot.x, y= spGetGroundHeight(spot.x, spot.z), z = spot.z, value = value, scale = scale, occupied = occupied, t = currentClock, ally = false, enemy = false, instanceID = "1024_1023"}} @@ -86,10 +86,10 @@ local sceduledCheckedSpotsFrame = spGetGameFrame() local isSpec, fullview = spGetSpectatingState() local myAllyTeamID = Spring.GetMyAllyTeamID() -local incomeMultiplier = select(7, Spring.GetTeamInfo(spGetMyTeamID(), false)) +local incomeMultiplier = select(7, SpringShared.GetTeamInfo(spGetMyTeamID(), false)) -local fontfile = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") -local vsx, vsy = Spring.GetViewGeometry() +local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") +local vsx, vsy = SpringUnsynced.GetViewGeometry() local fontfileScale = 1 -- fixed scale: billboard size is resolution-independent (world-space) local fontfileSize = 110 local fontfileOutlineSize = 12 @@ -399,8 +399,8 @@ end local function InitializeAtlas(mSpots) local multipliers = { [1] = true } -- all unique multipliers - for i, teamID in ipairs(Spring.GetTeamList()) do - local incomeMultiplier = select(7, Spring.GetTeamInfo(teamID, false)) + for i, teamID in ipairs(SpringShared.GetTeamList()) do + local incomeMultiplier = select(7, SpringShared.GetTeamInfo(teamID, false)) if multipliers[incomeMultiplier] == nil then multipliers[incomeMultiplier] = teamID end @@ -466,7 +466,7 @@ local function InitializeSpots(mSpots) local uvcoords = valueToUVs[value] if uvcoords then - local gh = Spring.GetGroundHeight(spot.x, spot.z) + local gh = SpringShared.GetGroundHeight(spot.x, spot.z) pushElementInstance( spotInstanceVBO, -- vbo { spot.x, gh, spot.z, scale, (occupied and 0) or 1, -1000, uvcoords.w, uvcoords.h, uvcoords.x, uvcoords.X, uvcoords.y, uvcoords.Y }, -- instanceData @@ -607,7 +607,7 @@ function widget:PlayerChanged(playerID) isSpec, fullview = spGetSpectatingState() myAllyTeamID = Spring.GetMyAllyTeamID() local oldIncomeMultiplier = incomeMultiplier - incomeMultiplier = select(7, Spring.GetTeamInfo(spGetMyTeamID(), false)) + incomeMultiplier = select(7, SpringShared.GetTeamInfo(spGetMyTeamID(), false)) if incomeMultiplier ~= oldIncomeMultiplier then UpdateSpotValues() end @@ -639,7 +639,7 @@ local function getWaterLevel() if lrs and lrs.level then return lrs.level end - local level = Spring.GetGameRulesParam("lavaLevel") + local level = SpringShared.GetGameRulesParam("lavaLevel") if level and level ~= -99999 then return level end diff --git a/luaui/Widgets/gui_minimap.lua b/luaui/Widgets/gui_minimap.lua index c948333bcb4..4b4e962bed3 100644 --- a/luaui/Widgets/gui_minimap.lua +++ b/luaui/Widgets/gui_minimap.lua @@ -17,15 +17,15 @@ local mathFloor = math.floor local mathMin = math.min -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local minimapToWorld = VFS.Include("luaui/Include/minimap_utils.lua").minimapToWorld local getCurrentMiniMapRotationOption = VFS.Include("luaui/Include/minimap_utils.lua").getCurrentMiniMapRotationOption local ROTATION = VFS.Include("luaui/Include/minimap_utils.lua").ROTATION local maxAllowedWidth = 0.26 -local maxAllowedHeight = Spring.GetConfigFloat("MinimapMaxHeight", 0.32) -local leftClickMove = Spring.GetConfigInt("MinimapLeftClickMove", 1) == 1 +local maxAllowedHeight = SpringUnsynced.GetConfigFloat("MinimapMaxHeight", 0.32) +local leftClickMove = SpringUnsynced.GetConfigInt("MinimapLeftClickMove", 1) == 1 local vsx, vsy, _, vpy = spGetViewGeometry() @@ -44,8 +44,8 @@ local sec = 0 local sec2 = 0 local lastRot = -1 --TODO: switch this to use MiniMapRotationChanged Callin when it is added to Engine -local spGetCameraState = Spring.GetCameraState -local spGetActiveCommand = Spring.GetActiveCommand +local spGetCameraState = SpringUnsynced.GetCameraState +local spGetActiveCommand = SpringUnsynced.GetActiveCommand local math_isInRect = math.isInRect local wasOverview = false @@ -54,12 +54,12 @@ local leftclicked = false local RectRound, UiElement, elementCorner, elementPadding, elementMargin local dlistGuishader, dlistMinimap, oldMinimapGeometry -local dualscreenMode = ((Spring.GetConfigInt("DualScreenMode", 0) or 0) == 1) +local dualscreenMode = ((SpringUnsynced.GetConfigInt("DualScreenMode", 0) or 0) == 1) -- Icon density scaling: reduce icon size when many units are on the map local iconDensityMaxUnits = 18000 local iconDensityMinScale = 0.5 -local baseMinimapIconScale = Spring.GetConfigFloat("MinimapIconScale", 3.5) +local baseMinimapIconScale = SpringUnsynced.GetConfigFloat("MinimapIconScale", 3.5) local lastAppliedIconScale = nil local function checkGuishader(force) @@ -79,7 +79,7 @@ local function clear() end function widget:ViewResize() - local newDualscreenMode = ((Spring.GetConfigInt("DualScreenMode", 0) or 0) == 1) + local newDualscreenMode = ((SpringUnsynced.GetConfigInt("DualScreenMode", 0) or 0) == 1) if dualscreenMode ~= newDualscreenMode then dualscreenMode = newDualscreenMode if dualscreenMode then @@ -116,7 +116,7 @@ function widget:ViewResize() backgroundRect = { 0, vsy - usedHeight - elementPadding, usedWidth + elementPadding, vsy } if not dualscreenMode then - Spring.SendCommands(string.format("minimap geometry %i %i %i %i", 0, 0, usedWidth, usedHeight)) + SpringUnsynced.SendCommands(string.format("minimap geometry %i %i %i %i", 0, 0, usedWidth, usedHeight)) checkGuishader(true) end dlistMinimap = gl.DeleteList(dlistMinimap) @@ -127,15 +127,15 @@ function widget:ViewResize() end function widget:Initialize() - oldMinimapGeometry = Spring.GetMiniMapGeometry() + oldMinimapGeometry = SpringUnsynced.GetMiniMapGeometry() gl.SlaveMiniMap(true) widget:ViewResize() - if Spring.GetConfigInt("MinimapMinimize", 0) == 1 then - Spring.SendCommands("minimap minimize 1") + if SpringUnsynced.GetConfigInt("MinimapMinimize", 0) == 1 then + SpringUnsynced.SendCommands("minimap minimize 1") end - _, _, _, _, minimized, maximized = Spring.GetMiniMapGeometry() + _, _, _, _, minimized, maximized = SpringUnsynced.GetMiniMapGeometry() WG["minimap"] = {} WG["minimap"].getHeight = function() @@ -145,7 +145,7 @@ function widget:Initialize() return mathFloor(maxAllowedHeight * vsy), maxAllowedHeight end WG["minimap"].setMaxHeight = function(value) - Spring.SetConfigFloat("MinimapMaxHeight", value) + SpringUnsynced.SetConfigFloat("MinimapMaxHeight", value) maxAllowedHeight = value widget:ViewResize() end @@ -154,7 +154,7 @@ function widget:Initialize() end WG["minimap"].setLeftClickMove = function(value) leftClickMove = value - Spring.SetConfigInt("MinimapLeftClickMove", value and 1 or 0) + SpringUnsynced.SetConfigInt("MinimapLeftClickMove", value and 1 or 0) end WG["minimap"].setBaseIconScale = function(value) baseMinimapIconScale = value @@ -170,11 +170,11 @@ function widget:Shutdown() gl.SlaveMiniMap(false) -- Restore original icon scale - Spring.SendCommands("minimap unitsize " .. baseMinimapIconScale) - Spring.SetConfigFloat("MinimapIconScale", baseMinimapIconScale) + SpringUnsynced.SendCommands("minimap unitsize " .. baseMinimapIconScale) + SpringUnsynced.SetConfigFloat("MinimapIconScale", baseMinimapIconScale) if not dualscreenMode then - Spring.SendCommands("minimap geometry " .. oldMinimapGeometry) + SpringUnsynced.SendCommands("minimap geometry " .. oldMinimapGeometry) end end @@ -205,7 +205,7 @@ function widget:Update(dt) sec2 = 0 -- Poll ConfigFloat for external changes (e.g. from gui_options) - local cfgMaxHeight = Spring.GetConfigFloat("MinimapMaxHeight", 0.32) + local cfgMaxHeight = SpringUnsynced.GetConfigFloat("MinimapMaxHeight", 0.32) if cfgMaxHeight ~= maxAllowedHeight then maxAllowedHeight = cfgMaxHeight widget:ViewResize() @@ -215,16 +215,16 @@ function widget:Update(dt) return end - _, _, _, _, minimized, maximized = Spring.GetMiniMapGeometry() + _, _, _, _, minimized, maximized = SpringUnsynced.GetMiniMapGeometry() if minimized or maximized then return end - Spring.SendCommands(string.format("minimap geometry %i %i %i %i", 0, 0, usedWidth, usedHeight)) + SpringUnsynced.SendCommands(string.format("minimap geometry %i %i %i %i", 0, 0, usedWidth, usedHeight)) checkGuishader() -- Icon density scaling: reduce icon size when many units are on the map - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() local totalUnits = allUnits and #allUnits or 0 local unitFraction = math.min(totalUnits / iconDensityMaxUnits, 1.0) local densityScale = 1.0 - (1.0 - iconDensityMinScale) * unitFraction @@ -232,7 +232,7 @@ function widget:Update(dt) local resBoost = 1.0 + 0.18 * math.min(math.max((vsy - 1080) / (2880 - 1080), 0), 1) local scaledIconSize = baseMinimapIconScale * densityScale * resBoost if scaledIconSize ~= lastAppliedIconScale then - Spring.SendCommands("minimap unitsize " .. scaledIconSize) + SpringUnsynced.SendCommands("minimap unitsize " .. scaledIconSize) lastAppliedIconScale = scaledIconSize end end @@ -253,10 +253,10 @@ function widget:DrawScreen() if minimized or maximized then clear() else - local x, y = Spring.GetMouseState() + local x, y = SpringUnsynced.GetMouseState() if math_isInRect(x, y, backgroundRect[1], backgroundRect[2] - elementPadding, backgroundRect[3] + elementPadding, backgroundRect[4]) then if not math_isInRect(x, y, backgroundRect[1], backgroundRect[2] + 1, backgroundRect[3] - 1, backgroundRect[4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end end end @@ -273,11 +273,11 @@ function widget:DrawScreen() end wasOverview = true - elseif not (minimized or maximized) or (wasOverview and Spring.GetConfigInt("MinimapMinimize", 0) == 0) then - if wasOverview and Spring.GetConfigInt("MinimapMinimize", 0) == 0 then + elseif not (minimized or maximized) or (wasOverview and SpringUnsynced.GetConfigInt("MinimapMinimize", 0) == 0) then + if wasOverview and SpringUnsynced.GetConfigInt("MinimapMinimize", 0) == 0 then gl.SlaveMiniMap(true) wasOverview = false - Spring.SendCommands("minimap minimize 0") + SpringUnsynced.SendCommands("minimap minimize 0") end if dlistGuishader and WG["guishader"] then @@ -306,15 +306,15 @@ end function widget:SetConfigData(data) -- Migrate old maxHeight config data to ConfigFloat (one-time) - if data.maxHeight ~= nil and Spring.GetConfigFloat("MinimapMaxHeight", -1) == -1 then + if data.maxHeight ~= nil and SpringUnsynced.GetConfigFloat("MinimapMaxHeight", -1) == -1 then maxAllowedHeight = data.maxHeight - Spring.SetConfigFloat("MinimapMaxHeight", data.maxHeight) + SpringUnsynced.SetConfigFloat("MinimapMaxHeight", data.maxHeight) end -- leftClickMove now stored as Spring ConfigInt "MinimapLeftClickMove" - if data.leftClickMove ~= nil and Spring.GetConfigInt("MinimapLeftClickMove", -1) == -1 then + if data.leftClickMove ~= nil and SpringUnsynced.GetConfigInt("MinimapLeftClickMove", -1) == -1 then -- Migrate old config data to new ConfigInt (one-time) leftClickMove = data.leftClickMove - Spring.SetConfigInt("MinimapLeftClickMove", data.leftClickMove and 1 or 0) + SpringUnsynced.SetConfigInt("MinimapLeftClickMove", data.leftClickMove and 1 or 0) end end @@ -323,14 +323,14 @@ function widget:MouseMove(x, y) if leftclicked and leftClickMove then local px, py, pz = minimapToWorld(x, y, vpy) if py then - Spring.SetCameraTarget(px, py, pz, 0.04) + SpringUnsynced.SetCameraTarget(px, py, pz, 0.04) end end end end function widget:MousePress(x, y, button) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if dualscreenMode then @@ -355,7 +355,7 @@ function widget:MousePress(x, y, button) leftclicked = true local px, py, pz = minimapToWorld(x, y, vpy) if py then - Spring.SetCameraTarget(px, py, pz, 0.2) + SpringUnsynced.SetCameraTarget(px, py, pz, 0.2) return true end end diff --git a/luaui/Widgets/gui_mouse_fx.lua b/luaui/Widgets/gui_mouse_fx.lua index ab31527e8a6..d525d2fd5dd 100644 --- a/luaui/Widgets/gui_mouse_fx.lua +++ b/luaui/Widgets/gui_mouse_fx.lua @@ -56,9 +56,9 @@ local types = { -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -local spGetCameraPosition = Spring.GetCameraPosition -local spTraceScreenRay = Spring.TraceScreenRay -local spGetMouseState = Spring.GetMouseState +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetMouseState = SpringUnsynced.GetMouseState local glCreateList = gl.CreateList local glDeleteList = gl.DeleteList @@ -157,7 +157,7 @@ function widget:DrawWorldPreUnit() if chobbyInterface then return end - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end diff --git a/luaui/Widgets/gui_options.lua b/luaui/Widgets/gui_options.lua index cdcd464af64..baea79a18f1 100644 --- a/luaui/Widgets/gui_options.lua +++ b/luaui/Widgets/gui_options.lua @@ -13,7 +13,7 @@ function widget:GetInfo() } end -Spring.SendCommands("resbar 0") +SpringUnsynced.SendCommands("resbar 0") -- Add new options at: function init @@ -109,16 +109,16 @@ local sounds = { toggleOffClick = "LuaUI/Sounds/switchoff.wav", } -local continuouslyClean = Spring.GetConfigInt("ContinuouslyClearMapmarks", 0) == 1 +local continuouslyClean = SpringUnsynced.GetConfigInt("ContinuouslyClearMapmarks", 0) == 1 -local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode +local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode --local anonymousTeamColor = {Spring.GetConfigInt("anonymousColorR", 255)/255, Spring.GetConfigInt("anonymousColorG", 0)/255, Spring.GetConfigInt("anonymousColorB", 0)/255} -local fontfile = "fonts/" .. Spring.GetConfigString("bar_font", "Poppins-Regular.otf") -local fontfile2 = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") -local fontfile3 = "fonts/" .. Spring.GetConfigString("bar_font3", "SourceCodePro-Medium.otf") +local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font", "Poppins-Regular.otf") +local fontfile2 = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") +local fontfile3 = "fonts/" .. SpringUnsynced.GetConfigString("bar_font3", "SourceCodePro-Medium.otf") -local vsx, vsy = Spring.GetViewGeometry() +local vsx, vsy = SpringUnsynced.GetViewGeometry() local fontfileScale = (0.5 + (vsx * vsy / 5700000)) local fontfileSize = 36 local fontfileOutlineSize = 7 @@ -145,7 +145,7 @@ local show = false local prevShow = show local manualChange = true -local spGetGroundHeight = Spring.GetGroundHeight +local spGetGroundHeight = SpringShared.GetGroundHeight local os_clock = os.clock local math_isInRect = math.isInRect @@ -170,21 +170,21 @@ local GL_ONE = GL.ONE local RectRound, elementCorner, elementMargin, elementPadding, UiElement, UiButton, UiSlider, UiSliderKnob, UiToggle, UiSelector, UiSelectHighlight, bgpadding local isSinglePlayer = Spring.Utilities.Gametype.IsSinglePlayer() -local isReplay = Spring.IsReplay() +local isReplay = SpringUnsynced.IsReplay() local skipUnpauseOnHide = false local skipUnpauseOnLobbyHide = false local desiredWaterValue = 4 local waterDetected = false -if select(3, Spring.GetGroundExtremes()) < 0 then +if select(3, SpringShared.GetGroundExtremes()) < 0 then waterDetected = true end local heightmapChangeBuffer = {} local widgetScale = (vsy / 1080) -local edgeMoveWidth = tonumber(Spring.GetConfigFloat("EdgeMoveWidth", 1) or 0.02) +local edgeMoveWidth = tonumber(SpringUnsynced.GetConfigFloat("EdgeMoveWidth", 1) or 0.02) local defaultMapSunPos = { gl.GetSun("pos") } local defaultSunLighting = { @@ -202,7 +202,7 @@ local defaultSkyAxisAngle = { -- Correct some maps fog if Game.mapName == "Nine_Metal_Islands_V1" then - Spring.SetAtmosphere({ fogStart = 999990, fogEnd = 9999999 }) + SpringUnsynced.SetAtmosphere({ fogStart = 999990, fogEnd = 9999999 }) end local defaultMapFog = { fogStart = gl.GetAtmosphere("fogStart"), @@ -286,10 +286,10 @@ if not startScript then [player0] { team=0; - name=]] .. select(1, Spring.GetPlayerInfo(Spring.GetMyPlayerID())) .. [[; + name=]] .. select(1, SpringShared.GetPlayerInfo(Spring.GetMyPlayerID())) .. [[; } mapname=]] .. Game.mapName .. [[; - myplayername=]] .. select(1, Spring.GetPlayerInfo(Spring.GetMyPlayerID())) .. [[; + myplayername=]] .. select(1, SpringShared.GetPlayerInfo(Spring.GetMyPlayerID())) .. [[; ishost=1; gametype=]] .. Game.gameName .. " " .. Game.gameVersion .. [[; nohelperais=0; @@ -300,19 +300,19 @@ end local function setEngineFont() local relativesize = 1 --"fonts/FreeSansBold.otf" - Spring.SetConfigInt("SmallFontSize", fontfileSize * fontfileScale * relativesize) - Spring.SetConfigInt("SmallFontOutlineWidth", fontfileOutlineSize * fontfileScale * relativesize * 0.85) - Spring.SetConfigInt("SmallFontOutlineWeight", 2) + SpringUnsynced.SetConfigInt("SmallFontSize", fontfileSize * fontfileScale * relativesize) + SpringUnsynced.SetConfigInt("SmallFontOutlineWidth", fontfileOutlineSize * fontfileScale * relativesize * 0.85) + SpringUnsynced.SetConfigInt("SmallFontOutlineWeight", 2) - Spring.SetConfigInt("FontSize", fontfileSize * fontfileScale * relativesize) - Spring.SetConfigInt("FontOutlineWidth", fontfileOutlineSize * fontfileScale * relativesize * 0.85) - Spring.SetConfigInt("FontOutlineWeight", 2) + SpringUnsynced.SetConfigInt("FontSize", fontfileSize * fontfileScale * relativesize) + SpringUnsynced.SetConfigInt("FontOutlineWidth", fontfileOutlineSize * fontfileScale * relativesize * 0.85) + SpringUnsynced.SetConfigInt("FontOutlineWeight", 2) - Spring.SendCommands("font " .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf")) + SpringUnsynced.SendCommands("font " .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf")) -- set spring engine default font cause it cant thee game archive fonts on launch - Spring.SetConfigString("SmallFontFile", "FreeSansBold.otf") - Spring.SetConfigString("FontFile", "FreeSansBold.otf") + SpringUnsynced.SetConfigString("SmallFontFile", "FreeSansBold.otf") + SpringUnsynced.SetConfigString("FontFile", "FreeSansBold.otf") end setEngineFont() @@ -324,15 +324,15 @@ local function showOption(option) end local function adjustShadowQuality() - local quality = Spring.GetConfigInt("ShadowQuality", 3) + local quality = SpringUnsynced.GetConfigInt("ShadowQuality", 3) local shadowMapSize = 600 + math.min(10240, (vsy + vsx) * 0.37) * (quality * 0.5) - Spring.SetConfigInt("Shadows", (quality == 0 and 0 or 1)) - Spring.SetConfigInt("ShadowMapSize", shadowMapSize) - Spring.SendCommands("shadows " .. (quality == 0 and 0 or 1) .. " " .. shadowMapSize) + SpringUnsynced.SetConfigInt("Shadows", (quality == 0 and 0 or 1)) + SpringUnsynced.SetConfigInt("ShadowMapSize", shadowMapSize) + SpringUnsynced.SendCommands("shadows " .. (quality == 0 and 0 or 1) .. " " .. shadowMapSize) end function widget:ViewResize() - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() widgetScale = (vsy / 1080) @@ -381,10 +381,10 @@ function widget:ViewResize() end local function detectWater() - local _, _, mapMinHeight, mapMaxHeight = Spring.GetGroundExtremes() + local _, _, mapMinHeight, mapMaxHeight = SpringShared.GetGroundExtremes() if mapMinHeight <= -2 then waterDetected = true - Spring.SendCommands("water " .. desiredWaterValue) + SpringUnsynced.SendCommands("water " .. desiredWaterValue) end end @@ -402,7 +402,7 @@ local floor = math.floor local inputMode = "" function widget:TextInput(char) -- if it isnt working: chobby probably hijacked it - if not chobbyInterface and not Spring.IsGUIHidden() and showTextInput and show then + if not chobbyInterface and not SpringUnsynced.IsGUIHidden() and showTextInput and show then if inputTextInsertActive then inputText = utf8.sub(inputText, 1, inputTextPosition) .. char .. utf8.sub(inputText, inputTextPosition + 2) if inputTextPosition <= utf8.len(inputText) then @@ -454,7 +454,7 @@ local function cancelChatInput() if selectOptionsList then selectOptionsList = glDeleteList(selectOptionsList) end - Spring.SDLStopTextInput() + SpringUnsynced.SDLStopTextInput() widgetHandler.textOwner = nil --widgetHandler:DisownText() if doReinit then applyFilter() @@ -477,7 +477,7 @@ function updateInputDlist() local activationArea = { screenX, screenY - screenHeight, screenX + screenWidth, screenY } local usedFontSize = 15 * widgetScale local lineHeight = floor(usedFontSize * 1.15) - local x, y, _ = Spring.GetMouseState() + local x, y, _ = SpringUnsynced.GetMouseState() local chatlogHeightDiff = 0 local inputFontSize = floor(usedFontSize * 1.03) local inputHeight = floor(inputFontSize * 2.15) @@ -944,21 +944,21 @@ end local function updateGrabinput() -- grabinput makes alt-tabbing harder, so loosen grip a bit when in lobby would be wise - if Spring.GetConfigInt("grabinput", 1) == 1 and not gameOver then + if SpringUnsynced.GetConfigInt("grabinput", 1) == 1 and not gameOver then if chobbyInterface then if enabledGrabinput then enabledGrabinput = false - Spring.SendCommands("grabinput 0") + SpringUnsynced.SendCommands("grabinput 0") end else if not enabledGrabinput then enabledGrabinput = true - Spring.SendCommands("grabinput 1") + SpringUnsynced.SendCommands("grabinput 1") end end else enabledGrabinput = false - Spring.SendCommands("grabinput 0") + SpringUnsynced.SendCommands("grabinput 0") end end @@ -971,12 +971,12 @@ local isOffscreen = false local isOffscreenTime local prevOffscreenVolume local apiUnitTrackerEnabledCount = 0 -local cachedMuteOffscreen = Spring.GetConfigInt("muteOffscreen", 0) == 1 +local cachedMuteOffscreen = SpringUnsynced.GetConfigInt("muteOffscreen", 0) == 1 local offscreenCheckTimer = 0 function resetUserVolume() if prevOffscreenVolume then - Spring.SetConfigInt("snd_volmaster", prevOffscreenVolume) + SpringUnsynced.SetConfigInt("snd_volmaster", prevOffscreenVolume) prevOffscreenVolume = nil end end @@ -1002,7 +1002,7 @@ function widget:Update(dt) end if checkOffscreen then local prevIsOffscreen = isOffscreen - isOffscreen = select(6, Spring.GetMouseState()) + isOffscreen = select(6, SpringUnsynced.GetMouseState()) if isOffscreen and enabledGrabinput then enabledGrabinput = false end @@ -1011,20 +1011,20 @@ function widget:Update(dt) local prevIsOffscreenTime = isOffscreenTime isOffscreenTime = now if isOffscreen and not prevIsOffscreenTime then - prevOffscreenVolume = tonumber(Spring.GetConfigInt("snd_volmaster", 40) or 40) + prevOffscreenVolume = tonumber(SpringUnsynced.GetConfigInt("snd_volmaster", 40) or 40) end end if isOffscreenTime then if isOffscreenTime + muteFadeTime > now then if isOffscreen then - Spring.SetConfigInt("snd_volmaster", prevOffscreenVolume * (1 - ((now - isOffscreenTime) / muteFadeTime))) + SpringUnsynced.SetConfigInt("snd_volmaster", prevOffscreenVolume * (1 - ((now - isOffscreenTime) / muteFadeTime))) else - Spring.SetConfigInt("snd_volmaster", prevOffscreenVolume * ((now - isOffscreenTime) / muteFadeTime)) + SpringUnsynced.SetConfigInt("snd_volmaster", prevOffscreenVolume * ((now - isOffscreenTime) / muteFadeTime)) end else isOffscreenTime = nil if isOffscreen then - Spring.SetConfigInt("snd_volmaster", 0) + SpringUnsynced.SetConfigInt("snd_volmaster", 0) else resetUserVolume() end @@ -1062,14 +1062,14 @@ function widget:Update(dt) -- Spring.SetCameraState(nil, 1) --else if WG.lockcamera and not WG.lockcamera.GetPlayerID() and WG.setcamera_bugfix == true then - Spring.SetCameraState(nil, cameraTransitionTime) + SpringUnsynced.SetCameraState(nil, cameraTransitionTime) end --end -- check if there is water shown (we do this because basic water 0 saves perf when no water is rendered) if not waterDetected then -- in case of modoption waterlevel has been made to show water - if not checkedForWaterAfterGamestart and Spring.GetGameFrame() <= 30 then + if not checkedForWaterAfterGamestart and SpringShared.GetGameFrame() <= 30 then detectWater() checkedForWaterAfterGamestart = true end @@ -1082,7 +1082,7 @@ function widget:Update(dt) while z <= coords[4] do if spGetGroundHeight(x, z) <= 0 then waterDetected = true - Spring.SendCommands("water " .. desiredWaterValue) + SpringUnsynced.SendCommands("water " .. desiredWaterValue) break end z = z + 8 @@ -1101,8 +1101,8 @@ function widget:Update(dt) sec2 = sec2 + dt if sec2 > 0.5 then sec2 = 0 - continuouslyClean = Spring.GetConfigInt("ContinuouslyClearMapmarks", 0) == 1 - cachedMuteOffscreen = Spring.GetConfigInt("muteOffscreen", 0) == 1 + continuouslyClean = SpringUnsynced.GetConfigInt("ContinuouslyClearMapmarks", 0) == 1 + cachedMuteOffscreen = SpringUnsynced.GetConfigInt("muteOffscreen", 0) == 1 -- detect guishader toggle: force refresh when it comes back on local guishaderActive = WG["guishader"] ~= nil @@ -1141,13 +1141,13 @@ function widget:Update(dt) applyFilter() end if getOptionByID("sndvolmaster") then - options[getOptionByID("sndvolmaster")].value = tonumber(Spring.GetConfigInt("snd_volmaster", 40) or 40) -- update value because other widgets can adjust this too + options[getOptionByID("sndvolmaster")].value = tonumber(SpringUnsynced.GetConfigInt("snd_volmaster", 40) or 40) -- update value because other widgets can adjust this too end if getOptionByID("sndvolmusic") then if WG["music"] and WG["music"].GetMusicVolume then options[getOptionByID("sndvolmusic")].value = WG["music"].GetMusicVolume() else - options[getOptionByID("sndvolmusic")].value = tonumber(Spring.GetConfigInt("snd_volmusic", 50) or 50) + options[getOptionByID("sndvolmusic")].value = tonumber(SpringUnsynced.GetConfigInt("snd_volmusic", 50) or 50) end end end @@ -1156,7 +1156,7 @@ end function widget:CommandNotify(cmdID, cmdParams, cmdOptions) if show then --on window - local mx, my, ml = Spring.GetMouseState() + local mx, my, ml = SpringUnsynced.GetMouseState() if math_isInRect(mx, my, windowRect[1], windowRect[2], windowRect[3], windowRect[4]) then return true elseif titleRect and math_isInRect(mx, my, titleRect[1], titleRect[2], titleRect[3], titleRect[4]) then @@ -1178,16 +1178,16 @@ function widget:RecvLuaMsg(msg, playerID) chobbyInterface = (msg:sub(1, 19) == "LobbyOverlayActive1") updateGrabinput() if (isSinglePlayer or isReplay) and pauseGameWhenSingleplayer and not skipUnpauseOnHide then - local _, _, isClientPaused, _ = Spring.GetGameState() + local _, _, isClientPaused, _ = SpringUnsynced.GetGameState() if chobbyInterface and isClientPaused then skipUnpauseOnLobbyHide = true end if not skipUnpauseOnLobbyHide then - Spring.SendCommands("pause " .. (chobbyInterface and "1" or "0")) + SpringUnsynced.SendCommands("pause " .. (chobbyInterface and "1" or "0")) pauseGameWhenSingleplayerExecuted = chobbyInterface end if not chobbyInterface then - Spring.SetConfigInt("VSync", Spring.GetConfigInt("VSyncGame", -1) * Spring.GetConfigInt("VSyncFraction", 1)) + SpringUnsynced.SetConfigInt("VSync", SpringUnsynced.GetConfigInt("VSyncGame", -1) * SpringUnsynced.GetConfigInt("VSyncFraction", 1)) end end end @@ -1195,7 +1195,7 @@ end local function checkPause() -- pause/unpause when the options/quitscreen interface shows - local _, _, isClientPaused, _ = Spring.GetGameState() + local _, _, isClientPaused, _ = SpringUnsynced.GetGameState() if not isClientPaused then skipUnpauseOnHide = false skipUnpauseOnLobbyHide = false @@ -1206,7 +1206,7 @@ local function checkPause() skipUnpauseOnHide = true end if not skipUnpauseOnHide then - Spring.SendCommands("pause " .. (show and "1" or "0")) -- cause several widgets are still using old colors + SpringUnsynced.SendCommands("pause " .. (show and "1" or "0")) -- cause several widgets are still using old colors showToggledOff = not show pauseGameWhenSingleplayerExecuted = show end @@ -1228,7 +1228,7 @@ local function checkQuitscreen() skipUnpauseOnHide = true end if not skipUnpauseOnHide then - Spring.SendCommands("pause " .. (quitscreen and "1" or "0")) -- cause several widgets are still using old colors + SpringUnsynced.SendCommands("pause " .. (quitscreen and "1" or "0")) -- cause several widgets are still using old colors pauseGameWhenSingleplayerExecuted = quitscreen end end @@ -1276,16 +1276,16 @@ function widget:DrawScreen() if (show or showOnceMore) and windowList then --on window - local mx, my, ml = Spring.GetMouseState() + local mx, my, ml = SpringUnsynced.GetMouseState() if (math_isInRect(mx, my, windowRect[1], windowRect[2], windowRect[3], windowRect[4])) or (titleRect and math_isInRect(mx, my, titleRect[1], titleRect[2], titleRect[3], titleRect[4])) or (chatInputArea and math_isInRect(mx, my, chatInputArea[1], chatInputArea[2], chatInputArea[3], chatInputArea[4])) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end if groupRect ~= nil then for id, group in pairs(optionGroups) do if group.numOptions > 0 then if devMode or devUI or group.id ~= "dev" then if math_isInRect(mx, my, groupRect[id][1], groupRect[id][2], groupRect[id][3], groupRect[id][4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") break end end @@ -1470,7 +1470,7 @@ function widget:DrawScreen() if math_isInRect(mx, my, optionSelect[#optionSelect][1], optionSelect[#optionSelect][2], optionSelect[#optionSelect][3], optionSelect[#optionSelect][4]) then UiSelectHighlight(optionButtons[showSelectOptions][1], math.floor(yPos - oHeight - oPadding), optionButtons[showSelectOptions][1] + maxWidth, math.floor(yPos + oPadding)) if playSounds and (prevSelectHover == nil or prevSelectHover ~= i) then - Spring.PlaySoundFile(sounds.selectHoverClick, 0.04, "ui") + SpringUnsynced.PlaySoundFile(sounds.selectHoverClick, 0.04, "ui") end prevSelectHover = k end @@ -1693,7 +1693,7 @@ function getSliderValue(draggingSlider, mx) end function widget:MouseWheel(up, value) - local x, y = Spring.GetMouseState() + local x, y = SpringUnsynced.GetMouseState() if show then return true end @@ -1707,7 +1707,7 @@ function widget:MouseMove(mx, my) applyOptionValue(draggingSlider, newValue) -- disabled so only on release it gets applied if playSounds and (lastSliderSound == nil or os_clock() - lastSliderSound > 0.04) then lastSliderSound = os_clock() - Spring.PlaySoundFile(sounds.sliderDrag, 0.4, "ui") + SpringUnsynced.PlaySoundFile(sounds.sliderDrag, 0.4, "ui") end end end @@ -1722,7 +1722,7 @@ function widget:MouseRelease(x, y, button) end function mouseEvent(mx, my, button, release) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return false end @@ -1742,7 +1742,7 @@ function mouseEvent(mx, my, button, release) showSelectOptions = nil selectClickAllowHide = nil if playSounds then - Spring.PlaySoundFile(sounds.paginatorClick, 0.9, "ui") + SpringUnsynced.PlaySoundFile(sounds.paginatorClick, 0.9, "ui") end end tabClick = true @@ -1765,7 +1765,7 @@ function mouseEvent(mx, my, button, release) startColumn = (totalColumns - maxShownColumns) + 1 end if playSounds then - Spring.PlaySoundFile(sounds.paginatorClick, 0.6, "ui") + SpringUnsynced.PlaySoundFile(sounds.paginatorClick, 0.6, "ui") end showSelectOptions = nil selectClickAllowHide = nil @@ -1776,7 +1776,7 @@ function mouseEvent(mx, my, button, release) startColumn = 1 end if playSounds then - Spring.PlaySoundFile(sounds.paginatorClick, 0.6, "ui") + SpringUnsynced.PlaySoundFile(sounds.paginatorClick, 0.6, "ui") end showSelectOptions = nil selectClickAllowHide = nil @@ -1796,7 +1796,7 @@ function mouseEvent(mx, my, button, release) if math_isInRect(mx, my, o[1], o[2], o[3], o[4]) then applyOptionValue(showSelectOptions, o[5]) if playSounds then - Spring.PlaySoundFile(sounds.selectClick, 0.5, "ui") + SpringUnsynced.PlaySoundFile(sounds.selectClick, 0.5, "ui") end end end @@ -1822,9 +1822,9 @@ function mouseEvent(mx, my, button, release) applyOptionValue(i, not options[i].value) if playSounds then if options[i] and options[i].value then - Spring.PlaySoundFile(sounds.toggleOnClick, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sounds.toggleOnClick, 0.75, "ui") else - Spring.PlaySoundFile(sounds.toggleOffClick, 0.75, "ui") + SpringUnsynced.PlaySoundFile(sounds.toggleOffClick, 0.75, "ui") end end elseif options[i].type == "slider" and math_isInRect(mx, my, o[1], o[2], o[3], o[4]) then @@ -1851,13 +1851,13 @@ function mouseEvent(mx, my, button, release) if options[draggingSlider].value ~= newValue then applyOptionValue(draggingSlider, getSliderValue(draggingSlider, mx)) -- disabled so only on release it gets applied if playSounds then - Spring.PlaySoundFile(sounds.sliderDrag, 0.3, "ui") + SpringUnsynced.PlaySoundFile(sounds.sliderDrag, 0.3, "ui") end end elseif options[i].type == "select" and math_isInRect(mx, my, o[1], o[2], o[3], o[4]) then if playSounds then - Spring.PlaySoundFile(sounds.selectUnfoldClick, 0.6, "ui") + SpringUnsynced.PlaySoundFile(sounds.selectUnfoldClick, 0.6, "ui") end if showSelectOptions == nil then showSelectOptions = i @@ -1951,7 +1951,7 @@ function applyOptionValue(i, newValue, skipRedrawWindow, force) if options[i].id ~= "preset" and presets.lowest[options[i].id] ~= nil and manualChange then if options[getOptionByID("preset")] then options[getOptionByID("preset")].value = Spring.I18N("ui.settings.option.select_custom") - Spring.SetConfigString("graphicsPreset", "custom") + SpringUnsynced.SetConfigString("graphicsPreset", "custom") end end @@ -1969,7 +1969,7 @@ function applyOptionValue(i, newValue, skipRedrawWindow, force) end forceUpdate = true if id == "teamcolors" then - Spring.SendCommands("luarules reloadluaui") -- cause several widgets are still using old colors + SpringUnsynced.SendCommands("luarules reloadluaui") -- cause several widgets are still using old colors end end @@ -2375,7 +2375,7 @@ function init() local displays = WG["screenMode"] and WG["screenMode"].GetDisplays() or {} local currentDisplay = 1 - local v_sx, v_sy, v_px, v_py = Spring.GetViewGeometry() + local v_sx, v_sy, v_px, v_py = SpringUnsynced.GetViewGeometry() local displayNames = {} local hasMultiDisplayOption = false for index, display in ipairs(displays) do @@ -2402,9 +2402,9 @@ function init() end -- only allow dualscreen-mode on single displays when super ultrawide screen or Multi Display option shows - if (#displayNames <= 1 and vsx / vsy < 2.5) or (#displayNames > 1 and #displayNames == Spring.GetNumDisplays()) then - if Spring.GetConfigInt("DualScreenMode", 0) ~= 0 then - Spring.SetConfigInt("DualScreenMode", 0) + if (#displayNames <= 1 and vsx / vsy < 2.5) or (#displayNames > 1 and #displayNames == SpringUnsynced.GetNumDisplays()) then + if SpringUnsynced.GetConfigInt("DualScreenMode", 0) ~= 0 then + SpringUnsynced.SetConfigInt("DualScreenMode", 0) end end @@ -2421,7 +2421,7 @@ function init() end -- scan for shader version error if string.find(line, "error: GLSL 1.50 is not supported", nil, true) then - Spring.SetConfigInt("LuaShaders", 0) + SpringUnsynced.SetConfigInt("LuaShaders", 0) end -- look for system hardware @@ -2456,10 +2456,10 @@ function init() -- restrict options for potato systems if isPotatoCpu or isPotatoGpu then if isPotatoCpu then - Spring.Echo("potato CPU detected") + SpringShared.Echo("potato CPU detected") end if isPotatoGpu then - Spring.Echo("potato Graphics Card detected") + SpringShared.Echo("potato Graphics Card detected") end end -- restric gfx preset options for potato gpu, lowest preset is added and high preset is removed @@ -2534,7 +2534,7 @@ function init() type = "select", options = presetNames, onload = function(i) - local preset = Spring.GetConfigString("graphicsPreset", "custom") + local preset = SpringUnsynced.GetConfigString("graphicsPreset", "custom") local configSettingValues = { "lowest", "low", "medium", "high", "ultra", "custom" } for k, value in pairs(configSettingValues) do if value == preset then @@ -2547,12 +2547,12 @@ function init() local configSetting = "custom" local configSettingValues = { "lowest", "low", "medium", "high", "ultra", "custom" } configSetting = configSettingValues[value] - Spring.SetConfigString("graphicsPreset", configSetting) + SpringUnsynced.SetConfigString("graphicsPreset", configSetting) if configSetting == "custom" then return end - Spring.Echo("Loading preset: " .. options[i].options[value]) + SpringShared.Echo("Loading preset: " .. options[i].options[value]) manualChange = false for optionID, value in pairs(presets[configSetting]) do local i = getOptionByID(optionID) @@ -2581,7 +2581,7 @@ function init() onchange = function(i, value) --currentDisplay = value selectedDisplay = value - Spring.SetConfigInt("SelectedDisplay", value) + SpringUnsynced.SetConfigInt("SelectedDisplay", value) resolutionNames = {} screenmodeOffset = 0 for _, screenMode in ipairs(screenModes) do @@ -2593,7 +2593,7 @@ function init() end options[getOptionByID("resolution")].options = resolutionNames if selectedDisplay == currentDisplay then - options[getOptionByID("resolution")].value = Spring.GetConfigInt("SelectedScreenMode", 1) + options[getOptionByID("resolution")].value = SpringUnsynced.GetConfigInt("SelectedScreenMode", 1) else options[getOptionByID("resolution")].value = 0 end @@ -2607,7 +2607,7 @@ function init() name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.resolution"), type = "select", options = resolutionNames, - value = Spring.GetConfigInt("SelectedScreenMode", 1), + value = SpringUnsynced.GetConfigInt("SelectedScreenMode", 1), description = Spring.I18N("ui.settings.option.resolution_descr"), onload = function(i, value) -- FIXME: disabled for now due to "Now whenever i do fullscreen or borderless the game will go to monitor 2 regardless of the chosen option. (I want the game on monitor 1)." @@ -2616,12 +2616,12 @@ function init() --end end, onchange = function(i, value) - Spring.SetConfigInt("SelectedScreenMode", value) + SpringUnsynced.SetConfigInt("SelectedScreenMode", value) if WG["screenMode"] then WG["screenMode"].SetScreenMode(value + screenmodeOffset) currentDisplay = 1 - local v_sx, v_sy, v_px, v_py = Spring.GetViewGeometry() + local v_sx, v_sy, v_px, v_py = SpringUnsynced.GetViewGeometry() for index, display in ipairs(displays) do if v_px >= display.x and v_px < display.x + display.width and v_py >= display.y and v_py < display.y + display.height then currentDisplay = index @@ -2636,10 +2636,10 @@ function init() category = types.dev, name = Spring.I18N("ui.settings.option.dualmode"), type = "bool", - value = Spring.GetConfigInt("DualScreenMode"), + value = SpringUnsynced.GetConfigInt("DualScreenMode"), description = Spring.I18N("ui.settings.option.dualmode_enabled_descr"), onchange = function(_, value) - Spring.SetConfigInt("DualScreenMode", value and 1 or 0) + SpringUnsynced.SetConfigInt("DualScreenMode", value and 1 or 0) end, }, { @@ -2648,10 +2648,10 @@ function init() category = types.dev, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.dualmode_left"), type = "bool", - value = Spring.GetConfigInt("DualScreenMiniMapOnLeft"), + value = SpringUnsynced.GetConfigInt("DualScreenMiniMapOnLeft"), description = Spring.I18N("ui.settings.option.dualmode_left_descr"), onchange = function(_, value) - Spring.SetConfigInt("DualScreenMiniMapOnLeft", value and 1 or 0) + SpringUnsynced.SetConfigInt("DualScreenMiniMapOnLeft", value and 1 or 0) end, }, { @@ -2660,10 +2660,10 @@ function init() category = types.dev, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.dualmode_minimap_aspectratio"), type = "bool", - value = Spring.GetConfigInt("DualScreenMiniMapAspectRatio"), + value = SpringUnsynced.GetConfigInt("DualScreenMiniMapAspectRatio"), description = Spring.I18N("ui.settings.option.dualmode_minimap_aspectratio_descr"), onchange = function(_, value) - Spring.SetConfigInt("DualScreenMiniMapAspectRatio", value and 1 or 0) + SpringUnsynced.SetConfigInt("DualScreenMiniMapAspectRatio", value and 1 or 0) end, }, { @@ -2676,7 +2676,7 @@ function init() value = 2, description = Spring.I18N("ui.settings.option.vsync_descr"), onload = function(i) - local vsync = Spring.GetConfigInt("VSyncGame", -1) + local vsync = SpringUnsynced.GetConfigInt("VSyncGame", -1) if vsync > 0 then options[i].value = 2 elseif vsync < 0 then @@ -2688,12 +2688,12 @@ function init() onchange = function(i, value) local vsync = 0 if value == 2 then - vsync = Spring.GetConfigInt("VSyncFraction", 1) + vsync = SpringUnsynced.GetConfigInt("VSyncFraction", 1) elseif value == 3 then - vsync = -Spring.GetConfigInt("VSyncFraction", 1) + vsync = -SpringUnsynced.GetConfigInt("VSyncFraction", 1) end - Spring.SetConfigInt("VSync", vsync) - Spring.SetConfigInt("VSyncGame", vsync) -- stored here as assurance cause lobby/game also changes vsync when idle and lobby could think game has set vsync 4 after a hard crash + SpringUnsynced.SetConfigInt("VSync", vsync) + SpringUnsynced.SetConfigInt("VSyncGame", vsync) -- stored here as assurance cause lobby/game also changes vsync when idle and lobby could think game has set vsync 4 after a hard crash end, }, { @@ -2705,13 +2705,13 @@ function init() max = 4, step = 1, type = "slider", - value = Spring.GetConfigInt("VSyncFraction", 1), + value = SpringUnsynced.GetConfigInt("VSyncFraction", 1), description = Spring.I18N("ui.settings.option.vsync_fraction_descr"), onchange = function(i, value) - Spring.SetConfigInt("VSyncFraction", value) - local vsync = Spring.GetConfigInt("VSyncGame", -1) + SpringUnsynced.SetConfigInt("VSyncFraction", value) + local vsync = SpringUnsynced.GetConfigInt("VSyncGame", -1) if vsync ~= 0 then - Spring.SetConfigInt("VSync", vsync * value) + SpringUnsynced.SetConfigInt("VSync", vsync * value) end end, }, @@ -2723,10 +2723,10 @@ function init() category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.limitidlefps"), type = "bool", - value = (Spring.GetConfigInt("LimitIdleFps", 0) == 1), + value = (SpringUnsynced.GetConfigInt("LimitIdleFps", 0) == 1), description = Spring.I18N("ui.settings.option.limitidlefps_descr"), onchange = function(i, value) - Spring.SetConfigInt("LimitIdleFps", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("LimitIdleFps", (value and 1 or 0)) end, }, @@ -2738,10 +2738,10 @@ function init() type = "select", options = { Spring.I18N("ui.settings.option.select_off"), "x2", "x4", "x8" }, restart = true, - value = tonumber(Spring.GetConfigInt("MSAALevel", 0) or 0), + value = tonumber(SpringUnsynced.GetConfigInt("MSAALevel", 0) or 0), description = Spring.I18N("ui.settings.option.msaa_descr"), onload = function(i) - local msaa = tonumber(Spring.GetConfigInt("MSAALevel", 0) or 0) + local msaa = tonumber(SpringUnsynced.GetConfigInt("MSAALevel", 0) or 0) if msaa <= 0 then options[getOptionByID("msaa")].value = 1 else @@ -2755,11 +2755,11 @@ function init() end, onchange = function(i, value) if value == 1 then - Spring.SetConfigInt("MSAA", 0) - Spring.SetConfigInt("MSAALevel", -1) -- setting 0 will reset it to default x4 :( + SpringUnsynced.SetConfigInt("MSAA", 0) + SpringUnsynced.SetConfigInt("MSAALevel", -1) -- setting 0 will reset it to default x4 :( else - Spring.SetConfigInt("MSAA", 1) - Spring.SetConfigInt("MSAALevel", tonumber(string.sub(options[getOptionByID("msaa")].options[value], 2))) + SpringUnsynced.SetConfigInt("MSAA", 1) + SpringUnsynced.SetConfigInt("MSAALevel", tonumber(string.sub(options[getOptionByID("msaa")].options[value], 2))) end end, }, @@ -2771,10 +2771,10 @@ function init() name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.supersampling"), type = "bool", restart = false, - value = (Spring.GetConfigFloat("MinSampleShadingRate", 0.0) == 1.0), + value = (SpringUnsynced.GetConfigFloat("MinSampleShadingRate", 0.0) == 1.0), description = Spring.I18N("ui.settings.option.supersampling_descr"), onchange = function(i, value) - Spring.SetConfigFloat("MinSampleShadingRate", (value and 1.0 or 0.0)) + SpringUnsynced.SetConfigFloat("MinSampleShadingRate", (value and 1.0 or 0.0)) end, }, @@ -2894,11 +2894,11 @@ function init() category = types.basic, name = Spring.I18N("ui.settings.option.advmapshading"), type = "bool", - value = (Spring.GetConfigInt("AdvMapShading", 1) == 1), + value = (SpringUnsynced.GetConfigInt("AdvMapShading", 1) == 1), description = Spring.I18N("ui.settings.option.advmapshading_descr"), onchange = function(i, value) - Spring.SetConfigInt("AdvMapShading", (value and 1 or 0)) - Spring.SendCommands("advmapshading " .. (value and "1" or "0")) + SpringUnsynced.SetConfigInt("AdvMapShading", (value and 1 or 0)) + SpringUnsynced.SendCommands("advmapshading " .. (value and "1" or "0")) end, }, @@ -2908,14 +2908,14 @@ function init() name = Spring.I18N("ui.settings.option.cus"), category = types.basic, type = "bool", - value = (Spring.GetConfigInt("cus2", 1) == 1), + value = (SpringUnsynced.GetConfigInt("cus2", 1) == 1), description = Spring.I18N("ui.settings.option.cus_descr"), onchange = function(i, value) if value == 0.5 then - Spring.SendCommands("luarules disablecusgl4") + SpringUnsynced.SendCommands("luarules disablecusgl4") else - Spring.SetConfigInt("cus2", (value and 1 or 0)) - Spring.SendCommands("luarules " .. (value and "reloadcusgl4" or "disablecusgl4")) + SpringUnsynced.SetConfigInt("cus2", (value and 1 or 0)) + SpringUnsynced.SendCommands("luarules " .. (value and "reloadcusgl4" or "disablecusgl4")) end end, }, @@ -2927,10 +2927,10 @@ function init() name = Spring.I18N("ui.settings.option.shadowslider"), type = "select", options = { Spring.I18N("ui.settings.option.select_off"), Spring.I18N("ui.settings.option.select_lowest"), Spring.I18N("ui.settings.option.select_low"), Spring.I18N("ui.settings.option.select_medium"), Spring.I18N("ui.settings.option.select_high"), Spring.I18N("ui.settings.option.select_ultra") }, - value = Spring.GetConfigInt("ShadowQuality", 3) + 1, + value = SpringUnsynced.GetConfigInt("ShadowQuality", 3) + 1, description = Spring.I18N("ui.settings.option.shadowslider_descr"), onchange = function(i, value) - Spring.SetConfigInt("ShadowQuality", value - 1) + SpringUnsynced.SetConfigInt("ShadowQuality", value - 1) adjustShadowQuality() end, }, @@ -2947,7 +2947,7 @@ function init() value = gl.GetSun("shadowDensity"), description = "", onchange = function(i, value) - Spring.SetSunLighting({ groundShadowDensity = value, modelShadowDensity = value }) + SpringUnsynced.SetSunLighting({ groundShadowDensity = value, modelShadowDensity = value }) end, }, @@ -3050,10 +3050,10 @@ function init() category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.lighteffects_headlights"), type = "bool", - value = Spring.GetConfigInt("headlights", 1) == 1, + value = SpringUnsynced.GetConfigInt("headlights", 1) == 1, description = Spring.I18N("ui.settings.option.lighteffects_headlights_descr"), onchange = function(i, value) - Spring.SetConfigInt("headlights", value and 1 or 0) + SpringUnsynced.SetConfigInt("headlights", value and 1 or 0) if widgetHandler.orderList["Deferred rendering GL4"] ~= nil then widgetHandler:DisableWidget("Deferred rendering GL4") widgetHandler:EnableWidget("Deferred rendering GL4") @@ -3066,10 +3066,10 @@ function init() category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.lighteffects_buildlights"), type = "bool", - value = Spring.GetConfigInt("buildlights", 1) == 1, + value = SpringUnsynced.GetConfigInt("buildlights", 1) == 1, description = Spring.I18N("ui.settings.option.lighteffects_buildlights_descr"), onchange = function(i, value) - Spring.SetConfigInt("buildlights", value and 1 or 0) + SpringUnsynced.SetConfigInt("buildlights", value and 1 or 0) if widgetHandler.orderList["Deferred rendering GL4"] ~= nil then widgetHandler:DisableWidget("Deferred rendering GL4") widgetHandler:EnableWidget("Deferred rendering GL4") @@ -3165,11 +3165,11 @@ function init() min = 2500, max = 40000, step = 500, - value = tonumber(Spring.GetConfigInt("FeatureDrawDistance", 10000)), + value = tonumber(SpringUnsynced.GetConfigInt("FeatureDrawDistance", 10000)), description = Spring.I18N("ui.settings.option.featuredrawdist_descr"), onchange = function(i, value) - Spring.SetConfigInt("FeatureFadeDistance", math.floor(value * 0.8)) - Spring.SetConfigInt("FeatureDrawDistance", value) + SpringUnsynced.SetConfigInt("FeatureFadeDistance", math.floor(value * 0.8)) + SpringUnsynced.SetConfigInt("FeatureDrawDistance", value) end, }, @@ -3207,8 +3207,8 @@ function init() if desiredWaterValue > 0 then desiredWaterValue = 4 end - Spring.SendCommands("water " .. desiredWaterValue) - Spring.SetConfigInt("water", 4) + SpringUnsynced.SendCommands("water " .. desiredWaterValue) + SpringUnsynced.SetConfigInt("water", 4) end end, }, @@ -3278,11 +3278,11 @@ function init() max = 3, step = 1, type = "slider", - value = Spring.GetConfigInt("GroundDecals", 0), + value = SpringUnsynced.GetConfigInt("GroundDecals", 0), description = Spring.I18N("ui.settings.option.decals_descr"), onchange = function(i, value) - Spring.SetConfigInt("GroundDecals", value) - Spring.SendCommands("GroundDecals " .. value) + SpringUnsynced.SetConfigInt("GroundDecals", value) + SpringUnsynced.SendCommands("GroundDecals " .. value) end, }, @@ -3312,12 +3312,12 @@ function init() category = types.dev, name = Spring.I18N("ui.settings.option.treewind"), type = "bool", - value = tonumber(Spring.GetConfigInt("TreeWind", 1) or 1) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("TreeWind", 1) or 1) == 1, description = Spring.I18N("ui.settings.option.treewind_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SendCommands("luarules treewind " .. (value and 1 or 0)) - Spring.SetConfigInt("TreeWind", (value and 1 or 0)) + SpringUnsynced.SendCommands("luarules treewind " .. (value and 1 or 0)) + SpringUnsynced.SetConfigInt("TreeWind", (value and 1 or 0)) end, }, @@ -3399,20 +3399,20 @@ function init() min = 0, max = 1, step = 0.01, - value = Spring.GetConfigFloat("FogMult", 1), + value = SpringUnsynced.GetConfigFloat("FogMult", 1), description = Spring.I18N("ui.settings.option.fogmult_descr"), onload = function(i) options[i].onchange(i, options[i].value) end, onchange = function(i, value) - Spring.SetConfigFloat("FogMult", value) + SpringUnsynced.SetConfigFloat("FogMult", value) value = 1 / value -- inverse local newFogStart = math.min(9, (defaultMapFog.fogStart * ((value + 4) * 0.2))) local newFogEnd = math.min(9, defaultMapFog.fogEnd * ((value + 1) * 0.5)) if newFogStart >= newFogEnd then newFogStart = newFogEnd - 0.01 end - Spring.SetAtmosphere({ fogStart = newFogStart, fogEnd = newFogEnd }) + SpringUnsynced.SetAtmosphere({ fogStart = newFogStart, fogEnd = newFogEnd }) end, }, @@ -3428,12 +3428,12 @@ function init() min = 10000, max = 40000, step = 1000, - value = tonumber(Spring.GetConfigInt("MaxParticles", 1) or 15000), + value = tonumber(SpringUnsynced.GetConfigInt("MaxParticles", 1) or 15000), description = Spring.I18N("ui.settings.option.particles_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("MaxParticles", value) - Spring.SetConfigInt("MaxNanoParticles", math.floor(value * 0.34)) + SpringUnsynced.SetConfigInt("MaxParticles", value) + SpringUnsynced.SetConfigInt("MaxNanoParticles", math.floor(value * 0.34)) end, }, @@ -3485,13 +3485,13 @@ function init() type = "select", restart = true, options = soundDevices, - value = soundDevicesByName[Spring.GetConfigString("snd_device")], + value = soundDevicesByName[SpringUnsynced.GetConfigString("snd_device")], description = Spring.I18N("ui.settings.option.snddevice_descr"), onchange = function(i, value) if options[i].options[options[i].value] == "default" then - Spring.SetConfigString("snd_device", "") + SpringUnsynced.SetConfigString("snd_device", "") else - Spring.SetConfigString("snd_device", options[i].options[options[i].value]) + SpringUnsynced.SetConfigString("snd_device", options[i].options[options[i].value]) end end, }, @@ -3505,10 +3505,10 @@ function init() min = 0, max = 80, step = 2, - value = tonumber(Spring.GetConfigInt("snd_volmaster", 1) or 80), + value = tonumber(SpringUnsynced.GetConfigInt("snd_volmaster", 1) or 80), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("snd_volmaster", value) + SpringUnsynced.SetConfigInt("snd_volmaster", value) end, }, { @@ -3520,10 +3520,10 @@ function init() min = 0, max = 100, step = 2, - value = tonumber(Spring.GetConfigInt("snd_volgeneral", 1) or 100), + value = tonumber(SpringUnsynced.GetConfigInt("snd_volgeneral", 1) or 100), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("snd_volgeneral", value) + SpringUnsynced.SetConfigInt("snd_volgeneral", value) end, }, { @@ -3535,10 +3535,10 @@ function init() min = 0, max = 100, step = 2, - value = tonumber(Spring.GetConfigInt("snd_volbattle_options", 100) or 100), + value = tonumber(SpringUnsynced.GetConfigInt("snd_volbattle_options", 100) or 100), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("snd_volbattle_options", value) + SpringUnsynced.SetConfigInt("snd_volbattle_options", value) end, }, { @@ -3550,10 +3550,10 @@ function init() min = 0, max = 100, step = 2, - value = tonumber(Spring.GetConfigInt("snd_volui", 1) or 100), + value = tonumber(SpringUnsynced.GetConfigInt("snd_volui", 1) or 100), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("snd_volui", value) + SpringUnsynced.SetConfigInt("snd_volui", value) end, }, --{ id = "sndambient", group = "sound", category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N('ui.settings.option.sndvolambient'), type = "slider", min = 0, max = 100, step = 2, value = tonumber(Spring.GetConfigInt("snd_volambient", 1) or 100), @@ -3615,13 +3615,13 @@ function init() min = 0, max = 99, step = 1, - value = tonumber(Spring.GetConfigInt("snd_volmusic", 50) or 50), + value = tonumber(SpringUnsynced.GetConfigInt("snd_volmusic", 50) or 50), onload = function(i) end, onchange = function(i, value) if WG["music"] and WG["music"].SetMusicVolume then WG["music"].SetMusicVolume(value) else - Spring.SetConfigInt("snd_volmusic", value) + SpringUnsynced.SetConfigInt("snd_volmusic", value) end end, }, @@ -3632,10 +3632,10 @@ function init() category = types.advanced, name = Spring.I18N("ui.settings.option.sndunitsound"), type = "bool", - value = (Spring.GetConfigInt("snd_unitsound", 1) == 1), + value = (SpringUnsynced.GetConfigInt("snd_unitsound", 1) == 1), description = Spring.I18N("ui.settings.option.sndunitsound_desc"), onchange = function(i, value) - Spring.SetConfigInt("snd_unitsound", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("snd_unitsound", (value and 1 or 0)) end, }, @@ -3648,11 +3648,11 @@ function init() min = 0, max = 0.4, step = 0.01, - value = tonumber(Spring.GetConfigFloat("snd_airAbsorption", 0.35) or 0.35), + value = tonumber(SpringUnsynced.GetConfigFloat("snd_airAbsorption", 0.35) or 0.35), description = Spring.I18N("ui.settings.option.sndairabsorption_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigFloat("snd_airAbsorption", value) + SpringUnsynced.SetConfigFloat("snd_airAbsorption", value) end, }, @@ -3665,11 +3665,11 @@ function init() min = 0, max = 3, step = 0.01, - value = tonumber(Spring.GetConfigFloat("snd_zoomVolume", 1.00) or 1.00), + value = tonumber(SpringUnsynced.GetConfigFloat("snd_zoomVolume", 1.00) or 1.00), description = Spring.I18N("ui.settings.option.sndzoomvolume_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigFloat("snd_zoomVolume", value) + SpringUnsynced.SetConfigFloat("snd_zoomVolume", value) end, }, @@ -3679,10 +3679,10 @@ function init() category = types.advanced, name = Spring.I18N("ui.settings.option.muteoffscreen"), type = "bool", - value = (Spring.GetConfigInt("muteOffscreen", 0) == 1), + value = (SpringUnsynced.GetConfigInt("muteOffscreen", 0) == 1), description = Spring.I18N("ui.settings.option.muteoffscreen_descr"), onchange = function(i, value) - Spring.SetConfigInt("muteOffscreen", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("muteOffscreen", (value and 1 or 0)) end, }, @@ -3695,10 +3695,10 @@ function init() category = types.basic, name = Spring.I18N("ui.settings.option.soundtracknew"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackNew", 1) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackNew", 1) == 1, description = Spring.I18N("ui.settings.option.soundtracknew_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackNew", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackNew", value and 1 or 0) if WG["music"] and WG["music"].RefreshTrackList then WG["music"].RefreshTrackList() init() @@ -3711,10 +3711,10 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.soundtrackraptors"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackRaptors", 0) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackRaptors", 0) == 1, description = Spring.I18N("ui.settings.option.soundtrackraptors_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackRaptors", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackRaptors", value and 1 or 0) if WG["music"] and WG["music"].RefreshTrackList then WG["music"].RefreshTrackList() init() @@ -3727,10 +3727,10 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.soundtrackscavengers"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackScavengers", 0) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackScavengers", 0) == 1, description = Spring.I18N("ui.settings.option.soundtrackscavengers_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackScavengers", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackScavengers", value and 1 or 0) if WG["music"] and WG["music"].RefreshTrackList then WG["music"].RefreshTrackList() init() @@ -3743,10 +3743,10 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.soundtrackaprilfools"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackAprilFools", 1) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackAprilFools", 1) == 1, description = Spring.I18N("ui.settings.option.soundtrackaprilfools_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackAprilFools", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackAprilFools", value and 1 or 0) if WG["music"] and WG["music"].RefreshTrackList then WG["music"].RefreshTrackList() init() @@ -3759,10 +3759,10 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.soundtrackaprilfoolspostevent"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackAprilFoolsPostEvent", 0) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackAprilFoolsPostEvent", 0) == 1, description = Spring.I18N("ui.settings.option.soundtrackaprilfoolspostevent_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackAprilFoolsPostEvent", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackAprilFoolsPostEvent", value and 1 or 0) if WG["music"] and WG["music"].RefreshTrackList then WG["music"].RefreshTrackList() init() @@ -3775,10 +3775,10 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.soundtrackhalloween"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackHalloween", 1) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackHalloween", 1) == 1, description = Spring.I18N("ui.settings.option.soundtrackhalloween_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackHalloween", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackHalloween", value and 1 or 0) if WG["music"] and WG["music"].RefreshTrackList then WG["music"].RefreshTrackList() init() @@ -3791,10 +3791,10 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.soundtrackhalloweenpostevent"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackHalloweenPostEvent", 0) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackHalloweenPostEvent", 0) == 1, description = Spring.I18N("ui.settings.option.soundtrackhalloweenpostevent_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackHalloweenPostEvent", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackHalloweenPostEvent", value and 1 or 0) if WG["music"] and WG["music"].RefreshTrackList then WG["music"].RefreshTrackList() init() @@ -3807,10 +3807,10 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.soundtrackxmas"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackXmas", 1) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackXmas", 1) == 1, description = Spring.I18N("ui.settings.option.soundtrackxmas_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackXmas", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackXmas", value and 1 or 0) if WG["music"] and WG["music"].RefreshTrackList then WG["music"].RefreshTrackList() init() @@ -3823,10 +3823,10 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.soundtrackxmaspostevent"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackXmasPostEvent", 0) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackXmasPostEvent", 0) == 1, description = Spring.I18N("ui.settings.option.soundtrackxmaspostevent_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackXmasPostEvent", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackXmasPostEvent", value and 1 or 0) if WG["music"] and WG["music"].RefreshTrackList then WG["music"].RefreshTrackList() init() @@ -3839,10 +3839,10 @@ function init() category = types.advanced, name = Spring.I18N("ui.settings.option.soundtrackcustom"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackCustom", 1) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackCustom", 1) == 1, description = Spring.I18N("ui.settings.option.soundtrackcustom_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackCustom", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackCustom", value and 1 or 0) if WG["music"] and WG["music"].RefreshTrackList then WG["music"].RefreshTrackList() init() @@ -3855,10 +3855,10 @@ function init() category = types.basic, name = Spring.I18N("ui.settings.option.soundtrackinterruption"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackInterruption", 1) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackInterruption", 1) == 1, description = Spring.I18N("ui.settings.option.soundtrackinterruption_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackInterruption", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackInterruption", value and 1 or 0) if WG["music"] and WG["music"].RefreshSettings then WG["music"].RefreshSettings() end @@ -3870,10 +3870,10 @@ function init() category = types.basic, name = Spring.I18N("ui.settings.option.soundtrackfades"), type = "bool", - value = Spring.GetConfigInt("UseSoundtrackFades", 1) == 1, + value = SpringUnsynced.GetConfigInt("UseSoundtrackFades", 1) == 1, description = Spring.I18N("ui.settings.option.soundtrackfades_descr"), onchange = function(i, value) - Spring.SetConfigInt("UseSoundtrackFades", value and 1 or 0) + SpringUnsynced.SetConfigInt("UseSoundtrackFades", value and 1 or 0) if WG["music"] and WG["music"].RefreshSettings then WG["music"].RefreshSettings() end @@ -3896,7 +3896,7 @@ function init() value = 1, onload = function(i) end, onchange = function(i, value) - Spring.SetConfigString("voiceset", options[i].options[options[i].value]) + SpringUnsynced.SetConfigString("voiceset", options[i].options[options[i].value]) if widgetHandler.orderList["Notifications"] ~= nil then widgetHandler:DisableWidget("Notifications") widgetHandler:EnableWidget("Notifications") @@ -3967,10 +3967,10 @@ function init() category = types.advanced, name = Spring.I18N("ui.settings.option.notifications_substitute"), type = "bool", - value = Spring.GetConfigInt("NotificationsSubstitute", 0) == 1, + value = SpringUnsynced.GetConfigInt("NotificationsSubstitute", 0) == 1, description = Spring.I18N("ui.settings.option.notifications_substitute_descr"), onchange = function(i, value) - Spring.SetConfigInt("NotificationsSubstitute", value and 1 or 0) + SpringUnsynced.SetConfigInt("NotificationsSubstitute", value and 1 or 0) widgetHandler:DisableWidget("Notifications") widgetHandler:EnableWidget("Notifications") init() @@ -4008,11 +4008,11 @@ function init() value = 1, description = Spring.I18N("ui.settings.option.keylayout_descr"), onload = function() - local keyLayout = Spring.GetConfigString("KeyboardLayout") + local keyLayout = SpringUnsynced.GetConfigString("KeyboardLayout") if not keyLayout or keyLayout == "" then keyLayout = keyLayouts.layouts[1] - Spring.SetConfigString("KeyboardLayout", keyLayouts.layouts[1]) + SpringUnsynced.SetConfigString("KeyboardLayout", keyLayouts.layouts[1]) end local value = 1 @@ -4026,7 +4026,7 @@ function init() options[getOptionByID("keylayout")].value = value end, onchange = function(_, value) - Spring.SetConfigString("KeyboardLayout", keyLayouts.layouts[value]) + SpringUnsynced.SetConfigString("KeyboardLayout", keyLayouts.layouts[value]) if WG["bar_hotkeys"] and WG["bar_hotkeys"].reloadBindings then WG["bar_hotkeys"].reloadBindings() end @@ -4043,7 +4043,7 @@ function init() value = 1, description = Spring.I18N("ui.settings.option.keybindings_descr"), onload = function() - local keyFile = Spring.GetConfigString("KeybindingFile") + local keyFile = SpringUnsynced.GetConfigString("KeybindingFile") local value = 1 if (not keyFile) or (keyFile == "") or (not VFS.FileExists(keyFile)) then @@ -4069,17 +4069,17 @@ function init() local isCustom = keyLayouts.keybindingPresets["Custom"] == keyFile if isCustom and not VFS.FileExists(keyFile) then - Spring.SendCommands("keysave " .. keyFile) - Spring.Echo("Preset Custom selected, file saved at: " .. keyFile) + SpringUnsynced.SendCommands("keysave " .. keyFile) + SpringShared.Echo("Preset Custom selected, file saved at: " .. keyFile) end - Spring.SetConfigString("KeybindingFile", keyFile) + SpringUnsynced.SetConfigString("KeybindingFile", keyFile) if isCustom then - Spring.Echo("To test your custom bindings after changes type in chat: /keyreload") + SpringShared.Echo("To test your custom bindings after changes type in chat: /keyreload") end -- enable grid menu for grid keybinds local preset = options[getOptionByID("keybindings")].options[value] - Spring.Echo(preset) + SpringShared.Echo(preset) if string.find(string.lower(preset), "grid", nil, true) then widgetHandler:DisableWidget("Build menu") widgetHandler:EnableWidget("Grid menu") @@ -4198,12 +4198,12 @@ function init() category = types.basic, name = Spring.I18N("ui.settings.option.hwcursor"), type = "bool", - value = tonumber(Spring.GetConfigInt("HardwareCursor", 0) or 0) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("HardwareCursor", 0) or 0) == 1, description = Spring.I18N("ui.settings.option.hwcursor_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SendCommands("HardwareCursor " .. (value and 1 or 0)) - Spring.SetConfigInt("HardwareCursor", (value and 1 or 0)) + SpringUnsynced.SendCommands("HardwareCursor " .. (value and 1 or 0)) + SpringUnsynced.SetConfigInt("HardwareCursor", (value and 1 or 0)) end, }, { @@ -4246,11 +4246,11 @@ function init() category = types.basic, name = Spring.I18N("ui.settings.option.containmouse"), type = "bool", - value = Spring.GetConfigInt("grabinput", 1) == 1, + value = SpringUnsynced.GetConfigInt("grabinput", 1) == 1, description = Spring.I18N("ui.settings.option.containmouse_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("grabinput", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("grabinput", (value and 1 or 0)) updateGrabinput() end, }, @@ -4265,11 +4265,11 @@ function init() min = 150, max = 400, step = 10, - value = Spring.GetConfigInt("DoubleClickTime", 200), + value = SpringUnsynced.GetConfigInt("DoubleClickTime", 200), description = Spring.I18N("ui.settings.option.doubleclicktime_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("DoubleClickTime", value) + SpringUnsynced.SetConfigInt("DoubleClickTime", value) end, }, @@ -4283,14 +4283,14 @@ function init() min = 4, max = 50, step = 1, - value = Spring.GetConfigInt("MouseDragSelectionThreshold", 4), + value = SpringUnsynced.GetConfigInt("MouseDragSelectionThreshold", 4), description = Spring.I18N("ui.settings.option.dragthreshold_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("MouseDragSelectionThreshold", value) - Spring.SetConfigInt("MouseDragCircleCommandThreshold", value) - Spring.SetConfigInt("MouseDragBoxCommandThreshold", value + 12) - Spring.SetConfigInt("MouseDragFrontCommandThreshold", value + 26) + SpringUnsynced.SetConfigInt("MouseDragSelectionThreshold", value) + SpringUnsynced.SetConfigInt("MouseDragCircleCommandThreshold", value) + SpringUnsynced.SetConfigInt("MouseDragBoxCommandThreshold", value + 12) + SpringUnsynced.SetConfigInt("MouseDragFrontCommandThreshold", value + 26) end, }, @@ -4303,11 +4303,11 @@ function init() category = types.basic, name = Spring.I18N("ui.settings.option.middleclicktoggle"), type = "bool", - value = (Spring.GetConfigFloat("MouseDragScrollThreshold", 0.3) ~= 0), + value = (SpringUnsynced.GetConfigFloat("MouseDragScrollThreshold", 0.3) ~= 0), description = Spring.I18N("ui.settings.option.middleclicktoggle_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigFloat("MouseDragScrollThreshold", (value and 0.3 or 0)) + SpringUnsynced.SetConfigFloat("MouseDragScrollThreshold", (value and 0.3 or 0)) end, }, @@ -4318,15 +4318,15 @@ function init() name = Spring.I18N("ui.settings.option.screenedgemove"), type = "bool", restart = true, - value = tonumber(Spring.GetConfigInt("FullscreenEdgeMove", 1) or 1) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("FullscreenEdgeMove", 1) or 1) == 1, description = Spring.I18N("ui.settings.option.screenedgemove_descr"), onchange = function(i, value) - Spring.SetConfigInt("FullscreenEdgeMove", (value and 1 or 0)) - Spring.SetConfigInt("WindowedEdgeMove", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("FullscreenEdgeMove", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("WindowedEdgeMove", (value and 1 or 0)) if value then - Spring.SetConfigFloat("EdgeMoveWidth", edgeMoveWidth) + SpringUnsynced.SetConfigFloat("EdgeMoveWidth", edgeMoveWidth) else - Spring.SetConfigFloat("EdgeMoveWidth", 0) + SpringUnsynced.SetConfigFloat("EdgeMoveWidth", 0) end end, }, @@ -4343,7 +4343,7 @@ function init() description = Spring.I18N("ui.settings.option.screenedgemovewidth_descr"), onchange = function(i, value) edgeMoveWidth = value - Spring.SetConfigFloat("EdgeMoveWidth", value) + SpringUnsynced.SetConfigFloat("EdgeMoveWidth", value) end, }, { @@ -4353,10 +4353,10 @@ function init() name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.screenedgemovedynamic"), type = "bool", restart = true, - value = tonumber(Spring.GetConfigInt("EdgeMoveDynamic", 1) or 1) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("EdgeMoveDynamic", 1) or 1) == 1, description = Spring.I18N("ui.settings.option.screenedgemovedynamic_descr"), onchange = function(i, value) - Spring.SetConfigInt("EdgeMoveDynamic", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("EdgeMoveDynamic", (value and 1 or 0)) end, }, @@ -4367,19 +4367,19 @@ function init() name = Spring.I18N("ui.settings.option.camera"), type = "select", options = { Spring.I18N("ui.settings.option.select_firstperson"), Spring.I18N("ui.settings.option.select_overhead"), Spring.I18N("ui.settings.option.select_springcam"), Spring.I18N("ui.settings.option.select_rotoverhead"), Spring.I18N("ui.settings.option.select_free") }, - value = (tonumber((Spring.GetConfigInt("CamMode", 1) + 1) or 2)), + value = (tonumber((SpringUnsynced.GetConfigInt("CamMode", 1) + 1) or 2)), onchange = function(i, value) - Spring.SetConfigInt("CamMode", (value - 1)) + SpringUnsynced.SetConfigInt("CamMode", (value - 1)) if value == 1 then - Spring.SendCommands("viewfps") + SpringUnsynced.SendCommands("viewfps") elseif value == 2 then - Spring.SendCommands("viewta") + SpringUnsynced.SendCommands("viewta") elseif value == 3 then - Spring.SendCommands("viewspring") + SpringUnsynced.SendCommands("viewspring") elseif value == 4 then - Spring.SendCommands("viewrot") + SpringUnsynced.SendCommands("viewrot") elseif value == 5 then - Spring.SendCommands("viewfree") + SpringUnsynced.SendCommands("viewfree") end init() end, @@ -4391,10 +4391,10 @@ function init() name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.springcamheightmode"), type = "select", options = { Spring.I18N("ui.settings.option.select_constant"), Spring.I18N("ui.settings.option.select_terrain"), Spring.I18N("ui.settings.option.select_smooth") }, - value = Spring.GetConfigInt("CamSpringTrackMapHeightMode", 0) + 1, + value = SpringUnsynced.GetConfigInt("CamSpringTrackMapHeightMode", 0) + 1, description = Spring.I18N("ui.settings.option.springcamheightmode_descr"), onchange = function(i, value) - Spring.SetConfigInt("CamSpringTrackMapHeightMode", value - 1) + SpringUnsynced.SetConfigInt("CamSpringTrackMapHeightMode", value - 1) end, }, { @@ -4406,11 +4406,11 @@ function init() min = 0, max = 1500, step = 1, - value = Spring.GetConfigInt("CamSpringMinZoomDistance", 0), + value = SpringUnsynced.GetConfigInt("CamSpringMinZoomDistance", 0), description = Spring.I18N("ui.settings.option.mincamheight_descr"), onchange = function(i, value) - Spring.SetConfigInt("CamSpringMinZoomDistance", value) - Spring.SetConfigInt("OverheadMinZoomDistance", value) + SpringUnsynced.SetConfigInt("CamSpringMinZoomDistance", value) + SpringUnsynced.SetConfigInt("OverheadMinZoomDistance", value) end, }, { @@ -4458,9 +4458,9 @@ function init() name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.smoothingmode"), type = "select", options = { Spring.I18N("ui.settings.option.smoothing_exponential"), Spring.I18N("ui.settings.option.smoothing_spring") }, - value = (Spring.GetConfigInt("CamTransitionMode", 1) + 1), + value = (SpringUnsynced.GetConfigInt("CamTransitionMode", 1) + 1), onchange = function(i, value) - Spring.SetConfigInt("CamTransitionMode", (value - 1)) + SpringUnsynced.SetConfigInt("CamTransitionMode", (value - 1)) end, }, { @@ -4483,7 +4483,7 @@ function init() else halfLife = halfLife * 600 - 400 end - Spring.SetConfigFloat("CamSpringHalflife", halfLife) + SpringUnsynced.SetConfigFloat("CamSpringHalflife", halfLife) end, }, { @@ -4495,11 +4495,11 @@ function init() min = -0.01, max = -0.00195, step = 0.0001, - value = Spring.GetConfigFloat("MiddleClickScrollSpeed", 0.0035), + value = SpringUnsynced.GetConfigFloat("MiddleClickScrollSpeed", 0.0035), description = Spring.I18N("ui.settings.option.camerapanspeed_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigFloat("MiddleClickScrollSpeed", value) + SpringUnsynced.SetConfigFloat("MiddleClickScrollSpeed", value) end, }, { @@ -4511,16 +4511,16 @@ function init() min = 0, max = 100, step = 1, - value = Spring.GetConfigInt("CamSpringScrollSpeed", 10), + value = SpringUnsynced.GetConfigInt("CamSpringScrollSpeed", 10), description = Spring.I18N("ui.settings.option.cameramovespeed_descr"), onload = function(i) end, onchange = function(i, value) --cameraPanTransitionTime = value - Spring.SetConfigInt("FPSScrollSpeed", value) -- spring default: 10 - Spring.SetConfigInt("OverheadScrollSpeed", value) -- spring default: 10 - Spring.SetConfigInt("RotOverheadScrollSpeed", value) -- spring default: 10 - Spring.SetConfigFloat("CamFreeScrollSpeed", value * 50) -- spring default: 500 - Spring.SetConfigInt("CamSpringScrollSpeed", value) -- spring default: 10 + SpringUnsynced.SetConfigInt("FPSScrollSpeed", value) -- spring default: 10 + SpringUnsynced.SetConfigInt("OverheadScrollSpeed", value) -- spring default: 10 + SpringUnsynced.SetConfigInt("RotOverheadScrollSpeed", value) -- spring default: 10 + SpringUnsynced.SetConfigFloat("CamFreeScrollSpeed", value * 50) -- spring default: 500 + SpringUnsynced.SetConfigInt("CamSpringScrollSpeed", value) -- spring default: 10 end, }, { @@ -4532,14 +4532,14 @@ function init() min = 1, max = 50, step = 1, - value = math.abs(tonumber(Spring.GetConfigInt("ScrollWheelSpeed", 1) or 25)), + value = math.abs(tonumber(SpringUnsynced.GetConfigInt("ScrollWheelSpeed", 1) or 25)), description = "", onload = function(i) end, onchange = function(i, value) if getOptionByID("scrollinverse") and options[getOptionByID("scrollinverse")].value then - Spring.SetConfigInt("ScrollWheelSpeed", -value) + SpringUnsynced.SetConfigInt("ScrollWheelSpeed", -value) else - Spring.SetConfigInt("ScrollWheelSpeed", value) + SpringUnsynced.SetConfigInt("ScrollWheelSpeed", value) end end, }, @@ -4549,15 +4549,15 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.scrollinverse"), type = "bool", - value = (tonumber(Spring.GetConfigInt("ScrollWheelSpeed", 1) or 25) < 0), + value = (tonumber(SpringUnsynced.GetConfigInt("ScrollWheelSpeed", 1) or 25) < 0), description = "", onload = function(i) end, onchange = function(i, value) if getOptionByID("scrollspeed") then if value then - Spring.SetConfigInt("ScrollWheelSpeed", -options[getOptionByID("scrollspeed")].value) + SpringUnsynced.SetConfigInt("ScrollWheelSpeed", -options[getOptionByID("scrollspeed")].value) else - Spring.SetConfigInt("ScrollWheelSpeed", options[getOptionByID("scrollspeed")].value) + SpringUnsynced.SetConfigInt("ScrollWheelSpeed", options[getOptionByID("scrollspeed")].value) end end end, @@ -4568,11 +4568,11 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.invertmouse"), type = "bool", - value = tonumber(Spring.GetConfigInt("InvertMouse", 0)) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("InvertMouse", 0)) == 1, description = "", onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("InvertMouse", value and 1 or 0) + SpringUnsynced.SetConfigInt("InvertMouse", value and 1 or 0) end, }, { id = "scrolltoggleoverview", group = "control", category = types.advanced, widget = "Scrolldown Toggleoverview", name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.scrolltoggleoverview"), type = "bool", value = GetWidgetToggleValue("Scrolldown Toggleoverview"), description = Spring.I18N("ui.settings.option.scrolltoggleoverview_descr") }, @@ -4687,7 +4687,7 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.language_english_unit_names"), type = "bool", - value = Spring.GetConfigInt("language_english_unit_names", 0) == 1, + value = SpringUnsynced.GetConfigInt("language_english_unit_names", 0) == 1, onchange = function(i, value) WG["language"].setEnglishUnitNames(value) end, @@ -4701,13 +4701,13 @@ function init() min = 0.8, max = 1.3, step = 0.01, - value = Spring.GetConfigFloat("ui_scale", 1), + value = SpringUnsynced.GetConfigFloat("ui_scale", 1), description = "", onload = function(i) end, onchange = function(i, value, force) if force then - Spring.SetConfigFloat("ui_scale", value) - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigFloat("ui_scale", value) + SpringUnsynced.SendCommands("luarules reloadluaui") else sceduleOptionApply = { os.clock() + 1.5, getOptionByID("uiscale") } end @@ -4722,17 +4722,17 @@ function init() min = 0.3, max = 1, step = 0.01, - value = Spring.GetConfigFloat("ui_opacity", 0.7), + value = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7), description = "", onload = function(i) end, onchange = function(i, value, force) - Spring.SetConfigFloat("ui_opacity", value) - ui_opacity = Spring.GetConfigFloat("ui_opacity", 0.7) + SpringUnsynced.SetConfigFloat("ui_opacity", value) + ui_opacity = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7) forceUpdate = true if force then - Spring.SetConfigFloat("ui_opacity", value) - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigFloat("ui_opacity", value) + SpringUnsynced.SendCommands("luarules reloadluaui") else sceduleOptionApply = { os.clock() + 1.5, getOptionByID("guiopacity") } end @@ -4747,13 +4747,13 @@ function init() min = 4, max = 40, step = 1, - value = Spring.GetConfigFloat("ui_tilescale", 7), + value = SpringUnsynced.GetConfigFloat("ui_tilescale", 7), description = "", onload = function(i) end, onchange = function(i, value, force) if force then - Spring.SetConfigFloat("ui_tilescale", value) - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigFloat("ui_tilescale", value) + SpringUnsynced.SendCommands("luarules reloadluaui") else sceduleOptionApply = { os.clock() + 1.5, getOptionByID("guitilescale") } end @@ -4768,13 +4768,13 @@ function init() min = 0, max = 0.03, step = 0.001, - value = Spring.GetConfigFloat("ui_tileopacity", 0.014), + value = SpringUnsynced.GetConfigFloat("ui_tileopacity", 0.014), description = "", onload = function(i) end, onchange = function(i, value, force) if force then - Spring.SetConfigFloat("ui_tileopacity", value) - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigFloat("ui_tileopacity", value) + SpringUnsynced.SendCommands("luarules reloadluaui") else sceduleOptionApply = { os.clock() + 1.5, getOptionByID("guitileopacity") } end @@ -4792,10 +4792,10 @@ function init() min = 0.2, max = 0.4, step = 0.01, - value = Spring.GetConfigFloat("MinimapMaxHeight", 0.32), + value = SpringUnsynced.GetConfigFloat("MinimapMaxHeight", 0.32), description = Spring.I18N("ui.settings.option.minimap_maxheight_descr"), onchange = function(i, value) - Spring.SetConfigFloat("MinimapMaxHeight", value) + SpringUnsynced.SetConfigFloat("MinimapMaxHeight", value) end, }, { @@ -4804,10 +4804,10 @@ function init() category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.minimapleftclick"), type = "bool", - value = Spring.GetConfigInt("MinimapLeftClickMove", 1) == 1, + value = SpringUnsynced.GetConfigInt("MinimapLeftClickMove", 1) == 1, description = Spring.I18N("ui.settings.option.minimapleftclick_descr"), onchange = function(i, value) - Spring.SetConfigInt("MinimapLeftClickMove", value and 1 or 0) + SpringUnsynced.SetConfigInt("MinimapLeftClickMove", value and 1 or 0) if WG["minimap"] and WG["minimap"].setLeftClickMove then WG["minimap"].setLeftClickMove(value) end @@ -4822,12 +4822,12 @@ function init() min = 2, max = 5, step = 0.25, - value = tonumber(Spring.GetConfigFloat("MinimapIconScale", 3.5) or 1), + value = tonumber(SpringUnsynced.GetConfigFloat("MinimapIconScale", 3.5) or 1), description = "", onload = function(i) end, onchange = function(i, value) - Spring.SetConfigFloat("MinimapIconScale", value) - Spring.SendCommands("minimap unitsize " .. value) -- spring wont remember what you set with '/minimap iconssize #' + SpringUnsynced.SetConfigFloat("MinimapIconScale", value) + SpringUnsynced.SendCommands("minimap unitsize " .. value) -- spring wont remember what you set with '/minimap iconssize #' if WG["minimap"] and WG["minimap"].setBaseIconScale then WG["minimap"].setBaseIconScale(value) end @@ -4839,11 +4839,11 @@ function init() category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.minimapminimized"), type = "bool", - value = Spring.GetConfigInt("MinimapMinimize", 0) == 1, + value = SpringUnsynced.GetConfigInt("MinimapMinimize", 0) == 1, description = Spring.I18N("ui.settings.option.minimapminimized_descr"), onchange = function(i, value) - Spring.SendCommands("minimap minimize " .. (value and "1" or "0")) - Spring.SetConfigInt("MinimapMinimize", (value and "1" or "0")) + SpringUnsynced.SendCommands("minimap minimize " .. (value and "1" or "0")) + SpringUnsynced.SetConfigInt("MinimapMinimize", (value and "1" or "0")) end, }, { @@ -4857,7 +4857,7 @@ function init() onload = function(i) loadWidgetData("Minimap Rotation Manager", "minimaprotation", { "mode" }) if options[i].value == nil then -- first load to migrate from old behavior smoothly, might wanna remove it later - options[i].value = Spring.GetConfigInt("MiniMapCanFlip", 0) + 1 + options[i].value = SpringUnsynced.GetConfigInt("MiniMapCanFlip", 0) + 1 end end, onchange = function(i, value) @@ -4875,10 +4875,10 @@ function init() category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.pip_altkeyzoom"), type = "bool", - value = Spring.GetConfigInt("PipAltKeyRequiredForZoom", 1) == 1, + value = SpringUnsynced.GetConfigInt("PipAltKeyRequiredForZoom", 1) == 1, description = Spring.I18N("ui.settings.option.pip_altkeyzoom_descr"), onchange = function(i, value) - Spring.SetConfigInt("PipAltKeyRequiredForZoom", value and 1 or 0) + SpringUnsynced.SetConfigInt("PipAltKeyRequiredForZoom", value and 1 or 0) for _, n in ipairs({ 0, 1, 2, 3, 4 }) do if WG["pip" .. n] and WG["pip" .. n].setAltKeyRequiredForZoom then WG["pip" .. n].setAltKeyRequiredForZoom(value) @@ -4893,10 +4893,10 @@ function init() category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.pip_commandfx"), type = "bool", - value = Spring.GetConfigInt("PipDrawCommandFX", 1) == 1, + value = SpringUnsynced.GetConfigInt("PipDrawCommandFX", 1) == 1, description = Spring.I18N("ui.settings.option.pip_commandfx_descr"), onchange = function(i, value) - Spring.SetConfigInt("PipDrawCommandFX", value and 1 or 0) + SpringUnsynced.SetConfigInt("PipDrawCommandFX", value and 1 or 0) for _, n in ipairs({ 0, 1, 2, 3, 4 }) do if WG["pip" .. n] and WG["pip" .. n].setDrawCommandFX then WG["pip" .. n].setDrawCommandFX(value) @@ -5413,11 +5413,11 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.console_hidespecchat"), type = "bool", - value = (Spring.GetConfigInt("HideSpecChat", 0) == 1), + value = (SpringUnsynced.GetConfigInt("HideSpecChat", 0) == 1), description = Spring.I18N("ui.settings.option.console_hidespecchat_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("HideSpecChat", value and 1 or 0) + SpringUnsynced.SetConfigInt("HideSpecChat", value and 1 or 0) end, }, { @@ -5426,11 +5426,11 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. widgetOptionColor .. Spring.I18N("ui.settings.option.console_hidespecchatplayer"), type = "bool", - value = (Spring.GetConfigInt("HideSpecChatPlayer", 1) == 1), + value = (SpringUnsynced.GetConfigInt("HideSpecChatPlayer", 1) == 1), description = Spring.I18N("ui.settings.option.console_hidespecchatplayer_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("HideSpecChatPlayer", value and 1 or 0) + SpringUnsynced.SetConfigInt("HideSpecChatPlayer", value and 1 or 0) end, }, { @@ -5541,12 +5541,12 @@ function init() category = types.dev, name = Spring.I18N("ui.settings.option.continuouslyclearmapmarks"), type = "bool", - value = Spring.GetConfigInt("ContinuouslyClearMapmarks", 0) == 1, + value = SpringUnsynced.GetConfigInt("ContinuouslyClearMapmarks", 0) == 1, description = Spring.I18N("ui.settings.option.continuouslyclearmapmarks_descr"), onchange = function(i, value) - Spring.SetConfigInt("ContinuouslyClearMapmarks", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("ContinuouslyClearMapmarks", (value and 1 or 0)) if value then - Spring.SendCommands({ "clearmapmarks" }) + SpringUnsynced.SendCommands({ "clearmapmarks" }) end end, }, @@ -5563,10 +5563,10 @@ function init() category = types.advanced, name = Spring.I18N("ui.settings.option.widgetselector"), type = "bool", - value = Spring.GetConfigInt("widgetselector", 0) == 1, + value = SpringUnsynced.GetConfigInt("widgetselector", 0) == 1, description = Spring.I18N("ui.settings.option.widgetselector_descr"), onchange = function(i, value) - Spring.SetConfigInt("widgetselector", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("widgetselector", (value and 1 or 0)) end, }, @@ -5582,11 +5582,11 @@ function init() min = 0.85, max = 3, step = 0.05, - value = tonumber(Spring.GetConfigFloat("UnitIconScaleUI", 1) or 1), + value = tonumber(SpringUnsynced.GetConfigFloat("UnitIconScaleUI", 1) or 1), description = Spring.I18N("ui.settings.option.uniticonscaleui_descr"), onchange = function(i, value) - Spring.SendCommands("iconscaleui " .. value) - Spring.SetConfigFloat("UnitIconScaleUI", value) + SpringUnsynced.SendCommands("iconscaleui " .. value) + SpringUnsynced.SetConfigFloat("UnitIconScaleUI", value) end, }, { @@ -5598,14 +5598,14 @@ function init() min = 1, max = 12000, step = 50, - value = tonumber(Spring.GetConfigInt("UnitIconFadeVanish", 2700) or 1), + value = tonumber(SpringUnsynced.GetConfigInt("UnitIconFadeVanish", 2700) or 1), description = Spring.I18N("ui.settings.option.uniticondistance_descr"), onchange = function(i, value) - Spring.SendCommands("iconfadestart " .. value) - Spring.SetConfigInt("UnitIconFadeStart", value) + SpringUnsynced.SendCommands("iconfadestart " .. value) + SpringUnsynced.SetConfigInt("UnitIconFadeStart", value) -- update UnitIconFadeVanish too - Spring.SendCommands("iconfadevanish " .. value) - Spring.SetConfigInt("UnitIconFadeVanish", value) + SpringUnsynced.SendCommands("iconfadevanish " .. value) + SpringUnsynced.SetConfigInt("UnitIconFadeVanish", value) end, }, { @@ -5614,11 +5614,11 @@ function init() category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.uniticonhidewithui"), type = "bool", - value = (Spring.GetConfigInt("UnitIconsHideWithUI", 0) == 1), + value = (SpringUnsynced.GetConfigInt("UnitIconsHideWithUI", 0) == 1), description = Spring.I18N("ui.settings.option.uniticonhidewithui_descr"), onchange = function(i, value) - Spring.SendCommands("iconshidewithui " .. (value and 1 or 0)) - Spring.SetConfigInt("UnitIconsHideWithUI", (value and 1 or 0)) + SpringUnsynced.SendCommands("iconshidewithui " .. (value and 1 or 0)) + SpringUnsynced.SetConfigInt("UnitIconsHideWithUI", (value and 1 or 0)) end, }, @@ -5783,10 +5783,10 @@ function init() max = 1.0, step = 0.15, type = "slider", - value = Spring.GetConfigFloat("UnitGhostIconsDimming", 0.8), + value = SpringUnsynced.GetConfigFloat("UnitGhostIconsDimming", 0.8), description = Spring.I18N("ui.settings.option.ghosticons_brightness_descr"), onchange = function(i, value) - Spring.SetConfigFloat("UnitGhostIconsDimming", value) + SpringUnsynced.SetConfigFloat("UnitGhostIconsDimming", value) end, }, @@ -6210,11 +6210,11 @@ function init() category = types.basic, name = Spring.I18N("ui.settings.option.displaydps"), type = "bool", - value = tonumber(Spring.GetConfigInt("DisplayDPS", 0) or 0) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("DisplayDPS", 0) or 0) == 1, description = Spring.I18N("ui.settings.option.displaydps_descr"), onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("DisplayDPS", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("DisplayDPS", (value and 1 or 0)) end, }, @@ -6827,8 +6827,8 @@ function init() description = Spring.I18N("ui.settings.option.devmode_descr"), onchange = function(i, value) devUI = value - Spring.SetConfigInt("DevUI", value and 1 or 0) - Spring.SendCommands("luaui reload") + SpringUnsynced.SetConfigInt("DevUI", value and 1 or 0) + SpringUnsynced.SendCommands("luaui reload") end, }, @@ -6848,19 +6848,19 @@ function init() onchange = function(i, value) useNetworkSmoothing = value if useNetworkSmoothing then - Spring.SetConfigInt("UseNetMessageSmoothingBuffer", 1) - Spring.SetConfigInt("NetworkLossFactor", 0) - Spring.SetConfigInt("LinkOutgoingBandwidth", 196608) - Spring.SetConfigInt("LinkIncomingSustainedBandwidth", 196608) - Spring.SetConfigInt("LinkIncomingPeakBandwidth", 196608) - Spring.SetConfigInt("LinkIncomingMaxPacketRate", 1024) + SpringUnsynced.SetConfigInt("UseNetMessageSmoothingBuffer", 1) + SpringUnsynced.SetConfigInt("NetworkLossFactor", 0) + SpringUnsynced.SetConfigInt("LinkOutgoingBandwidth", 196608) + SpringUnsynced.SetConfigInt("LinkIncomingSustainedBandwidth", 196608) + SpringUnsynced.SetConfigInt("LinkIncomingPeakBandwidth", 196608) + SpringUnsynced.SetConfigInt("LinkIncomingMaxPacketRate", 1024) else - Spring.SetConfigInt("UseNetMessageSmoothingBuffer", 0) - Spring.SetConfigInt("NetworkLossFactor", 2) - Spring.SetConfigInt("LinkOutgoingBandwidth", 196608) - Spring.SetConfigInt("LinkIncomingSustainedBandwidth", 1048576) - Spring.SetConfigInt("LinkIncomingPeakBandwidth", 1048576) - Spring.SetConfigInt("LinkIncomingMaxPacketRate", 2048) + SpringUnsynced.SetConfigInt("UseNetMessageSmoothingBuffer", 0) + SpringUnsynced.SetConfigInt("NetworkLossFactor", 2) + SpringUnsynced.SetConfigInt("LinkOutgoingBandwidth", 196608) + SpringUnsynced.SetConfigInt("LinkIncomingSustainedBandwidth", 1048576) + SpringUnsynced.SetConfigInt("LinkIncomingPeakBandwidth", 1048576) + SpringUnsynced.SetConfigInt("LinkIncomingMaxPacketRate", 2048) end end, }, @@ -6878,10 +6878,10 @@ function init() pauseGameWhenSingleplayer = value if (isSinglePlayer or isReplay) and show then if pauseGameWhenSingleplayer then - Spring.SendCommands("pause " .. (pauseGameWhenSingleplayer and "1" or "0")) + SpringUnsynced.SendCommands("pause " .. (pauseGameWhenSingleplayer and "1" or "0")) pauseGameWhenSingleplayerExecuted = pauseGameWhenSingleplayer elseif pauseGameWhenSingleplayerExecuted then - Spring.SendCommands("pause 0") + SpringUnsynced.SendCommands("pause 0") pauseGameWhenSingleplayerExecuted = false end end @@ -6898,10 +6898,10 @@ function init() min = 0.05, max = 0.3, step = 0.01, - value = Spring.GetConfigFloat("MinSimDrawBalance", 0.15), + value = SpringUnsynced.GetConfigFloat("MinSimDrawBalance", 0.15), description = Spring.I18N("ui.settings.option.catchupsmoothness_descr"), onchange = function(i, value) - Spring.SetConfigFloat("MinSimDrawBalance", value) + SpringUnsynced.SetConfigFloat("MinSimDrawBalance", value) end, }, { @@ -6914,10 +6914,10 @@ function init() min = 2, max = 15, step = 1, - value = Spring.GetConfigInt("MinDrawFPS", 2), + value = SpringUnsynced.GetConfigInt("MinDrawFPS", 2), description = Spring.I18N("ui.settings.option.catchupminfps_descr"), onchange = function(i, value) - Spring.SetConfigInt("MinDrawFPS", value) + SpringUnsynced.SetConfigInt("MinDrawFPS", value) end, }, @@ -7146,12 +7146,12 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("anonymousColorR", 255)), + value = tonumber(SpringUnsynced.GetConfigInt("anonymousColorR", 255)), description = Spring.I18N("ui.settings.option.anonymous_descr"), onchange = function(i, value, force) if force then - Spring.SetConfigInt("anonymousColorR", value) - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigInt("anonymousColorR", value) + SpringUnsynced.SendCommands("luarules reloadluaui") else sceduleOptionApply = { os.clock() + 1.5, getOptionByID("anonymous_r") } end @@ -7167,12 +7167,12 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("anonymousColorG", 0)), + value = tonumber(SpringUnsynced.GetConfigInt("anonymousColorG", 0)), description = Spring.I18N("ui.settings.option.anonymous_descr"), onchange = function(i, value, force) if force then - Spring.SetConfigInt("anonymousColorG", value) - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigInt("anonymousColorG", value) + SpringUnsynced.SendCommands("luarules reloadluaui") else sceduleOptionApply = { os.clock() + 1.5, getOptionByID("anonymous_g") } end @@ -7188,12 +7188,12 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("anonymousColorB", 0)), + value = tonumber(SpringUnsynced.GetConfigInt("anonymousColorB", 0)), description = Spring.I18N("ui.settings.option.anonymous_descr"), onchange = function(i, value, force) if force then - Spring.SetConfigInt("anonymousColorB", value) - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigInt("anonymousColorB", value) + SpringUnsynced.SendCommands("luarules reloadluaui") else sceduleOptionApply = { os.clock() + 1.5, getOptionByID("anonymous_b") } end @@ -7206,11 +7206,11 @@ function init() category = types.basic, name = Spring.I18N("ui.settings.option.playercolors"), type = "bool", - value = tonumber(Spring.GetConfigInt("SimpleTeamColors", 0) or 0) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColors", 0) or 0) == 1, description = Spring.I18N("ui.settings.option.simpleteamcolors_descr"), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColors", (value and 1 or 0)) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColors", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, @@ -7220,19 +7220,19 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.simpleteamcolors_reset"), type = "bool", - value = tonumber(Spring.GetConfigInt("SimpleTeamColors_Reset", 0) or 0) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColors_Reset", 0) or 0) == 1, onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsUseGradient", 0) - Spring.SetConfigInt("SimpleTeamColorsPlayerR", 0) - Spring.SetConfigInt("SimpleTeamColorsPlayerG", 77) - Spring.SetConfigInt("SimpleTeamColorsPlayerB", 255) - Spring.SetConfigInt("SimpleTeamColorsAllyR", 0) - Spring.SetConfigInt("SimpleTeamColorsAllyG", 255) - Spring.SetConfigInt("SimpleTeamColorsAllyB", 0) - Spring.SetConfigInt("SimpleTeamColorsEnemyR", 255) - Spring.SetConfigInt("SimpleTeamColorsEnemyG", 16) - Spring.SetConfigInt("SimpleTeamColorsEnemyB", 5) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsUseGradient", 0) + SpringUnsynced.SetConfigInt("SimpleTeamColorsPlayerR", 0) + SpringUnsynced.SetConfigInt("SimpleTeamColorsPlayerG", 77) + SpringUnsynced.SetConfigInt("SimpleTeamColorsPlayerB", 255) + SpringUnsynced.SetConfigInt("SimpleTeamColorsAllyR", 0) + SpringUnsynced.SetConfigInt("SimpleTeamColorsAllyG", 255) + SpringUnsynced.SetConfigInt("SimpleTeamColorsAllyB", 0) + SpringUnsynced.SetConfigInt("SimpleTeamColorsEnemyR", 255) + SpringUnsynced.SetConfigInt("SimpleTeamColorsEnemyG", 16) + SpringUnsynced.SetConfigInt("SimpleTeamColorsEnemyB", 5) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, { @@ -7241,10 +7241,10 @@ function init() category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.simpleteamcolors_use_gradient"), type = "bool", - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsUseGradient", 0) or 0) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsUseGradient", 0) or 0) == 1, onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsUseGradient", (value and 1 or 0)) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsUseGradient", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, { @@ -7253,11 +7253,11 @@ function init() category = types.dev, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.simpleteamcolorsfactionspecific"), type = "bool", - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsFactionSpecific", 0) or 0) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsFactionSpecific", 0) or 0) == 1, description = Spring.I18N("ui.settings.option.simpleteamcolorsfactionspecific_descr"), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsFactionSpecific", (value and 1 or 0)) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsFactionSpecific", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, { @@ -7269,10 +7269,10 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsPlayerR", 0)), + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsPlayerR", 0)), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsPlayerR", value) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsPlayerR", value) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, { @@ -7284,10 +7284,10 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsPlayerG", 77)), + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsPlayerG", 77)), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsPlayerG", value) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsPlayerG", value) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, { @@ -7299,10 +7299,10 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsPlayerB", 255)), + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsPlayerB", 255)), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsPlayerB", value) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsPlayerB", value) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, @@ -7315,10 +7315,10 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsAllyR", 0)), + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsAllyR", 0)), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsAllyR", value) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsAllyR", value) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, { @@ -7330,10 +7330,10 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsAllyG", 255)), + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsAllyG", 255)), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsAllyG", value) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsAllyG", value) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, { @@ -7345,10 +7345,10 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsAllyB", 0)), + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsAllyB", 0)), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsAllyB", value) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsAllyB", value) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, @@ -7361,10 +7361,10 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsEnemyR", 255)), + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsEnemyR", 255)), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsEnemyR", value) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsEnemyR", value) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, { @@ -7376,10 +7376,10 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsEnemyG", 16)), + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsEnemyG", 16)), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsEnemyG", value) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsEnemyG", value) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, { @@ -7391,10 +7391,10 @@ function init() min = 0, max = 255, step = 1, - value = tonumber(Spring.GetConfigInt("SimpleTeamColorsEnemyB", 5)), + value = tonumber(SpringUnsynced.GetConfigInt("SimpleTeamColorsEnemyB", 5)), onchange = function(i, value) - Spring.SetConfigInt("SimpleTeamColorsEnemyB", value) - Spring.SetConfigInt("UpdateTeamColors", 1) + SpringUnsynced.SetConfigInt("SimpleTeamColorsEnemyB", value) + SpringUnsynced.SetConfigInt("UpdateTeamColors", 1) end, }, @@ -7409,7 +7409,7 @@ function init() description = Spring.I18N("ui.settings.option.customwidgets_descr"), onchange = function(i, value) widgetHandler.__allowUserWidgets = value - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SendCommands("luarules reloadluaui") end, }, @@ -7424,7 +7424,7 @@ function init() description = Spring.I18N("ui.settings.option.restart_descr"), onchange = function(i, value) options[getOptionByID("restart")].value = false - Spring.Restart("", startScript) + SpringUnsynced.Restart("", startScript) end, }, @@ -7440,7 +7440,7 @@ function init() type = "bool", value = false, onchange = function(i, value) - Spring.SendCommands("luarules profile") + SpringUnsynced.SendCommands("luarules profile") end, }, { @@ -7449,10 +7449,10 @@ function init() category = types.dev, name = widgetOptionColor .. " " .. Spring.I18N("ui.settings.option.profiler_sort_by_load"), type = "bool", - value = Spring.GetConfigInt("profiler_sort_by_load", 1), + value = SpringUnsynced.GetConfigInt("profiler_sort_by_load", 1), description = Spring.I18N("ui.settings.option.profiler_sort_by_load_descr"), onchange = function(i, value) - Spring.SetConfigInt("profiler_sort_by_load", (value and "1" or "0")) + SpringUnsynced.SetConfigInt("profiler_sort_by_load", (value and "1" or "0")) end, }, { @@ -7464,10 +7464,10 @@ function init() min = 0.1, max = 10, step = 0.1, - value = Spring.GetConfigFloat("profiler_averagetime", 2), + value = SpringUnsynced.GetConfigFloat("profiler_averagetime", 2), description = Spring.I18N("ui.settings.option.profiler_averagetime_descr"), onchange = function(i, value) - Spring.SetConfigFloat("profiler_averagetime", value) + SpringUnsynced.SetConfigFloat("profiler_averagetime", value) end, }, { id = "framegrapher", group = "dev", category = types.dev, widget = "Frame Grapher", name = Spring.I18N("ui.settings.option.framegrapher"), type = "bool", value = GetWidgetToggleValue("Frame Grapher"), description = "" }, @@ -7481,7 +7481,7 @@ function init() value = false, description = "", onchange = function(i, value) - Spring.SendCommands("DebugColVol " .. (value and "1" or "0")) + SpringUnsynced.SendCommands("DebugColVol " .. (value and "1" or "0")) end, }, { @@ -7494,7 +7494,7 @@ function init() description = Spring.I18N("ui.settings.option.echocamerastate_descr"), onchange = function(i, value) options[getOptionByID("echocamerastate")].value = false - Spring.Echo(Spring.GetCameraState()) + SpringShared.Echo(SpringUnsynced.GetCameraState()) end, }, @@ -7507,10 +7507,10 @@ function init() category = types.dev, name = Spring.I18N("ui.settings.option.storedefaultsettings"), type = "bool", - value = tonumber(Spring.GetConfigInt("StoreDefaultSettings", 0) or 0) == 1, + value = tonumber(SpringUnsynced.GetConfigInt("StoreDefaultSettings", 0) or 0) == 1, description = Spring.I18N("ui.settings.option.storedefaultsettings_descr"), onchange = function(i, value) - Spring.SetConfigInt("StoreDefaultSettings", (value and 1 or 0)) + SpringUnsynced.SetConfigInt("StoreDefaultSettings", (value and 1 or 0)) end, }, @@ -7541,8 +7541,8 @@ function init() onload = function(i) end, onchange = function(i, value) if VFS.FileExists("fonts/" .. options[i].optionsFont[value]) then - Spring.SetConfigString("bar_font", options[i].optionsFont[value]) - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigString("bar_font", options[i].optionsFont[value]) + SpringUnsynced.SendCommands("luarules reloadluaui") end end, }, @@ -7558,8 +7558,8 @@ function init() onload = function(i) end, onchange = function(i, value) if VFS.FileExists("fonts/" .. options[i].optionsFont[value]) then - Spring.SetConfigString("bar_font2", options[i].optionsFont[value]) - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigString("bar_font2", options[i].optionsFont[value]) + SpringUnsynced.SendCommands("luarules reloadluaui") end end, }, @@ -7679,10 +7679,10 @@ function init() sunY = options[getOptionByID("sun_y")].max end options[getOptionByID("sun_y")].value = sunY - Spring.SetSunDirection(sunX, sunY, sunZ) + SpringUnsynced.SetSunDirection(sunX, sunY, sunZ) -- just so that map/model lighting gets updated - Spring.SetSunLighting({ groundShadowDensity = gl.GetSun("shadowDensity"), modelShadowDensity = gl.GetSun("shadowDensity") }) - Spring.Echo(gl.GetSun()) + SpringUnsynced.SetSunLighting({ groundShadowDensity = gl.GetSun("shadowDensity"), modelShadowDensity = gl.GetSun("shadowDensity") }) + SpringShared.Echo(gl.GetSun()) end, }, { @@ -7705,10 +7705,10 @@ function init() sunX = options[getOptionByID("sun_x")].max end options[getOptionByID("sun_x")].value = sunX - Spring.SetSunDirection(sunX, sunY, sunZ) + SpringUnsynced.SetSunDirection(sunX, sunY, sunZ) -- just so that map/model lighting gets updated - Spring.SetSunLighting({ groundShadowDensity = gl.GetSun("shadowDensity"), modelShadowDensity = gl.GetSun("shadowDensity") }) - Spring.Echo(gl.GetSun()) + SpringUnsynced.SetSunLighting({ groundShadowDensity = gl.GetSun("shadowDensity"), modelShadowDensity = gl.GetSun("shadowDensity") }) + SpringShared.Echo(gl.GetSun()) end, }, { @@ -7732,10 +7732,10 @@ function init() sunZ = options[getOptionByID("sun_z")].max end options[getOptionByID("sun_z")].value = sunZ - Spring.SetSunDirection(sunX, sunY, sunZ) + SpringUnsynced.SetSunDirection(sunX, sunY, sunZ) -- just so that map/model lighting gets updated - Spring.SetSunLighting({ groundShadowDensity = gl.GetSun("shadowDensity"), modelShadowDensity = gl.GetSun("shadowDensity") }) - Spring.Echo(gl.GetSun()) + SpringUnsynced.SetSunLighting({ groundShadowDensity = gl.GetSun("shadowDensity"), modelShadowDensity = gl.GetSun("shadowDensity") }) + SpringShared.Echo(gl.GetSun()) end, }, { @@ -7751,10 +7751,10 @@ function init() options[getOptionByID("sun_y")].value = defaultMapSunPos[2] options[getOptionByID("sun_z")].value = defaultMapSunPos[3] options[getOptionByID("sun_reset")].value = false - Spring.SetSunDirection(defaultMapSunPos[1], defaultMapSunPos[2], defaultMapSunPos[3]) + SpringUnsynced.SetSunDirection(defaultMapSunPos[1], defaultMapSunPos[2], defaultMapSunPos[3]) -- just so that map/model lighting gets updated - Spring.SetSunLighting({ groundShadowDensity = gl.GetSun("shadowDensity"), modelShadowDensity = gl.GetSun("shadowDensity") }) - Spring.Echo(gl.GetSun()) + SpringUnsynced.SetSunLighting({ groundShadowDensity = gl.GetSun("shadowDensity"), modelShadowDensity = gl.GetSun("shadowDensity") }) + SpringShared.Echo(gl.GetSun()) end, }, @@ -7773,7 +7773,7 @@ function init() if getOptionByID("fog_end") and value >= options[getOptionByID("fog_end")].value then applyOptionValue(getOptionByID("fog_end"), value + 0.01) end - Spring.SetAtmosphere({ fogStart = value }) + SpringUnsynced.SetAtmosphere({ fogStart = value }) end, }, { @@ -7791,7 +7791,7 @@ function init() if getOptionByID("fog_start") and value <= options[getOptionByID("fog_start")].value then applyOptionValue(getOptionByID("fog_start"), value - 0.01) end - Spring.SetAtmosphere({ fogEnd = value }) + SpringUnsynced.SetAtmosphere({ fogEnd = value }) end, }, { @@ -7809,7 +7809,7 @@ function init() options[getOptionByID("fog_end")].value = defaultMapFog.fogEnd options[getOptionByID("fog_reset")].value = false end - Spring.SetAtmosphere({ fogStart = defaultMapFog.fogStart, fogEnd = defaultMapFog.fogEnd }) + SpringUnsynced.SetAtmosphere({ fogStart = defaultMapFog.fogStart, fogEnd = defaultMapFog.fogEnd }) end, }, @@ -7827,7 +7827,7 @@ function init() onload = function(i) end, onchange = function(i, value) local fogColor = { gl.GetAtmosphere("fogColor") } - Spring.SetAtmosphere({ fogColor = { value, fogColor[2], fogColor[3], fogColor[4] } }) + SpringUnsynced.SetAtmosphere({ fogColor = { value, fogColor[2], fogColor[3], fogColor[4] } }) end, }, { @@ -7844,7 +7844,7 @@ function init() onload = function(i) end, onchange = function(i, value) local fogColor = { gl.GetAtmosphere("fogColor") } - Spring.SetAtmosphere({ fogColor = { fogColor[1], value, fogColor[3], fogColor[4] } }) + SpringUnsynced.SetAtmosphere({ fogColor = { fogColor[1], value, fogColor[3], fogColor[4] } }) end, }, { @@ -7861,7 +7861,7 @@ function init() onload = function(i) end, onchange = function(i, value) local fogColor = { gl.GetAtmosphere("fogColor") } - Spring.SetAtmosphere({ fogColor = { fogColor[1], fogColor[2], value, fogColor[4] } }) + SpringUnsynced.SetAtmosphere({ fogColor = { fogColor[1], fogColor[2], value, fogColor[4] } }) end, }, { @@ -7878,8 +7878,8 @@ function init() options[getOptionByID("fog_g")].value = defaultMapFog.fogColor[2] options[getOptionByID("fog_b")].value = defaultMapFog.fogColor[3] options[getOptionByID("fog_color_reset")].value = false - Spring.SetAtmosphere({ fogColor = defaultMapFog.fogColor }) - Spring.Echo("resetted map fog color defaults") + SpringUnsynced.SetAtmosphere({ fogColor = defaultMapFog.fogColor }) + SpringShared.Echo("resetted map fog color defaults") end, }, @@ -7895,7 +7895,7 @@ function init() options[i].value = gl.GetMapRendering("voidWater") end, onchange = function(i, value) - Spring.SetMapRenderingParams({ voidWater = value }) + SpringUnsynced.SetMapRenderingParams({ voidWater = value }) end, }, { @@ -7910,7 +7910,7 @@ function init() options[i].value = gl.GetMapRendering("voidGround") end, onchange = function(i, value) - Spring.SetMapRenderingParams({ voidGround = value }) + SpringUnsynced.SetMapRenderingParams({ voidGround = value }) end, }, @@ -7926,7 +7926,7 @@ function init() options[i].value = gl.GetMapRendering("splatDetailNormalDiffuseAlpha") end, onchange = function(i, value) - Spring.SetMapRenderingParams({ splatDetailNormalDiffuseAlpha = value }) + SpringUnsynced.SetMapRenderingParams({ splatDetailNormalDiffuseAlpha = value }) end, }, @@ -7947,7 +7947,7 @@ function init() end, onchange = function(i, value) local r, g, b, a = gl.GetMapRendering("splatTexMults") - Spring.SetMapRenderingParams({ splatTexMults = { value, g, b, a } }) + SpringUnsynced.SetMapRenderingParams({ splatTexMults = { value, g, b, a } }) end, }, { @@ -7967,7 +7967,7 @@ function init() end, onchange = function(i, value) local r, g, b, a = gl.GetMapRendering("splatTexMults") - Spring.SetMapRenderingParams({ splatTexMults = { r, value, b, a } }) + SpringUnsynced.SetMapRenderingParams({ splatTexMults = { r, value, b, a } }) end, }, { @@ -7987,7 +7987,7 @@ function init() end, onchange = function(i, value) local r, g, b, a = gl.GetMapRendering("splatTexMults") - Spring.SetMapRenderingParams({ splatTexMults = { r, g, value, a } }) + SpringUnsynced.SetMapRenderingParams({ splatTexMults = { r, g, value, a } }) end, }, { @@ -8007,7 +8007,7 @@ function init() end, onchange = function(i, value) local r, g, b, a = gl.GetMapRendering("splatTexMults") - Spring.SetMapRenderingParams({ splatTexMults = { r, g, b, value } }) + SpringUnsynced.SetMapRenderingParams({ splatTexMults = { r, g, b, value } }) end, }, @@ -8028,7 +8028,7 @@ function init() end, onchange = function(i, value) local r, g, b, a = gl.GetMapRendering("splatTexScales") - Spring.SetMapRenderingParams({ splatTexScales = { value, g, b, a } }) + SpringUnsynced.SetMapRenderingParams({ splatTexScales = { value, g, b, a } }) end, }, { @@ -8048,7 +8048,7 @@ function init() end, onchange = function(i, value) local r, g, b, a = gl.GetMapRendering("splatTexScales") - Spring.SetMapRenderingParams({ splatTexScales = { r, value, b, a } }) + SpringUnsynced.SetMapRenderingParams({ splatTexScales = { r, value, b, a } }) end, }, { @@ -8068,7 +8068,7 @@ function init() end, onchange = function(i, value) local r, g, b, a = gl.GetMapRendering("splatTexScales") - Spring.SetMapRenderingParams({ splatTexScales = { r, g, value, a } }) + SpringUnsynced.SetMapRenderingParams({ splatTexScales = { r, g, value, a } }) end, }, { @@ -8088,7 +8088,7 @@ function init() end, onchange = function(i, value) local r, g, b, a = gl.GetMapRendering("splatTexScales") - Spring.SetMapRenderingParams({ splatTexScales = { r, g, b, value } }) + SpringUnsynced.SetMapRenderingParams({ splatTexScales = { r, g, b, value } }) end, }, @@ -8108,8 +8108,8 @@ function init() options[i].value = groundshadowDensity end, onchange = function(i, value) - Spring.SetSunLighting({ groundShadowDensity = value }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ groundShadowDensity = value }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, @@ -8129,8 +8129,8 @@ function init() options[i].value = groundshadowDensity end, onchange = function(i, value) - Spring.SetSunLighting({ modelShadowDensity = value }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ modelShadowDensity = value }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, @@ -8151,8 +8151,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("ambient") - Spring.SetSunLighting({ groundAmbientColor = { value, g, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ groundAmbientColor = { value, g, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8172,8 +8172,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("ambient") - Spring.SetSunLighting({ groundAmbientColor = { r, value, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ groundAmbientColor = { r, value, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8193,8 +8193,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("ambient") - Spring.SetSunLighting({ groundAmbientColor = { r, g, value } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ groundAmbientColor = { r, g, value } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, @@ -8215,8 +8215,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("diffuse") - Spring.SetSunLighting({ groundDiffuseColor = { value, g, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ groundDiffuseColor = { value, g, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8236,8 +8236,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("diffuse") - Spring.SetSunLighting({ groundDiffuseColor = { r, value, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ groundDiffuseColor = { r, value, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8257,8 +8257,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("diffuse") - Spring.SetSunLighting({ groundDiffuseColor = { r, g, value } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ groundDiffuseColor = { r, g, value } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, @@ -8279,8 +8279,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("specular") - Spring.SetSunLighting({ groundSpecularColor = { value, g, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ groundSpecularColor = { value, g, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8300,8 +8300,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("specular") - Spring.SetSunLighting({ groundSpecularColor = { r, value, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ groundSpecularColor = { r, value, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8321,8 +8321,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("specular") - Spring.SetSunLighting({ groundSpecularColor = { r, g, value } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ groundSpecularColor = { r, g, value } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, @@ -8343,8 +8343,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("ambient", "unit") - Spring.SetSunLighting({ unitAmbientColor = { value, g, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ unitAmbientColor = { value, g, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8364,8 +8364,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("ambient", "unit") - Spring.SetSunLighting({ unitAmbientColor = { r, value, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ unitAmbientColor = { r, value, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8385,8 +8385,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("ambient", "unit") - Spring.SetSunLighting({ unitAmbientColor = { r, g, value } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ unitAmbientColor = { r, g, value } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, @@ -8407,8 +8407,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("diffuse", "unit") - Spring.SetSunLighting({ unitDiffuseColor = { value, g, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ unitDiffuseColor = { value, g, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8428,8 +8428,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("diffuse", "unit") - Spring.SetSunLighting({ unitDiffuseColor = { r, value, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ unitDiffuseColor = { r, value, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8449,8 +8449,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("diffuse", "unit") - Spring.SetSunLighting({ unitDiffuseColor = { r, g, value } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ unitDiffuseColor = { r, g, value } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, @@ -8471,8 +8471,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("specular", "unit") - Spring.SetSunLighting({ unitSpecularColor = { value, g, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ unitSpecularColor = { value, g, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8492,8 +8492,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("specular", "unit") - Spring.SetSunLighting({ unitSpecularColor = { r, value, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ unitSpecularColor = { r, value, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8513,8 +8513,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetSun("specular", "unit") - Spring.SetSunLighting({ unitSpecularColor = { r, g, value } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting({ unitSpecularColor = { r, g, value } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, @@ -8535,8 +8535,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetAtmosphere("sunColor") - Spring.SetAtmosphere({ sunColor = { value, g, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetAtmosphere({ sunColor = { value, g, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8556,8 +8556,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetAtmosphere("sunColor") - Spring.SetAtmosphere({ sunColor = { r, value, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetAtmosphere({ sunColor = { r, value, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8577,8 +8577,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetAtmosphere("sunColor") - Spring.SetAtmosphere({ sunColor = { r, g, value } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetAtmosphere({ sunColor = { r, g, value } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, @@ -8599,8 +8599,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetAtmosphere("skyColor") - Spring.SetAtmosphere({ skyColor = { value, g, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetAtmosphere({ skyColor = { value, g, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8620,8 +8620,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetAtmosphere("skyColor") - Spring.SetAtmosphere({ skyColor = { r, value, b } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetAtmosphere({ skyColor = { r, value, b } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, { @@ -8641,8 +8641,8 @@ function init() end, onchange = function(i, value) local r, g, b = gl.GetAtmosphere("skyColor") - Spring.SetAtmosphere({ skyColor = { r, g, value } }) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetAtmosphere({ skyColor = { r, g, value } }) + SpringUnsynced.SendCommands("luarules updatesun") end, }, @@ -8658,8 +8658,8 @@ function init() onchange = function(i, value) options[getOptionByID("sunlighting_reset")].value = false -- just so that map/model lighting gets updated - Spring.SetSunLighting(defaultSunLighting) - Spring.Echo("resetted ground/unit coloring") + SpringUnsynced.SetSunLighting(defaultSunLighting) + SpringShared.Echo("resetted ground/unit coloring") init() end, }, @@ -8682,7 +8682,7 @@ function init() onchange = function(i, value) local x, y, z, angle = gl.GetAtmosphere("skyAxisAngle") angle = value - Spring.SetAtmosphere({ skyAxisAngle = { x, y, z, angle } }) + SpringUnsynced.SetAtmosphere({ skyAxisAngle = { x, y, z, angle } }) end, }, { @@ -8703,7 +8703,7 @@ function init() onchange = function(i, value) local x, y, z, angle = gl.GetAtmosphere("skyAxisAngle") x = value - Spring.SetAtmosphere({ skyAxisAngle = { x, y, z, angle } }) + SpringUnsynced.SetAtmosphere({ skyAxisAngle = { x, y, z, angle } }) end, }, { @@ -8724,7 +8724,7 @@ function init() onchange = function(i, value) local x, y, z, angle = gl.GetAtmosphere("skyAxisAngle") y = value - Spring.SetAtmosphere({ skyAxisAngle = { x, y, z, angle } }) + SpringUnsynced.SetAtmosphere({ skyAxisAngle = { x, y, z, angle } }) end, }, { @@ -8745,7 +8745,7 @@ function init() onchange = function(i, value) local x, y, z, angle = gl.GetAtmosphere("skyAxisAngle") z = value - Spring.SetAtmosphere({ skyAxisAngle = { x, y, z, angle } }) + SpringUnsynced.SetAtmosphere({ skyAxisAngle = { x, y, z, angle } }) end, }, @@ -8760,8 +8760,8 @@ function init() onload = function(i) end, onchange = function(i, value) options[getOptionByID("skyaxisangle_reset")].value = false - Spring.SetAtmosphere({ skyAxisAngle = defaultSkyAxisAngle }) - Spring.Echo("resetted skyAxisAngle atmosphere") + SpringUnsynced.SetAtmosphere({ skyAxisAngle = defaultSkyAxisAngle }) + SpringShared.Echo("resetted skyAxisAngle atmosphere") init() end, }, @@ -8775,12 +8775,12 @@ function init() category = types.dev, name = "Bumpwater settings " .. widgetOptionColor .. " shorewaves", type = "bool", - value = Spring.GetConfigInt("BumpWaterShoreWaves", 1) == 1, + value = SpringUnsynced.GetConfigInt("BumpWaterShoreWaves", 1) == 1, description = "", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ shoreWaves = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ shoreWaves = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8789,12 +8789,12 @@ function init() category = types.dev, name = widgetOptionColor .. " dynamic waves", type = "bool", - value = Spring.GetConfigInt("BumpWaterDynamicWaves", 1) == 1, + value = SpringUnsynced.GetConfigInt("BumpWaterDynamicWaves", 1) == 1, description = "Springsettings.cfg config, Probably requires a restart", onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("BumpWaterDynamicWaves", (value and 1 or 0)) - Spring.SendCommands("water 4") + SpringUnsynced.SetConfigInt("BumpWaterDynamicWaves", (value and 1 or 0)) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8803,12 +8803,12 @@ function init() category = types.dev, name = widgetOptionColor .. " endless", type = "bool", - value = Spring.GetConfigInt("BumpWaterEndlessOcean", 1) == 1, + value = SpringUnsynced.GetConfigInt("BumpWaterEndlessOcean", 1) == 1, description = "Springsettings.cfg config, Probably requires a restart", onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("BumpWaterEndlessOcean", (value and 1 or 0)) - Spring.SendCommands("water 4") + SpringUnsynced.SetConfigInt("BumpWaterEndlessOcean", (value and 1 or 0)) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8817,12 +8817,12 @@ function init() category = types.dev, name = widgetOptionColor .. " occlusion query", type = "bool", - value = Spring.GetConfigInt("BumpWaterOcclusionQuery", 1) == 1, + value = SpringUnsynced.GetConfigInt("BumpWaterOcclusionQuery", 1) == 1, description = "Springsettings.cfg config, Probably requires a restart", onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("BumpWaterOcclusionQuery", (value and 1 or 0)) - Spring.SendCommands("water 4") + SpringUnsynced.SetConfigInt("BumpWaterOcclusionQuery", (value and 1 or 0)) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8831,12 +8831,12 @@ function init() category = types.dev, name = widgetOptionColor .. " blur reflection", type = "bool", - value = Spring.GetConfigInt("BumpWaterBlurReflection", 1) == 1, + value = SpringUnsynced.GetConfigInt("BumpWaterBlurReflection", 1) == 1, description = "Springsettings.cfg config, Probably requires a restart", onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("BumpWaterBlurReflection", (value and 1 or 0)) - Spring.SendCommands("water 4") + SpringUnsynced.SetConfigInt("BumpWaterBlurReflection", (value and 1 or 0)) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8845,12 +8845,12 @@ function init() category = types.dev, name = widgetOptionColor .. " anisotropy", type = "bool", - value = Spring.GetConfigInt("BumpWaterAnisotropy", 1) == 1, + value = SpringUnsynced.GetConfigInt("BumpWaterAnisotropy", 1) == 1, description = "Springsettings.cfg config, Probably requires a restart", onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("BumpWaterAnisotropy", (value and 1 or 0)) - Spring.SendCommands("water 4") + SpringUnsynced.SetConfigInt("BumpWaterAnisotropy", (value and 1 or 0)) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8859,12 +8859,12 @@ function init() category = types.dev, name = widgetOptionColor .. " use depth texture", type = "bool", - value = Spring.GetConfigInt("BumpWaterUseDepthTexture", 1) == 1, + value = SpringUnsynced.GetConfigInt("BumpWaterUseDepthTexture", 1) == 1, description = "Springsettings.cfg config, Probably requires a restart", onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("BumpWaterUseDepthTexture", (value and 1 or 0)) - Spring.SendCommands("water 4") + SpringUnsynced.SetConfigInt("BumpWaterUseDepthTexture", (value and 1 or 0)) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8873,12 +8873,12 @@ function init() category = types.dev, name = widgetOptionColor .. " use uniforms", type = "bool", - value = Spring.GetConfigInt("BumpWaterUseUniforms", 1) == 1, + value = SpringUnsynced.GetConfigInt("BumpWaterUseUniforms", 1) == 1, description = "Springsettings.cfg config, Probably requires a restart", onload = function(i) end, onchange = function(i, value) - Spring.SetConfigInt("BumpWaterUseUniforms", (value and 1 or 0)) - Spring.SendCommands("water 4") + SpringUnsynced.SetConfigInt("BumpWaterUseUniforms", (value and 1 or 0)) + SpringUnsynced.SendCommands("water 4") end, }, @@ -8893,8 +8893,8 @@ function init() description = "Springsettings.cfg config, Probably requires a restart", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ shoreWaves = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ shoreWaves = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8907,8 +8907,8 @@ function init() description = "The WaterPlane is a single Quad beneath the map.\nIt should have the same color as the ocean floor to hide the map -> background boundary. Specifying waterPlaneColor in mapinfo.lua will turn this on.", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ hasWaterPlane = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ hasWaterPlane = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8921,8 +8921,8 @@ function init() description = "Should the water be rendered even when minMapHeight>0.\nUse it to avoid the jumpin of the outside-map water rendering (BumpWater: endlessOcean option) when combat explosions reach groundwater.", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ forceRendering = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ forceRendering = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8938,8 +8938,8 @@ function init() description = "water 0 texture repeat horizontal", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ repeatX = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ repeatX = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8955,8 +8955,8 @@ function init() description = "water 0 texture repeat vertical", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ repeatY = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ repeatY = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -8972,8 +8972,8 @@ function init() description = "", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ surfaceAlpha = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ surfaceAlpha = value }) + SpringUnsynced.SendCommands("water 4") end, }, -- gl.GetWaterRendering("windSpeed") seems to not exist @@ -8998,8 +8998,8 @@ function init() description = "How much ambient lighting the water surface gets (ideally very little)", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ ambientFactor = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ ambientFactor = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9015,8 +9015,8 @@ function init() description = "How strong the diffuse lighting should be on the water", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ diffuseFactor = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ diffuseFactor = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9032,8 +9032,8 @@ function init() description = "How much light should be reflected straight from the sun", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ specularFactor = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ specularFactor = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9049,8 +9049,8 @@ function init() description = "How polished the surface of the water is", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ specularPower = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ specularPower = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9066,8 +9066,8 @@ function init() description = "The initial frequency of the bump map repetetion rate. Larger numbers mean more tiles", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ perlinStartFreq = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ perlinStartFreq = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9083,8 +9083,8 @@ function init() description = "How much smaller each additional repetion of the normal map should be. Larger numbers mean smaller", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ perlinLacunarity = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ perlinLacunarity = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9100,8 +9100,8 @@ function init() description = "How strong each additional repetetion of the normal map should be", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ perlinAmplitude = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ perlinAmplitude = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9117,8 +9117,8 @@ function init() description = "Minimum reflection strength, e.g. the reflectivity of the water when looking straight down on it", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ fresnelMin = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ fresnelMin = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9134,8 +9134,8 @@ function init() description = "Maximum reflection strength, the reflectivity of the water when looking parallel to the water plane", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ fresnelMax = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ fresnelMax = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9151,8 +9151,8 @@ function init() description = "Determines how fast the reflection increases when going from straight down view to parallel.", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ fresnelPower = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ fresnelPower = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9168,8 +9168,8 @@ function init() description = "How many (squared) Tiles does the `normalTexture` have?\nSuch Tiles are used when DynamicWaves are enabled in BumpWater, the more the better.\nCheck the example php script to generate such tiled bumpmaps.", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ numTiles = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ numTiles = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9185,8 +9185,8 @@ function init() description = "How much should the reflection be blurred", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ blurBase = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ blurBase = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9202,8 +9202,8 @@ function init() description = "How much should the reflection be blurred", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ blurExponent = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ blurExponent = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9219,8 +9219,8 @@ function init() description = "", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ reflectionDistortion = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ reflectionDistortion = value }) + SpringUnsynced.SendCommands("water 4") end, }, -- new water 4 params since engine 105BAR 582 @@ -9237,8 +9237,8 @@ function init() description = "Set this to 0.1 to make waves break shores not all at the same time", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ waveOffsetFactor = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ waveOffsetFactor = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9254,8 +9254,8 @@ function init() description = "How long the waves are", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ waveLength = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ waveLength = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9271,8 +9271,8 @@ function init() description = "How much the waters movement distorts the foam texture", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ waveFoamDistortion = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ waveFoamDistortion = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9288,8 +9288,8 @@ function init() description = "How strong the foam texture is", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ waveFoamIntensity = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ waveFoamIntensity = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9305,8 +9305,8 @@ function init() description = "The tiling rate of the caustics texture", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ causticsResolution = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ causticsResolution = value }) + SpringUnsynced.SendCommands("water 4") end, }, { @@ -9322,8 +9322,8 @@ function init() description = "How intense the caustics effects are", onload = function(i) end, onchange = function(i, value) - Spring.SetWaterParams({ causticsStrength = value }) - Spring.SendCommands("water 4") + SpringUnsynced.SetWaterParams({ causticsStrength = value }) + SpringUnsynced.SendCommands("water 4") end, }, -- TODO add SetWaterParams: @@ -9338,8 +9338,8 @@ function init() if not isPotatoGpu and not devMode and not devUI then options[getOptionByID("advmapshading")] = nil - Spring.SetConfigInt("AdvMapShading", 1) - Spring.SendCommands("advmapshading 1") + SpringUnsynced.SetConfigInt("AdvMapShading", 1) + SpringUnsynced.SendCommands("advmapshading 1") end -- reset tonemap defaults (only once) @@ -9395,21 +9395,21 @@ function init() if not Spring.Utilities.Gametype.GetCurrentHolidays()["aprilfools"] then options[getOptionByID("soundtrackAprilFools")] = nil - Spring.SetConfigInt("UseSoundtrackAprilFools", 1) + SpringUnsynced.SetConfigInt("UseSoundtrackAprilFools", 1) else options[getOptionByID("soundtrackAprilFoolsPostEvent")] = nil end if not Spring.Utilities.Gametype.GetCurrentHolidays()["halloween"] then options[getOptionByID("soundtrackHalloween")] = nil - Spring.SetConfigInt("UseSoundtrackHalloween", 1) + SpringUnsynced.SetConfigInt("UseSoundtrackHalloween", 1) else options[getOptionByID("soundtrackHalloweenPostEvent")] = nil end if not Spring.Utilities.Gametype.GetCurrentHolidays()["xmas"] then options[getOptionByID("soundtrackXmas")] = nil - Spring.SetConfigInt("UseSoundtrackXmas", 1) + SpringUnsynced.SetConfigInt("UseSoundtrackXmas", 1) else options[getOptionByID("soundtrackXmasPostEvent")] = nil end @@ -9443,12 +9443,12 @@ function init() options[getOptionByID("font")].options = fonts options[getOptionByID("font")].optionsFont = fontsFull - local fname = Spring.GetConfigString("bar_font", "Poppins-Regular.otf"):lower() + local fname = SpringUnsynced.GetConfigString("bar_font", "Poppins-Regular.otf"):lower() options[getOptionByID("font")].value = getSelectKey(getOptionByID("font"), string.sub(fname, 1, string.len(fname) - 4)) options[getOptionByID("font2")].options = fonts options[getOptionByID("font2")].optionsFont = fontsFull - local fname = Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf"):lower() + local fname = SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf"):lower() options[getOptionByID("font2")].value = getSelectKey(getOptionByID("font2"), string.sub(fname, 1, string.len(fname) - 4)) end @@ -9456,14 +9456,14 @@ function init() if getOptionByID("sun_y") then local sunX, sunY, sunZ = gl.GetSun("pos") if sunY < options[getOptionByID("sun_y")].min then - Spring.SetSunDirection(sunX, options[getOptionByID("sun_y")].min, sunZ) + SpringUnsynced.SetSunDirection(sunX, options[getOptionByID("sun_y")].min, sunZ) end end -- set minimal shadow opacity if getOptionByID("shadows_opacity") then if gl.GetSun("shadowDensity") < options[getOptionByID("shadows_opacity")].min then - Spring.SetSunLighting({ groundShadowDensity = options[getOptionByID("shadows_opacity")].min, modelShadowDensity = options[getOptionByID("shadows_opacity")].min }) + SpringUnsynced.SetSunLighting({ groundShadowDensity = options[getOptionByID("shadows_opacity")].min, modelShadowDensity = options[getOptionByID("shadows_opacity")].min }) end end @@ -9474,14 +9474,14 @@ function init() options[getOptionByID("anonymous_b")] = nil end - if Spring.GetGameFrame() == 0 then + if SpringShared.GetGameFrame() == 0 then detectWater() -- set vsync - Spring.SetConfigInt("VSync", Spring.GetConfigInt("VSyncGame", -1) * Spring.GetConfigInt("VSyncFraction", 1)) + SpringUnsynced.SetConfigInt("VSync", SpringUnsynced.GetConfigInt("VSyncGame", -1) * SpringUnsynced.GetConfigInt("VSyncFraction", 1)) end if not waterDetected then - Spring.SendCommands("water 0") + SpringUnsynced.SendCommands("water 0") end if #displayNames <= 1 then @@ -9490,7 +9490,7 @@ function init() end -- only allow dualscreen-mode on single displays when super ultrawide screen or Multi Display option shows - if (#displayNames <= 1 and vsx / vsy < 2.5) or (#displayNames > 1 and #displayNames == Spring.GetNumDisplays()) then + if (#displayNames <= 1 and vsx / vsy < 2.5) or (#displayNames > 1 and #displayNames == SpringUnsynced.GetNumDisplays()) then options[getOptionByID("dualmode_enabled")] = nil options[getOptionByID("dualmode_left")] = nil options[getOptionByID("dualmode_minimap_aspectratio")] = nil @@ -9507,9 +9507,9 @@ function init() -- disable engine decals (footprints) options[getOptionByID("decals")] = nil - if Spring.GetConfigInt("GroundDecals", 3) > 0 then - Spring.SendCommands("GroundDecals 0") - Spring.SetConfigInt("GroundDecals", 0) + if SpringUnsynced.GetConfigInt("GroundDecals", 3) > 0 then + SpringUnsynced.SendCommands("GroundDecals 0") + SpringUnsynced.SetConfigInt("GroundDecals", 0) end if isPotatoGpu then @@ -9561,7 +9561,7 @@ function init() end elseif gpuMem >= 3000 then - if Spring.GetConfigInt("cus2", 1) ~= 1 then + if SpringUnsynced.GetConfigInt("cus2", 1) ~= 1 then local id = getOptionByID("cusgl4") options[id].onchange(id, 1) end @@ -9577,9 +9577,9 @@ function init() options[getOptionByID("cusgl4")] = nil options[getOptionByID("water")] = nil else - if Spring.GetConfigInt("Water", 0) ~= 4 then - Spring.SendCommands("water 4") - Spring.SetConfigInt("Water", 4) + if SpringUnsynced.GetConfigInt("Water", 0) ~= 4 then + SpringUnsynced.SendCommands("water 4") + SpringUnsynced.SetConfigInt("Water", 4) end end end @@ -9599,7 +9599,7 @@ function init() end -- while we have set config-ints, that isnt enough to have these settings applied ingame - if savedConfig and Spring.GetGameFrame() == 0 then + if savedConfig and SpringShared.GetGameFrame() == 0 then for k, v in pairs(savedConfig) do if getOptionByID(k) then applyOptionValue(getOptionByID(k)) @@ -9610,9 +9610,9 @@ function init() -- detect AI local aiDetected = false - local t = Spring.GetTeamList() + local t = SpringShared.GetTeamList() for _, teamID in ipairs(t) do - if select(4, Spring.GetTeamInfo(teamID, false)) then + if select(4, SpringShared.GetTeamInfo(teamID, false)) then aiDetected = true end end @@ -9671,7 +9671,7 @@ function init() -- add sound notification sets if getOptionByID("notifications_set") then - local voiceset = Spring.GetConfigString("voiceset", "en/cephis") + local voiceset = SpringUnsynced.GetConfigString("voiceset", "en/cephis") local currentVoiceSetOption local sets = {} local languageDirs = VFS.SubDirs("sounds/voice", "*") @@ -9861,7 +9861,7 @@ function init() end -- not sure if needed: remove vsync option when its done by monitor (freesync/gsync) -> config value is set as 'x' - if Spring.GetConfigInt("VSync", 1) == "x" then + if SpringUnsynced.GetConfigInt("VSync", 1) == "x" then options[getOptionByID("vsync")] = nil options[getOptionByID("vsync_spec")] = nil options[getOptionByID("vsync_level")] = nil @@ -9880,11 +9880,11 @@ function init() options[getOptionByID("lockcamera_hideenemies")] = nil end - if Spring.GetConfigInt("CamMode", 2) ~= 2 then + if SpringUnsynced.GetConfigInt("CamMode", 2) ~= 2 then options[getOptionByID("springcamheightmode")] = nil end - if Spring.GetConfigString("KeybindingFile") ~= "uikeys.txt" then + if SpringUnsynced.GetConfigString("KeybindingFile") ~= "uikeys.txt" then options[getOptionByID("gridmenu")] = nil end @@ -10024,7 +10024,7 @@ function widget:MapDrawCmd(playerID, cmdType, startx, starty, startz, a, b, c) end function widget:UnsyncedHeightMapUpdate(x1, z1, x2, z2) - if not waterDetected and Spring.GetGameFrame() > 30 then + if not waterDetected and SpringShared.GetGameFrame() > 30 then if heightmapChangeClock == nil then heightmapChangeClock = os_clock() end @@ -10046,7 +10046,7 @@ local function optionsCmd(_, _, params) if showTextInput then if show then widgetHandler.textOwner = self --widgetHandler:OwnText() - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! else cancelChatInput() end @@ -10070,7 +10070,7 @@ local function optionCmd(_, _, params) show = true if showTextInput then widgetHandler.textOwner = self --widgetHandler:OwnText() - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! end end else @@ -10096,7 +10096,7 @@ local function optionCmd(_, _, params) end local function devmodeCmd(_, _, params) - Spring.SendCommands("option devmode") + SpringUnsynced.SendCommands("option devmode") end local function profileCmd(_, _, params) @@ -10135,7 +10135,7 @@ function widget:Initialize() widgetHandler:EnableWidget("Mex Snap") end -- set nano particle rotation: rotValue, rotVelocity, rotAcceleration, rotValueRNG, rotVelocityRNG, rotAccelerationRNG (in degrees) - Spring.SetNanoProjectileParams(-180, -50, -50, 360, 100, 100) + SpringUnsynced.SetNanoProjectileParams(-180, -50, -50, 360, 100, 100) -- just making sure if widgetHandler.orderList["Pregame UI"] < 0.5 then @@ -10176,83 +10176,83 @@ function widget:Initialize() --end -- make sure new icon system is used - if Spring.GetConfigInt("UnitIconsAsUI", 0) == 0 then - Spring.SendCommands("iconsasui 1") - Spring.SetConfigInt("UnitIconsAsUI", 1) + if SpringUnsynced.GetConfigInt("UnitIconsAsUI", 0) == 0 then + SpringUnsynced.SendCommands("iconsasui 1") + SpringUnsynced.SetConfigInt("UnitIconsAsUI", 1) end if firstlaunchsetupDone == false then firstlaunchsetupDone = true - Spring.Echo("First time setup: done") - Spring.SetConfigFloat("snd_airAbsorption", 0.35) + SpringShared.Echo("First time setup: done") + SpringUnsynced.SetConfigFloat("snd_airAbsorption", 0.35) -- Set lower defaults for lower end/potato systems if gpuMem < 3300 then - if Spring.GetConfigInt("MSAALevel", 2) > 2 then - Spring.SetConfigInt("MSAALevel", 2) + if SpringUnsynced.GetConfigInt("MSAALevel", 2) > 2 then + SpringUnsynced.SetConfigInt("MSAALevel", 2) end end if isPotatoGpu then - Spring.SendCommands("water 0") - Spring.SetConfigInt("Water", 0) + SpringUnsynced.SendCommands("water 0") + SpringUnsynced.SetConfigInt("Water", 0) --Spring.SetConfigInt("AdvMapShading", 0) --Spring.SendCommands("advmapshading 0") - Spring.SendCommands("Shadows 0 1024") - Spring.SetConfigInt("Shadows", 0) - Spring.GetConfigInt("ShadowQuality", 0) - Spring.SetConfigInt("ShadowMapSize", 1024) - Spring.SetConfigInt("Shadows", 0) - Spring.SetConfigInt("MSAALevel", 0) - Spring.SetConfigFloat("ui_opacity", 0.7) -- set to be more opaque cause guishader isnt availible + SpringUnsynced.SendCommands("Shadows 0 1024") + SpringUnsynced.SetConfigInt("Shadows", 0) + SpringUnsynced.GetConfigInt("ShadowQuality", 0) + SpringUnsynced.SetConfigInt("ShadowMapSize", 1024) + SpringUnsynced.SetConfigInt("Shadows", 0) + SpringUnsynced.SetConfigInt("MSAALevel", 0) + SpringUnsynced.SetConfigFloat("ui_opacity", 0.7) -- set to be more opaque cause guishader isnt availible else - Spring.SendCommands("water 4") - Spring.SetConfigInt("Water", 4) + SpringUnsynced.SendCommands("water 4") + SpringUnsynced.SetConfigInt("Water", 4) end local minMaxparticles = 12000 - if tonumber(Spring.GetConfigInt("MaxParticles", 1) or 0) < minMaxparticles then - Spring.SetConfigInt("MaxParticles", minMaxparticles) - Spring.Echo("First time setup: setting MaxParticles config value to " .. minMaxparticles) + if tonumber(SpringUnsynced.GetConfigInt("MaxParticles", 1) or 0) < minMaxparticles then + SpringUnsynced.SetConfigInt("MaxParticles", minMaxparticles) + SpringShared.Echo("First time setup: setting MaxParticles config value to " .. minMaxparticles) end - Spring.SetConfigInt("CamMode", 3) - Spring.SendCommands("viewspring") + SpringUnsynced.SetConfigInt("CamMode", 3) + SpringUnsynced.SendCommands("viewspring") end - Spring.SetConfigFloat("CamTimeFactor", 1) - Spring.SetConfigString("InputTextGeo", "0.35 0.72 0.03 0.04") -- input chat position posX, posY, ?, ? + SpringUnsynced.SetConfigFloat("CamTimeFactor", 1) + SpringUnsynced.SetConfigString("InputTextGeo", "0.35 0.72 0.03 0.04") -- input chat position posX, posY, ?, ? - if Spring.GetGameFrame() == 0 then + if SpringShared.GetGameFrame() == 0 then -- set minimum particle amount - if tonumber(Spring.GetConfigInt("MaxParticles", 1) or 10000) <= 10000 then - Spring.SetConfigInt("MaxParticles", 10000) + if tonumber(SpringUnsynced.GetConfigInt("MaxParticles", 1) or 10000) <= 10000 then + SpringUnsynced.SetConfigInt("MaxParticles", 10000) end - if Spring.GetConfigInt("MaxSounds", 128) < 128 then - Spring.SetConfigInt("MaxSounds", 128) + if SpringUnsynced.GetConfigInt("MaxSounds", 128) < 128 then + SpringUnsynced.SetConfigInt("MaxSounds", 128) end -- limit MSAA - if Spring.GetConfigInt("MSAALevel", 0) > 8 then - Spring.SetConfigInt("MSAALevel", 8) + if SpringUnsynced.GetConfigInt("MSAALevel", 0) > 8 then + SpringUnsynced.SetConfigInt("MSAALevel", 8) end end -- make sure vertical angle is proper (not horizontal view) - if Spring.GetGameFrame() == 0 and (Spring.GetConfigInt("CamMode", 2) == 2 or Spring.GetConfigInt("CamMode", 2) == 3) then - local cameraState = Spring.GetCameraState() + if SpringShared.GetGameFrame() == 0 and (SpringUnsynced.GetConfigInt("CamMode", 2) == 2 or SpringUnsynced.GetConfigInt("CamMode", 2) == 3) then + local cameraState = SpringUnsynced.GetCameraState() cameraState.rx = 2.6 - Spring.SetCameraState(cameraState, 0.1) + SpringUnsynced.SetCameraState(cameraState, 0.1) end -- make sure fog-start is smaller than fog-end in case maps have configured it this way if gl.GetAtmosphere("fogEnd") <= gl.GetAtmosphere("fogStart") then - Spring.SetAtmosphere({ fogEnd = gl.GetAtmosphere("fogStart") + 0.01 }) + SpringUnsynced.SetAtmosphere({ fogEnd = gl.GetAtmosphere("fogStart") + 0.01 }) end - Spring.SendCommands("minimap unitsize " .. (Spring.GetConfigFloat("MinimapIconScale", 3.5))) -- spring wont remember what you set with '/minimap iconssize #' + SpringUnsynced.SendCommands("minimap unitsize " .. (SpringUnsynced.GetConfigFloat("MinimapIconScale", 3.5))) -- spring wont remember what you set with '/minimap iconssize #' WG["options"] = {} WG["options"].toggle = function(state) @@ -10267,7 +10267,7 @@ function widget:Initialize() if showTextInput then if show then widgetHandler.textOwner = self --widgetHandler:OwnText() - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! else cancelChatInput() end @@ -10328,7 +10328,7 @@ function widget:Initialize() WG["options"].applyOptionValue = function(option, value) local optionID = getOptionByID(option) if not optionID then - Spring.Echo("Options widget: applyOptionValue: option '" .. option .. "' not found") + SpringShared.Echo("Options widget: applyOptionValue: option '" .. option .. "' not found") return end applyOptionValue(optionID, tonumber(value)) @@ -10369,7 +10369,7 @@ function widget:Shutdown() WG["options"] = nil resetUserVolume() - Spring.SendCommands("grabinput 0") + SpringUnsynced.SendCommands("grabinput 0") widgetHandler.actionHandler:RemoveAction(self, "options") widgetHandler.actionHandler:RemoveAction(self, "option") @@ -10445,7 +10445,7 @@ function widget:SetConfigData(data) if data.edgeMoveWidth then edgeMoveWidth = data.edgeMoveWidth end - if Spring.GetGameFrame() > 0 then + if SpringShared.GetGameFrame() > 0 then if data.requireRestartDefaults then requireRestartDefaults = data.requireRestartDefaults end @@ -10459,11 +10459,11 @@ function widget:SetConfigData(data) show = data.show if show and showTextInput then widgetHandler.textOwner = self --widgetHandler:OwnText() - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! end end end - if data.pauseGameWhenSingleplayerExecuted ~= nil and Spring.GetGameFrame() > 0 then + if data.pauseGameWhenSingleplayerExecuted ~= nil and SpringShared.GetGameFrame() > 0 then pauseGameWhenSingleplayerExecuted = data.pauseGameWhenSingleplayerExecuted end if data.pauseGameWhenSingleplayer ~= nil then @@ -10475,7 +10475,7 @@ function widget:SetConfigData(data) if data.savedConfig ~= nil then savedConfig = data.savedConfig for k, v in pairs(savedConfig) do - Spring.SetConfigFloat(v[1], v[2]) + SpringUnsynced.SetConfigFloat(v[1], v[2]) end end if data.mapChecksum and data.mapChecksum == Game.mapChecksum then diff --git a/luaui/Widgets/gui_ordermenu.lua b/luaui/Widgets/gui_ordermenu.lua index 7766a2010d1..f9785822224 100644 --- a/luaui/Widgets/gui_ordermenu.lua +++ b/luaui/Widgets/gui_ordermenu.lua @@ -17,10 +17,10 @@ local mathCeil = math.ceil local mathFloor = math.floor -- Localized Spring API for performance -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetGameFrame = Spring.GetGameFrame -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetGameFrame = SpringShared.GetGameFrame +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local keyConfig = VFS.Include("luaui/configs/keyboard_layouts.lua") local currentLayout @@ -77,8 +77,8 @@ local barGlowEdgeTexture = ":l:LuaUI/Images/barglow-edge.png" local soundButton = "LuaUI/Sounds/buildbar_waypoint.wav" -local uiOpacity = Spring.GetConfigFloat("ui_opacity", 0.7) -local uiScale = Spring.GetConfigFloat("ui_scale", 1) +local uiOpacity = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7) +local uiScale = SpringUnsynced.GetConfigFloat("ui_scale", 1) local backgroundRect = {} local activeRect = {} @@ -169,8 +169,8 @@ local hiddenCommandTypes = { local CMDTYPE_ICON_BUILDING = CMDTYPE.ICON_BUILDING local CMDTYPE_ICON_MODE = CMDTYPE.ICON_MODE -local spGetActiveCommand = Spring.GetActiveCommand -local spGetActiveCmdDescs = Spring.GetActiveCmdDescs +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetActiveCmdDescs = SpringUnsynced.GetActiveCmdDescs local os_clock = os.clock @@ -309,12 +309,12 @@ local function computeWaitState() end -- Use cached first unit instead of calling spGetSelectedUnits() which allocates a large table local ref = cachedFirstUnit - if ref and Spring.ValidUnitID(ref) and Spring.FindUnitCmdDesc(ref, CMD.WAIT) then + if ref and SpringShared.ValidUnitID(ref) and SpringShared.FindUnitCmdDesc(ref, CMD.WAIT) then local commandQueue - if isFactory[Spring.GetUnitDefID(ref)] then - commandQueue = Spring.GetFactoryCommands(ref, 1) + if isFactory[SpringShared.GetUnitDefID(ref)] then + commandQueue = SpringShared.GetFactoryCommands(ref, 1) else - commandQueue = Spring.GetUnitCommands(ref, 1) + commandQueue = SpringShared.GetUnitCommands(ref, 1) end if commandQueue and commandQueue[1] and commandQueue[1].id == CMD.WAIT then cachedWaitState = 2 @@ -550,7 +550,7 @@ function widget:ViewResize() end local function reloadBindings() - currentLayout = Spring.GetConfigString("KeyboardLayout", "qwerty") + currentLayout = SpringUnsynced.GetConfigString("KeyboardLayout", "qwerty") actionHotkeys = VFS.Include("luaui/Include/action_hotkeys.lua") end @@ -649,7 +649,7 @@ function widget:Update(dt) end disableInput = isSpectating - if Spring.IsGodModeEnabled() then + if SpringShared.IsGodModeEnabled() then disableInput = false end end @@ -907,11 +907,11 @@ local function drawOrders() end function widget:DrawScreen() - local x, y = Spring.GetMouseState() + local x, y = SpringUnsynced.GetMouseState() local cellHovered if not WG["topbar"] or not WG["topbar"].showingQuit() then if math_isInRect(x, y, backgroundRect[1], backgroundRect[2], backgroundRect[3], backgroundRect[4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") for cell = 1, #cellRects do if commands[cell] then if math_isInRect(x, y, cellRects[cell][1], cellRects[cell][2], cellRects[cell][3], cellRects[cell][4]) then @@ -1113,7 +1113,7 @@ function widget:DrawScreen() end function widget:MousePress(x, y, button) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if ordermenuShows and math_isInRect(x, y, backgroundRect[1], backgroundRect[2], backgroundRect[3], backgroundRect[4]) then @@ -1144,10 +1144,10 @@ function widget:MousePress(x, y, button) end if playSounds then - Spring.PlaySoundFile(soundButton, 0.6, "ui") + SpringUnsynced.PlaySoundFile(soundButton, 0.6, "ui") end - if cmd.id and Spring.GetCmdDescIndex(cmd.id) then - Spring.SetActiveCommand(Spring.GetCmdDescIndex(cmd.id), button, true, false, Spring.GetModKeyState()) + if cmd.id and SpringUnsynced.GetCmdDescIndex(cmd.id) then + SpringUnsynced.SetActiveCommand(SpringUnsynced.GetCmdDescIndex(cmd.id), button, true, false, SpringUnsynced.GetModKeyState()) end break end diff --git a/luaui/Widgets/gui_overview_cam_tab_hold.lua b/luaui/Widgets/gui_overview_cam_tab_hold.lua index 2fc2ee19869..19fdd29276d 100644 --- a/luaui/Widgets/gui_overview_cam_tab_hold.lua +++ b/luaui/Widgets/gui_overview_cam_tab_hold.lua @@ -24,7 +24,7 @@ local prevCamState = nil local function setActionHotkeys(action) camKeys = {} - local keyTable = Spring.GetActionHotKeys(action) + local keyTable = SpringUnsynced.GetActionHotKeys(action) for _, key in pairs(keyTable) do local btn = keyConfig.sanitizeKey(key):upper() table.insert(camKeys, btn) @@ -33,7 +33,7 @@ end -- works only with single key binds local function isCamKey(keyNum) - local pressedSymbol = Spring.GetKeySymbol(keyNum):upper() + local pressedSymbol = SpringUnsynced.GetKeySymbol(keyNum):upper() for _, symbol in pairs(camKeys) do if pressedSymbol == symbol then return true @@ -51,7 +51,7 @@ function widget:KeyPress(key, modifier, isRepeat) return false end - local camState = Spring.GetCameraState() + local camState = SpringUnsynced.GetCameraState() local isOverview = camState.name == "ov" if isOverview and isRepeat then @@ -74,14 +74,14 @@ function widget:KeyRelease(key, modifier) return false end - local camState = Spring.GetCameraState() + local camState = SpringUnsynced.GetCameraState() local isOverview = camState.name == "ov" isLongPress = false if prevCamState ~= nil and isOverview then - Spring.SendCommands({ "toggleoverview" }) - Spring.SetCameraState(prevCamState, 1) + SpringUnsynced.SendCommands({ "toggleoverview" }) + SpringUnsynced.SetCameraState(prevCamState, 1) return true end diff --git a/luaui/Widgets/gui_overview_keep_camera_position.lua b/luaui/Widgets/gui_overview_keep_camera_position.lua index 040b998c5ff..5ee6cb495b7 100644 --- a/luaui/Widgets/gui_overview_keep_camera_position.lua +++ b/luaui/Widgets/gui_overview_keep_camera_position.lua @@ -22,7 +22,7 @@ local prevCamState local function storeCamKeys() camKeys = {} - local keyTable = Spring.GetActionHotKeys("toggleoverview") + local keyTable = SpringUnsynced.GetActionHotKeys("toggleoverview") for _, key in pairs(keyTable) do local btn = keyConfig.sanitizeKey(key):upper() table.insert(camKeys, btn) @@ -35,7 +35,7 @@ end -- works only with single key binds local function isCamKey(keyNum) - local pressedSymbol = Spring.GetKeySymbol(keyNum):upper() + local pressedSymbol = SpringUnsynced.GetKeySymbol(keyNum):upper() for _, symbol in pairs(camKeys) do if pressedSymbol == symbol then return true @@ -45,12 +45,12 @@ local function isCamKey(keyNum) end local function isOverview() - return Spring.GetCameraState().name == "ov" + return SpringUnsynced.GetCameraState().name == "ov" end function widget:MouseWheel(up, value) if isOverview() and up then - Spring.SendCommands({ "toggleoverview" }) + SpringUnsynced.SendCommands({ "toggleoverview" }) return true end @@ -63,9 +63,9 @@ function widget:KeyPress(key, modifier) end if isOverview() then if prevCamState ~= nil then - Spring.SetCameraState(prevCamState, 1) + SpringUnsynced.SetCameraState(prevCamState, 1) end else - prevCamState = Spring.GetCameraState() + prevCamState = SpringUnsynced.GetCameraState() end end diff --git a/luaui/Widgets/gui_pausescreen.lua b/luaui/Widgets/gui_pausescreen.lua index e3d8b7d2311..8c1460f7b2b 100644 --- a/luaui/Widgets/gui_pausescreen.lua +++ b/luaui/Widgets/gui_pausescreen.lua @@ -16,10 +16,10 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry -local spGetGameSpeed = Spring.GetGameSpeed -local spGetGameFrame = Spring.GetGameFrame +local spGetGameSpeed = SpringUnsynced.GetGameSpeed +local spGetGameFrame = SpringShared.GetGameFrame local glColor = gl.Color local glTexture = gl.Texture @@ -80,7 +80,7 @@ local alphaLoc, showPauseScreen, nonShaderAlpha local gameover = false local noNewGameframes = false local cachedPauseText = nil -local spIsGUIHidden = Spring.IsGUIHidden +local spIsGUIHidden = SpringUnsynced.IsGUIHidden -- Pre-allocated color tables local textColor = { 1.0, 1.0, 1.0, 0 } @@ -261,7 +261,7 @@ function widget:Initialize() alphaLoc = glGetUniformLocation(shaderProgram, "alpha") end else - Spring.Echo(": GLSL not supported.") + SpringShared.Echo(": GLSL not supported.") end end diff --git a/luaui/Widgets/gui_pip.lua b/luaui/Widgets/gui_pip.lua index 20c6aab866c..a9c59b25f3d 100644 --- a/luaui/Widgets/gui_pip.lua +++ b/luaui/Widgets/gui_pip.lua @@ -1,6 +1,6 @@ local devUI = Spring.Utilities.ShowDevUI() local isSinglePlayer = Spring.Utilities.Gametype.IsSinglePlayer() -local isSpectator = Spring.GetSpectatingState() +local isSpectator = SpringUnsynced.GetSpectatingState() pipNumber = pipNumber or 1 @@ -71,8 +71,8 @@ local keyConfig = VFS.Include("luaui/configs/keyboard_layouts.lua") ---------------------------------------------------------------------------------------------------- -- Helper function to get a formatted hotkey string for an action local function getActionHotkey(action) - local currentKeyboardLayout = Spring.GetConfigString("KeyboardLayout", "qwerty") - local hotkeys = Spring.GetActionHotKeys(action) + local currentKeyboardLayout = SpringUnsynced.GetConfigString("KeyboardLayout", "qwerty") + local hotkeys = SpringUnsynced.GetActionHotKeys(action) if not hotkeys or #hotkeys == 0 then return "" end @@ -165,7 +165,7 @@ config = { iconDensityZoomFadeEnd = 0.8, -- Zoom level above which density scaling is completely off drawDecals = true, -- Show ground decals (explosion scars, footprints) from the decals GL4 widget - drawCommandFX = Spring.GetConfigInt("PipDrawCommandFX", 1) == 1, -- Show brief fading command lines when orders are given (like Commands FX widget) + drawCommandFX = SpringUnsynced.GetConfigInt("PipDrawCommandFX", 1) == 1, -- Show brief fading command lines when orders are given (like Commands FX widget) commandFXIgnoreNewUnits = true, -- Ignore commands given to newly finished units (rally point orders) commandFXOpacity = 0.2, -- Initial opacity of command FX lines commandFXDuration = 0.66, -- Seconds for command FX lines to fully fade out @@ -185,12 +185,12 @@ config = { drawComNametags = true, -- Draw player names above commander icons comNametagZoomThreshold = 0.18, -- Minimum zoom to show nametags (below this they'd overlap) drawComHealthBars = true, -- Draw health bars below commander icons when health < 99% - leftButtonPansCamera = isMinimapMode and (Spring.GetConfigInt("MinimapLeftClickMove", 1) == 1) or false, + leftButtonPansCamera = isMinimapMode and (SpringUnsynced.GetConfigInt("MinimapLeftClickMove", 1) == 1) or false, maximizeSizemult = 1.25, screenMargin = 0.00, drawProjectiles = true, zoomToCursor = true, - altKeyRequiredForZoom = Spring.GetConfigInt("PipAltKeyRequiredForZoom", 1) == 1, -- When true, scrolling over the PIP only zooms if ALT is held (otherwise passes through to the game) + altKeyRequiredForZoom = SpringUnsynced.GetConfigInt("PipAltKeyRequiredForZoom", 1) == 1, -- When true, scrolling over the PIP only zooms if ALT is held (otherwise passes through to the game) mapEdgeMargin = 0, showButtonsOnHoverOnly = true, switchInheritsTracking = false, @@ -229,7 +229,7 @@ config = { minimapMiddleClickZoomMax = 0.95, -- auto zoom out to this zoom level -- Minimap mode settings (when pipNumber == 0) - minimapModeMaxHeight = Spring.GetConfigFloat("MinimapMaxHeight", 0.32), -- Shared with gui_minimap.lua via ConfigFloat + minimapModeMaxHeight = SpringUnsynced.GetConfigFloat("MinimapMaxHeight", 0.32), -- Shared with gui_minimap.lua via ConfigFloat minimapModeMaxWidth = 0.26, -- Max width as fraction of screen width minimapModeScreenMargin = 0, -- No margin in minimap mode (edge-to-edge) minimapModeShowButtons = false, -- Hide buttons in minimap mode @@ -258,7 +258,7 @@ local state = { -- Consolidated rendering state local render = { - uiScale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1), + uiScale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1), vsx = nil, vsy = nil, widgetScale = nil, @@ -281,7 +281,7 @@ local render = { } -- Initialize render dimensions -render.vsx, render.vsy = Spring.GetViewGeometry() +render.vsx, render.vsy = SpringUnsynced.GetViewGeometry() render.widgetScale = (render.vsy / 2000) * render.uiScale render.usedButtonSize = math.floor(config.buttonSize * render.widgetScale * render.uiScale) render.dim.l = math.floor(render.vsx * 0.7) @@ -297,7 +297,7 @@ local cameraState = { wcz = 1000, targetWcx = 1000, targetWcz = 1000, - mySpecState = Spring.GetSpectatingState(), + mySpecState = SpringUnsynced.GetSpectatingState(), lastTrackedCameraState = nil, zoomToCursorActive = false, zoomToCursorWorldX = 0, @@ -598,7 +598,7 @@ function pipTV.BuildHotspots(now) local ev = events[i] if ev then local age = now - ev.time - if age < decayTime and (not losFilter or Spring.IsPosInLos(ev.x, 0, ev.z, losFilter)) then + if age < decayTime and (not losFilter or SpringShared.IsPosInLos(ev.x, 0, ev.z, losFilter)) then -- Time-based decay: linear falloff local decayFactor = 1 - (age / decayTime) local w = ev.weight * decayFactor @@ -708,7 +708,7 @@ function pipTV.ScanAnticipation(now) -- Gather all visible units with their positions. Use Spring.GetAllUnits (spectator-safe). -- We batch-collect positions to avoid N*M GetUnitPosition calls. - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() if not allUnits or #allUnits == 0 then return end @@ -727,11 +727,11 @@ function pipTV.ScanAnticipation(now) for i = 1, #allUnits do local uID = allUnits[i] - local defID = Spring.GetUnitDefID(uID) + local defID = SpringShared.GetUnitDefID(uID) if defID then - local teamID = Spring.GetUnitTeam(uID) - local allyTeam = teamID and Spring.GetTeamAllyTeamID(teamID) - local x, _, z = Spring.GetUnitBasePosition(uID) + local teamID = SpringShared.GetUnitTeam(uID) + local allyTeam = teamID and SpringShared.GetTeamAllyTeamID(teamID) + local x, _, z = SpringShared.GetUnitBasePosition(uID) if x and allyTeam then -- Collect non-air ground/sea units for proximity checks (low-HP danger detection) if not cache.canFly[defID] then @@ -788,7 +788,7 @@ function pipTV.ScanAnticipation(now) -- Low-HP commanders (health < 50%) if cache.isCommander[defID] then - local hp, maxHP = Spring.GetUnitHealth(uID) + local hp, maxHP = SpringShared.GetUnitHealth(uID) if hp and maxHP and maxHP > 0 then local hpFrac = hp / maxHP if hpFrac < 0.5 then @@ -808,7 +808,7 @@ function pipTV.ScanAnticipation(now) -- Low-HP expensive eco buildings (health < 40%) if cache.isExpensiveEco[defID] then - local hp, maxHP = Spring.GetUnitHealth(uID) + local hp, maxHP = SpringShared.GetUnitHealth(uID) if hp and maxHP and maxHP > 0 then local hpFrac = hp / maxHP if hpFrac < 0.4 then @@ -906,18 +906,18 @@ function pipTV.DirectorTick(dt) -- When detected, signal effective game-over so Update() can trigger zoom-out if not dir.effectiveGameOver and now - dir.lastAliveCheck >= 2.0 then dir.lastAliveCheck = now - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() if gf > 30 * 30 then -- Only check after first 30 seconds (avoid false positive at spawn) - local gaiaAT = select(6, Spring.GetTeamInfo(Spring.GetGaiaTeamID())) + local gaiaAT = select(6, SpringShared.GetTeamInfo(SpringShared.GetGaiaTeamID())) local aliveCount = 0 - local allyTeams = Spring.GetAllyTeamList() + local allyTeams = SpringShared.GetAllyTeamList() for a = 1, #allyTeams do local atID = allyTeams[a] if atID ~= gaiaAT then -- Check if any team in this allyteam is still alive - local teams = Spring.GetTeamList(atID) + local teams = SpringShared.GetTeamList(atID) for t = 1, #teams do - local _, _, isDead = Spring.GetTeamInfo(teams[t], false) + local _, _, isDead = SpringShared.GetTeamInfo(teams[t], false) if not isDead then aliveCount = aliveCount + 1 break -- This allyteam is alive, move to next @@ -957,7 +957,7 @@ function pipTV.DirectorTick(dt) -- Time factor: 0→1 over first 2 minutes (baseline) -- Activity factor: 0→1 as peak hotspot weight reaches combat levels (~10+) -- Use whichever is higher — so early fights on small maps instantly ramp up - local gameFrame = Spring.GetGameFrame() + local gameFrame = SpringShared.GetGameFrame() local timeFactor = math.min(1, gameFrame / (30 * 60 * 2)) -- 0→1 over 2 minutes -- Track peak activity across all current hotspots @@ -1716,8 +1716,8 @@ local seismicPingDlists = { innerOutlines = {}, } local gameHasStarted -local gaiaTeamID = Spring.GetGaiaTeamID() -cache.gaiaAllyTeamID = select(6, Spring.GetTeamInfo(gaiaTeamID)) +local gaiaTeamID = SpringShared.GetGaiaTeamID() +cache.gaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(gaiaTeamID)) -- Build AI team lookup tables at load time -- aiTeams: all AI-controlled teams (for optional hiding) @@ -1730,13 +1730,13 @@ local scavRaptorTeams = {} local comNametagCache = { dirty = true, lastRefresh = 0 } do - local teamList = Spring.GetTeamList() + local teamList = SpringShared.GetTeamList() for i = 1, #teamList do local teamID = teamList[i] - local _, _, _, isAI = Spring.GetTeamInfo(teamID, false) + local _, _, _, isAI = SpringShared.GetTeamInfo(teamID, false) if isAI then aiTeams[teamID] = true - local luaAI = Spring.GetTeamLuaAI(teamID) or "" + local luaAI = SpringShared.GetTeamLuaAI(teamID) or "" if string.find(luaAI, "Scavenger") or string.find(luaAI, "Raptor") then scavRaptorTeams[teamID] = true end @@ -1835,36 +1835,36 @@ local glFunc = { -- Spring function speedups local spFunc = { - GetGroundHeight = Spring.GetGroundHeight, - GetUnitsInRectangle = Spring.GetUnitsInRectangle, - GetUnitPosition = Spring.GetUnitPosition, - GetUnitBasePosition = Spring.GetUnitBasePosition, - GetUnitTeam = Spring.GetUnitTeam, - GetUnitDefID = Spring.GetUnitDefID, - GetTeamInfo = Spring.GetTeamInfo, - IsPosInLos = Spring.IsPosInLos, - IsPosInRadar = Spring.IsPosInRadar, - GetUnitLosState = Spring.GetUnitLosState, - GetFeatureDefID = Spring.GetFeatureDefID, - GetFeatureDirection = Spring.GetFeatureDirection, - GetFeaturePosition = Spring.GetFeaturePosition, - GetFeatureTeam = Spring.GetFeatureTeam, - GetFeaturesInRectangle = Spring.GetFeaturesInRectangle, - IsUnitSelected = Spring.IsUnitSelected, - GetUnitHealth = Spring.GetUnitHealth, - GetMouseState = Spring.GetMouseState, - GetProjectilesInRectangle = Spring.GetProjectilesInRectangle, - GetProjectilePosition = Spring.GetProjectilePosition, - GetProjectileDefID = Spring.GetProjectileDefID, - GetProjectileTarget = Spring.GetProjectileTarget, - GetProjectileOwnerID = Spring.GetProjectileOwnerID, - GetProjectileVelocity = Spring.GetProjectileVelocity, - GetUnitCommands = Spring.GetUnitCommands, - GetPlayerInfo = Spring.GetPlayerInfo, - GetUnitIsStunned = Spring.GetUnitIsStunned, - GetTeamAllyTeamID = Spring.GetTeamAllyTeamID, - GetUnitSelfDTime = Spring.GetUnitSelfDTime, - GetSelectedUnitsCount = Spring.GetSelectedUnitsCount, + GetGroundHeight = SpringShared.GetGroundHeight, + GetUnitsInRectangle = SpringShared.GetUnitsInRectangle, + GetUnitPosition = SpringShared.GetUnitPosition, + GetUnitBasePosition = SpringShared.GetUnitBasePosition, + GetUnitTeam = SpringShared.GetUnitTeam, + GetUnitDefID = SpringShared.GetUnitDefID, + GetTeamInfo = SpringShared.GetTeamInfo, + IsPosInLos = SpringShared.IsPosInLos, + IsPosInRadar = SpringShared.IsPosInRadar, + GetUnitLosState = SpringShared.GetUnitLosState, + GetFeatureDefID = SpringShared.GetFeatureDefID, + GetFeatureDirection = SpringShared.GetFeatureDirection, + GetFeaturePosition = SpringShared.GetFeaturePosition, + GetFeatureTeam = SpringShared.GetFeatureTeam, + GetFeaturesInRectangle = SpringShared.GetFeaturesInRectangle, + IsUnitSelected = SpringUnsynced.IsUnitSelected, + GetUnitHealth = SpringShared.GetUnitHealth, + GetMouseState = SpringUnsynced.GetMouseState, + GetProjectilesInRectangle = SpringShared.GetProjectilesInRectangle, + GetProjectilePosition = SpringShared.GetProjectilePosition, + GetProjectileDefID = SpringShared.GetProjectileDefID, + GetProjectileTarget = SpringShared.GetProjectileTarget, + GetProjectileOwnerID = SpringShared.GetProjectileOwnerID, + GetProjectileVelocity = SpringShared.GetProjectileVelocity, + GetUnitCommands = SpringShared.GetUnitCommands, + GetPlayerInfo = SpringShared.GetPlayerInfo, + GetUnitIsStunned = SpringShared.GetUnitIsStunned, + GetTeamAllyTeamID = SpringShared.GetTeamAllyTeamID, + GetUnitSelfDTime = SpringShared.GetUnitSelfDTime, + GetSelectedUnitsCount = SpringUnsynced.GetSelectedUnitsCount, } -- Map/game constants @@ -1886,8 +1886,8 @@ do isLava = false, voidWater = voidWater, } - mapInfo.minGroundHeight, mapInfo.maxGroundHeight = Spring.GetGroundExtremes() - local waterIsLava = Spring.GetModOptions().map_waterislava + mapInfo.minGroundHeight, mapInfo.maxGroundHeight = SpringShared.GetGroundExtremes() + local waterIsLava = SpringShared.GetModOptions().map_waterislava mapInfo.isLava = Spring.Lava.isLavaMap or (waterIsLava and waterIsLava ~= 0 and waterIsLava ~= "0") end mapInfo.hasWater = mapInfo.minGroundHeight < 0 or mapInfo.isLava @@ -1974,7 +1974,7 @@ end -- Eagerly read lava level if available (avoids wrong first R2T render on lava maps) if mapInfo.isLava or mapInfo.hasWater then - local initLavaLevel = Spring.GetGameRulesParam("lavaLevel") + local initLavaLevel = SpringShared.GetGameRulesParam("lavaLevel") if initLavaLevel and initLavaLevel ~= -99999 then mapInfo.dynamicWaterLevel = initLavaLevel end @@ -1989,8 +1989,8 @@ local buttons = { tooltipKey = "ui.pip.copy", command = "pip_copy", OnPress = function() - local sizex, sizez = Spring.GetWindowGeometry() - local _, pos = Spring.TraceScreenRay(sizex / 2, sizez / 2, true) + local sizex, sizez = SpringUnsynced.GetWindowGeometry() + local _, pos = SpringUnsynced.TraceScreenRay(sizex / 2, sizez / 2, true) if pos and pos[2] > -10000 then -- Set PIP camera to main camera position with rounding to match switch behavior local copiedX = math.floor(pos[1] + 0.5) @@ -2018,8 +2018,8 @@ local buttons = { tooltipKey = "ui.pip.switch", command = "pip_switch", OnPress = function() - local sizex, sizez = Spring.GetWindowGeometry() - local _, pos = Spring.TraceScreenRay(sizex / 2, sizez / 2, true) + local sizex, sizez = SpringUnsynced.GetWindowGeometry() + local _, pos = SpringUnsynced.TraceScreenRay(sizex / 2, sizez / 2, true) if pos and pos[2] > -10000 then -- Always read the current main camera position local mainCamX = math.floor(pos[1] + 0.5) @@ -2046,14 +2046,14 @@ local buttons = { end -- First untrack anything in main view - Spring.SendCommands("track") + SpringUnsynced.SendCommands("track") -- Then track the PIP units in main view for i = 1, #interactionState.areTracking do - Spring.SendCommands("track " .. interactionState.areTracking[i]) + SpringUnsynced.SendCommands("track " .. interactionState.areTracking[i]) end else -- If not tracking in PIP or feature disabled, untrack in main view - Spring.SendCommands("track") + SpringUnsynced.SendCommands("track") end -- Swap tracking state: current PIP tracking <-> backup @@ -2079,7 +2079,7 @@ local buttons = { camX = currentPipCamX, camZ = currentPipCamZ, } -- Switch camera positions - use rounded coordinates - Spring.SetCameraTarget(pipCameraTargetX, 0, pipCameraTargetZ, config.switchTransitionTime) + SpringUnsynced.SetCameraTarget(pipCameraTargetX, 0, pipCameraTargetZ, config.switchTransitionTime) -- Set PIP camera target for smooth transition (don't set cameraState.wcx/cameraState.wcz directly) cameraState.targetWcx, cameraState.targetWcz = mainCamX, mainCamZ miscState.isSwitchingViews = true -- Enable fast transition for pip_switch @@ -2088,7 +2088,7 @@ local buttons = { -- If feature is disabled, ensure main camera is not tracking if not config.switchInheritsTracking then - Spring.SendCommands("track") + SpringUnsynced.SendCommands("track") end end end, @@ -2099,7 +2099,7 @@ local buttons = { tooltipActiveKey = "ui.pip.untrack", command = "pip_track", OnPress = function() - local selectedUnits = Spring.GetSelectedUnits() + local selectedUnits = SpringUnsynced.GetSelectedUnits() if #selectedUnits > 0 then -- Add selected units to tracking (or start tracking if not already) if interactionState.areTracking then @@ -2158,17 +2158,17 @@ local buttons = { ghostBuildings[k] = nil end local scanAllyTeam = state.losViewAllyTeam - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for _, uID in ipairs(allUnits) do - local defID = Spring.GetUnitDefID(uID) + local defID = SpringShared.GetUnitDefID(uID) if defID and cache.isBuilding[defID] then - local uTeam = Spring.GetUnitTeam(uID) - local uAllyTeam = Spring.GetTeamAllyTeamID(uTeam) + local uTeam = SpringShared.GetUnitTeam(uID) + local uAllyTeam = SpringShared.GetTeamAllyTeamID(uTeam) if uAllyTeam ~= scanAllyTeam then -- Only ghost buildings the viewed allyteam has ever seen - local losBits = Spring.GetUnitLosState(uID, scanAllyTeam, true) + local losBits = SpringShared.GetUnitLosState(uID, scanAllyTeam, true) if losBits and (losBits % 2 >= 1 or losBits % 8 >= 4) then - local x, _, z = Spring.GetUnitBasePosition(uID) + local x, _, z = SpringShared.GetUnitBasePosition(uID) if x then ghostBuildings[uID] = { defID = defID, x = x, z = z, teamID = uTeam } end @@ -2905,11 +2905,11 @@ void main() { local teamColors = {} local teamAllyTeamCache = {} -- teamID -> allyTeamID mapping (avoids per-unit GetTeamInfo calls) -local teamList = Spring.GetTeamList() +local teamList = SpringShared.GetTeamList() for i = 1, #teamList do local tID = teamList[i] - teamColors[tID] = { Spring.GetTeamColor(tID) } - teamAllyTeamCache[tID] = select(6, Spring.GetTeamInfo(tID, false)) + teamColors[tID] = { SpringUnsynced.GetTeamColor(tID) } + teamAllyTeamCache[tID] = select(6, SpringShared.GetTeamInfo(tID, false)) end ---------------------------------------------------------------------------------------------------- @@ -3302,24 +3302,24 @@ local function InitGL4Icons() end if not gl.GetVAO or not gl.GetVBO then - Spring.Echo("[PIP] GL4 icons: VAO/VBO not available, falling back to legacy") + SpringShared.Echo("[PIP] GL4 icons: VAO/VBO not available, falling back to legacy") return end - if not Spring.GetIconData then - Spring.Echo("[PIP] GL4 icons: Spring.GetIconData not available, falling back to legacy") + if not SpringUnsynced.GetIconData then + SpringShared.Echo("[PIP] GL4 icons: Spring.GetIconData not available, falling back to legacy") return end - local defaultIconData = Spring.GetIconData("default") + local defaultIconData = SpringUnsynced.GetIconData("default") if not defaultIconData or not defaultIconData.atlasTexCoords then - Spring.Echo("[PIP] GL4 icons: Engine icon atlas data not available, falling back to legacy") + SpringShared.Echo("[PIP] GL4 icons: Engine icon atlas data not available, falling back to legacy") return end local iconsTexInfo = gl.TextureInfo("$icons") if not iconsTexInfo or iconsTexInfo.xsize <= 0 then - Spring.Echo("[PIP] GL4 icons: $icons texture not available, falling back to legacy") + SpringShared.Echo("[PIP] GL4 icons: $icons texture not available, falling back to legacy") return end @@ -3328,7 +3328,7 @@ local function InitGL4Icons() for uDefID, uDef in pairs(UnitDefs) do local iconName = uDef.iconType or "default" - local iconInfo = Spring.GetIconData(iconName) + local iconInfo = SpringUnsynced.GetIconData(iconName) if iconInfo and iconInfo.atlasTexCoords then local atc = iconInfo.atlasTexCoords gl4Icons.atlasUVs[uDefID] = { atc.x0, atc.y1, atc.x1, atc.y0 } @@ -3349,7 +3349,7 @@ local function InitGL4Icons() } local vbo = gl.GetVBO(GL.ARRAY_BUFFER, true) if not vbo then - Spring.Echo("[PIP] GL4 icons: Failed to create VBO") + SpringShared.Echo("[PIP] GL4 icons: Failed to create VBO") gl4Icons.atlas = nil return end @@ -3366,7 +3366,7 @@ local function InitGL4Icons() -- Create VAO: attach VBO as vertex buffer (geometry shader expands points → quads) local vao = gl.GetVAO() if not vao then - Spring.Echo("[PIP] GL4 icons: Failed to create VAO") + SpringShared.Echo("[PIP] GL4 icons: Failed to create VAO") vbo:Delete() gl4Icons.atlas = nil gl4Icons.vbo = nil @@ -3379,7 +3379,7 @@ local function InitGL4Icons() -- Buildings rarely change, so this VBO is uploaded much less frequently than the mobile VBO. local bldgVbo = gl.GetVBO(GL.ARRAY_BUFFER, true) if not bldgVbo then - Spring.Echo("[PIP] GL4 icons: Failed to create building VBO") + SpringShared.Echo("[PIP] GL4 icons: Failed to create building VBO") vao:Delete() vbo:Delete() gl4Icons.atlas = nil @@ -3390,7 +3390,7 @@ local function InitGL4Icons() bldgVbo:Define(gl4Icons.MAX_INSTANCES, vboLayout) local bldgVao = gl.GetVAO() if not bldgVao then - Spring.Echo("[PIP] GL4 icons: Failed to create building VAO") + SpringShared.Echo("[PIP] GL4 icons: Failed to create building VAO") bldgVbo:Delete() vao:Delete() vbo:Delete() @@ -3414,7 +3414,7 @@ local function InitGL4Icons() -- Ground units move slowly, so this VBO is updated less frequently than the fast mobile VBO. local slowVbo = gl.GetVBO(GL.ARRAY_BUFFER, true) if not slowVbo then - Spring.Echo("[PIP] GL4 icons: Failed to create slow mobile VBO") + SpringShared.Echo("[PIP] GL4 icons: Failed to create slow mobile VBO") bldgVao:Delete() bldgVbo:Delete() vao:Delete() @@ -3429,7 +3429,7 @@ local function InitGL4Icons() slowVbo:Define(gl4Icons.MAX_INSTANCES, vboLayout) local slowVao = gl.GetVAO() if not slowVao then - Spring.Echo("[PIP] GL4 icons: Failed to create slow mobile VAO") + SpringShared.Echo("[PIP] GL4 icons: Failed to create slow mobile VAO") slowVbo:Delete() bldgVao:Delete() bldgVbo:Delete() @@ -3456,7 +3456,7 @@ local function InitGL4Icons() -- Compile shader local shader = gl.CreateShader(gl4Icons.shaderCode) if not shader then - Spring.Echo("[PIP] GL4 icons: Shader compilation failed: " .. tostring(gl.GetShaderLog())) + SpringShared.Echo("[PIP] GL4 icons: Shader compilation failed: " .. tostring(gl.GetShaderLog())) vao:Delete() vbo:Delete() gl4Icons.atlas = nil @@ -3652,7 +3652,7 @@ local function InitGL4Primitives() -- Compile shaders local cShader = gl.CreateShader(gl4Prim.circleShaderCode) if not cShader then - Spring.Echo("[PIP] GL4 circle shader failed: " .. tostring(gl.GetShaderLog())) + SpringShared.Echo("[PIP] GL4 circle shader failed: " .. tostring(gl.GetShaderLog())) -- cleanup all nlVao:Delete() nlVbo:Delete() @@ -3670,7 +3670,7 @@ local function InitGL4Primitives() local qShader = gl.CreateShader(gl4Prim.quadShaderCode) if not qShader then - Spring.Echo("[PIP] GL4 quad shader failed: " .. tostring(gl.GetShaderLog())) + SpringShared.Echo("[PIP] GL4 quad shader failed: " .. tostring(gl.GetShaderLog())) gl.DeleteShader(cShader) nlVao:Delete() nlVbo:Delete() @@ -3688,7 +3688,7 @@ local function InitGL4Primitives() local lShader = gl.CreateShader(gl4Prim.lineShaderCode) if not lShader then - Spring.Echo("[PIP] GL4 line shader failed: " .. tostring(gl.GetShaderLog())) + SpringShared.Echo("[PIP] GL4 line shader failed: " .. tostring(gl.GetShaderLog())) gl.DeleteShader(qShader) gl.DeleteShader(cShader) nlVao:Delete() @@ -4384,7 +4384,7 @@ local function UpdateCentering(mx, my) return end - local _, pos = Spring.TraceScreenRay(mx, my, true) + local _, pos = SpringUnsynced.TraceScreenRay(mx, my, true) if pos and pos[2] > -10000 then cameraState.wcx, cameraState.wcz = pos[1], pos[3] cameraState.targetWcx, cameraState.targetWcz = cameraState.wcx, cameraState.wcz -- Set targets instantly for centering @@ -4453,7 +4453,7 @@ local function GetAliveTeammates() end local teammates = {} - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for _, playerID in ipairs(playerList) do if playerID ~= myPlayerID then @@ -4485,7 +4485,7 @@ local function FindNextBestTeamPlayer(excludePlayerID) end -- Find all active players on the same allyteam - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() local candidatePlayers = {} for _, playerID in ipairs(playerList) do @@ -4676,7 +4676,7 @@ end local function PipToWorldCoords(mx, my) -- Get current minimap rotation (must fetch fresh, not use cached render.minimapRotation) - local minimapRotation = Spring.GetMiniMapRotation and Spring.GetMiniMapRotation() or 0 + local minimapRotation = SpringUnsynced.GetMiniMapRotation and SpringUnsynced.GetMiniMapRotation() or 0 -- Convert screen coordinates to normalized PIP coordinates (0-1) local normX = (mx - render.dim.l) / (render.dim.r - render.dim.l) @@ -5506,7 +5506,7 @@ local function DrawProjectile(pID) local trailColor = inPlasmaViewport and not skipProjectileTrails and config.drawPlasmaTrails and cache.weaponPlasmaTrailColor[pDefID] if trailColor then local trail = cache.plasmaTrails[pID] - local gameFrame = Spring.GetGameFrame() + local gameFrame = SpringShared.GetGameFrame() if not trail then -- Short ring buffer: 6 slots for max ~4 visible line segments local projSpeed = 10 @@ -6150,7 +6150,7 @@ local function ExpireExplosions() if n == 0 then return end - local currentFrame = Spring.GetGameFrame() + local currentFrame = SpringShared.GetGameFrame() local i = 1 while i <= n do local explosion = cache.explosions[i] @@ -6230,7 +6230,7 @@ local function DrawExplosions() end end - local currentFrame = Spring.GetGameFrame() + local currentFrame = SpringShared.GetGameFrame() local n = #cache.explosions while i <= n do @@ -6460,7 +6460,7 @@ local function DrawExplosionOverlay() return end - local currentFrame = Spring.GetGameFrame() + local currentFrame = SpringShared.GetGameFrame() -- When LOS view is active, hide explosions outside the viewed allyteam's LOS local expLosAlly = state.losViewEnabled and state.losViewAllyTeam or nil @@ -6775,7 +6775,7 @@ local function GiveNotifyingOrder(cmdID, cmdParams, cmdOpts) return end - Spring.GiveOrder(cmdID, cmdParams, cmdOpts.coded) + SpringUnsynced.GiveOrder(cmdID, cmdParams, cmdOpts.coded) end local function GetBuildingDimensions(uDefID, facing) @@ -6802,7 +6802,7 @@ local function FindMyCommander() return nil end - local teamUnits = Spring.GetTeamUnits(myTeamID) + local teamUnits = SpringShared.GetTeamUnits(myTeamID) if not teamUnits then return nil end @@ -6830,14 +6830,14 @@ local function CalculateBuildDragPositions(startWX, startWZ, endWX, endWZ, build for i = #pools.buildPositions, 1, -1 do pools.buildPositions[i] = nil end - local buildFacing = Spring.GetBuildFacing() + local buildFacing = SpringUnsynced.GetBuildFacing() local buildWidth, buildHeight = GetBuildingDimensions(buildDefID, buildFacing) -- Snap ONLY the start position - this becomes our anchor - local sx, sy, sz = Spring.Pos2BuildPos(buildDefID, startWX, spFunc.GetGroundHeight(startWX, startWZ), startWZ) + local sx, sy, sz = SpringShared.Pos2BuildPos(buildDefID, startWX, spFunc.GetGroundHeight(startWX, startWZ), startWZ) -- For end position, snap it too to know the intended area - local ex, ey, ez = Spring.Pos2BuildPos(buildDefID, endWX, spFunc.GetGroundHeight(endWX, endWZ), endWZ) + local ex, ey, ez = SpringShared.Pos2BuildPos(buildDefID, endWX, spFunc.GetGroundHeight(endWX, endWZ), endWZ) -- Calculate direction and distance local dx = ex - sx @@ -6897,7 +6897,7 @@ local function CalculateBuildDragPositions(startWX, startWZ, endWX, endWZ, build local testZ = sz + dirZ * searchDist -- Snap this test position - local snappedX, _, snappedZ = Spring.Pos2BuildPos(buildDefID, testX, spFunc.GetGroundHeight(testX, testZ), testZ) + local snappedX, _, snappedZ = SpringShared.Pos2BuildPos(buildDefID, testX, spFunc.GetGroundHeight(testX, testZ), testZ) -- Check distance from last placed building local lastPos = positions[#positions] @@ -6945,7 +6945,7 @@ local function CalculateBuildDragPositions(startWX, startWZ, endWX, endWZ, build local wz = minZ + row * spacingZ -- Snap each position to engine's build grid - local snappedX, _, snappedZ = Spring.Pos2BuildPos(buildDefID, wx, spFunc.GetGroundHeight(wx, wz), wz) + local snappedX, _, snappedZ = SpringShared.Pos2BuildPos(buildDefID, wx, spFunc.GetGroundHeight(wx, wz), wz) -- Check if this snapped position is too close to a previous one (engine would reject it) local tooClose = false @@ -6984,7 +6984,7 @@ local function CalculateBuildDragPositions(startWX, startWZ, endWX, endWZ, build local wz = minZ + row * spacingZ -- Snap each position to engine's build grid - local snappedX, _, snappedZ = Spring.Pos2BuildPos(buildDefID, wx, spFunc.GetGroundHeight(wx, wz), wz) + local snappedX, _, snappedZ = SpringShared.Pos2BuildPos(buildDefID, wx, spFunc.GetGroundHeight(wx, wz), wz) -- Check if too close to previous local tooClose = false @@ -7064,7 +7064,7 @@ end local function IssueCommandAtPoint(cmdID, wx, wz, usingRMB, forceQueue, radius) - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() -- Force queue commands when explicitly requested (e.g., during formation drags) if forceQueue then shift = true @@ -7080,21 +7080,21 @@ local function IssueCommandAtPoint(cmdID, wx, wz, usingRMB, forceQueue, radius) -- For ATTACK command, only target if it's an enemy unit if id and cmdID == CMD.ATTACK then - if Spring.IsUnitAllied(id) then + if SpringUnsynced.IsUnitAllied(id) then id = nil -- Don't target allied units with ATTACK, use ground position instead end end -- For area RECLAIM command (radius > 0), don't target enemy units if id and cmdID == CMD.RECLAIM and radius and radius > 0 then - if not Spring.IsUnitAllied(id) then + if not SpringUnsynced.IsUnitAllied(id) then id = nil -- Don't target enemy units with area RECLAIM end end -- For area REPAIR command (radius > 0), don't target enemy units if id and cmdID == CMD.REPAIR and radius and radius > 0 then - if not Spring.IsUnitAllied(id) then + if not SpringUnsynced.IsUnitAllied(id) then id = nil -- Don't target enemy units with area REPAIR end end @@ -7103,7 +7103,7 @@ local function IssueCommandAtPoint(cmdID, wx, wz, usingRMB, forceQueue, radius) if id then -- For LOAD_UNITS command, give order only to transport units if cmdID == CMD.LOAD_UNITS then - local selectedUnits = Spring.GetSelectedUnits() + local selectedUnits = SpringUnsynced.GetSelectedUnits() local transports = {} -- Collect all transport units (using cache) @@ -7121,12 +7121,12 @@ local function IssueCommandAtPoint(cmdID, wx, wz, usingRMB, forceQueue, radius) -- Use a small radius area command so transports will find different nearby units local smallRadius = 150 for i = 1, #transports do - Spring.GiveOrderToUnit(transports[i], cmdID, { ux, uy, uz, smallRadius }, cmdOpts.coded) + SpringSynced.GiveOrderToUnit(transports[i], cmdID, { ux, uy, uz, smallRadius }, cmdOpts.coded) end end else -- Single transport, give direct unit target - Spring.GiveOrderToUnit(transports[1], cmdID, { id }, cmdOpts.coded) + SpringSynced.GiveOrderToUnit(transports[1], cmdID, { id }, cmdOpts.coded) end end else @@ -7145,14 +7145,14 @@ local function IssueCommandAtPoint(cmdID, wx, wz, usingRMB, forceQueue, radius) if radius and radius > 0 then -- For area LOAD_UNITS command, give order only to transport units individually if cmdID == CMD.LOAD_UNITS then - local selectedUnits = Spring.GetSelectedUnits() + local selectedUnits = SpringUnsynced.GetSelectedUnits() -- Give order to each transport unit individually (using cache) -- This allows the engine to distribute targets naturally across multiple transports for i = 1, #selectedUnits do local unitDefID = spFunc.GetUnitDefID(selectedUnits[i]) if unitDefID and cache.isTransport[unitDefID] and (cache.transportCapacity[unitDefID] or 0) > 0 then - Spring.GiveOrderToUnit(selectedUnits[i], cmdID, { wx, spFunc.GetGroundHeight(wx, wz), wz, radius }, cmdOpts.coded) + SpringSynced.GiveOrderToUnit(selectedUnits[i], cmdID, { wx, spFunc.GetGroundHeight(wx, wz), wz, radius }, cmdOpts.coded) end end else @@ -7206,7 +7206,7 @@ local function IssueCommandAtPoint(cmdID, wx, wz, usingRMB, forceQueue, radius) -- Regular building - just pass the position as-is (no additional snapping) -- The position should already be snapped from CalculateBuildDragPositions - GiveNotifyingOrder(cmdID, { wx, spFunc.GetGroundHeight(wx, wz), wz, Spring.GetBuildFacing() }, cmdOpts) + GiveNotifyingOrder(cmdID, { wx, spFunc.GetGroundHeight(wx, wz), wz, SpringUnsynced.GetBuildFacing() }, cmdOpts) end end end @@ -7354,7 +7354,7 @@ local function RegisterMinimapWGAPI() return math.floor(config.minimapModeMaxHeight * render.vsy), config.minimapModeMaxHeight end WG["minimap"].setMaxHeight = function(value) - Spring.SetConfigFloat("MinimapMaxHeight", value) + SpringUnsynced.SetConfigFloat("MinimapMaxHeight", value) config.minimapModeMaxHeight = value widget:ViewResize() end @@ -7363,7 +7363,7 @@ local function RegisterMinimapWGAPI() end WG["minimap"].setLeftClickMove = function(value) config.leftButtonPansCamera = value - Spring.SetConfigInt("MinimapLeftClickMove", value and 1 or 0) + SpringUnsynced.SetConfigInt("MinimapLeftClickMove", value and 1 or 0) end WG["minimap"].isPipMinimapActive = function() return true @@ -7402,11 +7402,11 @@ local function RegisterMinimapWGAPI() if not value and miscState.engineMinimapActive then -- Turning off fallback while engine minimap is showing: restore icon scale and re-minimize if miscState.baseMinimapIconScale then - Spring.SendCommands("minimap unitsize " .. miscState.baseMinimapIconScale) - Spring.SetConfigFloat("MinimapIconScale", miscState.baseMinimapIconScale) + SpringUnsynced.SendCommands("minimap unitsize " .. miscState.baseMinimapIconScale) + SpringUnsynced.SetConfigFloat("MinimapIconScale", miscState.baseMinimapIconScale) miscState.baseMinimapIconScale = nil end - Spring.SendCommands("minimap minimize 1") + SpringUnsynced.SendCommands("minimap minimize 1") miscState.engineMinimapActive = false pipR2T.contentNeedsUpdate = true pipR2T.unitsNeedsUpdate = true @@ -7588,8 +7588,8 @@ function widget:Initialize() -- Initialize LOS shader for red-to-greyscale conversion shaders.los = gl.CreateShader(shaders.losCode) if not shaders.los then - Spring.Echo("PIP: Failed to compile LOS shader, LOS overlay will be disabled") - Spring.Echo("PIP: Shader log: " .. (gl.GetShaderLog() or "no log")) + SpringShared.Echo("PIP: Failed to compile LOS shader, LOS overlay will be disabled") + SpringShared.Echo("PIP: Shader log: " .. (gl.GetShaderLog() or "no log")) if pipR2T.losTex then gl.DeleteTexture(pipR2T.losTex) pipR2T.losTex = nil @@ -7599,8 +7599,8 @@ function widget:Initialize() -- Initialize decal overlay shader + GL4 VBO/VAO shaders.decal = gl.CreateShader(shaders.decalCode) if not shaders.decal then - Spring.Echo("PIP: Failed to compile decal shader") - Spring.Echo("PIP: Shader log: " .. (gl.GetShaderLog() or "no log")) + SpringShared.Echo("PIP: Failed to compile decal shader") + SpringShared.Echo("PIP: Shader log: " .. (gl.GetShaderLog() or "no log")) else InitGL4Decals() end @@ -7612,23 +7612,23 @@ function widget:Initialize() strength = gl.GetUniformLocation(shaders.decalBlit, "strength"), } else - Spring.Echo("PIP: Failed to compile decal blit shader") - Spring.Echo("PIP: Shader log: " .. (gl.GetShaderLog() or "no log")) + SpringShared.Echo("PIP: Failed to compile decal blit shader") + SpringShared.Echo("PIP: Shader log: " .. (gl.GetShaderLog() or "no log")) end -- Initialize minimap+shading compositing shader shaders.minimapShading = gl.CreateShader(shaders.minimapShadingCode) if not shaders.minimapShading then - Spring.Echo("PIP: Failed to compile minimap shading shader") - Spring.Echo("PIP: Shader log: " .. (gl.GetShaderLog() or "no log")) + SpringShared.Echo("PIP: Failed to compile minimap shading shader") + SpringShared.Echo("PIP: Shader log: " .. (gl.GetShaderLog() or "no log")) end -- Initialize water shader if map has water if mapInfo.hasWater then shaders.water = gl.CreateShader(shaders.waterCode) if not shaders.water then - Spring.Echo("PIP: Failed to compile water shader") - Spring.Echo("PIP: Shader log: " .. (gl.GetShaderLog() or "no log")) + SpringShared.Echo("PIP: Failed to compile water shader") + SpringShared.Echo("PIP: Shader log: " .. (gl.GetShaderLog() or "no log")) end end @@ -7767,8 +7767,8 @@ function widget:Initialize() end end - gameHasStarted = (Spring.GetGameFrame() > 0) - miscState.startX, _, miscState.startZ = Spring.GetTeamStartPosition(Spring.GetMyTeamID()) + gameHasStarted = (SpringShared.GetGameFrame() > 0) + miscState.startX, _, miscState.startZ = SpringShared.GetTeamStartPosition(Spring.GetMyTeamID()) -- Initialize GL4 instanced icon rendering (after cache is built so unitIcon data is available) InitGL4Icons() @@ -7795,7 +7795,7 @@ function widget:Initialize() -- For spectators with LOS view, also pre-scan to populate ghosts on reload do local initScanAllyTeam = nil - local initScanIsSpec, initScanFullview = Spring.GetSpectatingState() + local initScanIsSpec, initScanFullview = SpringUnsynced.GetSpectatingState() if not initScanIsSpec then initScanAllyTeam = Spring.GetMyAllyTeamID() elseif state.losViewEnabled and state.losViewAllyTeam then @@ -7805,25 +7805,25 @@ function widget:Initialize() initScanAllyTeam = Spring.GetMyAllyTeamID() end if initScanAllyTeam then - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for _, uID in ipairs(allUnits) do - local defID = Spring.GetUnitDefID(uID) + local defID = SpringShared.GetUnitDefID(uID) if defID and cache.isBuilding[defID] then - local uTeam = Spring.GetUnitTeam(uID) - local uAllyTeam = Spring.GetTeamAllyTeamID(uTeam) + local uTeam = SpringShared.GetUnitTeam(uID) + local uAllyTeam = SpringShared.GetTeamAllyTeamID(uTeam) if uAllyTeam ~= initScanAllyTeam then if initScanIsSpec then -- As spectator, only ghost buildings the viewed allyteam has ever seen - local losBits = Spring.GetUnitLosState(uID, initScanAllyTeam, true) + local losBits = SpringShared.GetUnitLosState(uID, initScanAllyTeam, true) if losBits and (losBits % 2 >= 1 or losBits % 8 >= 4) then - local x, _, z = Spring.GetUnitBasePosition(uID) + local x, _, z = SpringShared.GetUnitBasePosition(uID) if x then ghostBuildings[uID] = { defID = defID, x = x, z = z, teamID = uTeam } end end else -- As player, we can see all units returned (only own-LOS units are returned) - local x, _, z = Spring.GetUnitBasePosition(uID) + local x, _, z = SpringShared.GetUnitBasePosition(uID) if x then ghostBuildings[uID] = { defID = defID, x = x, z = z, teamID = uTeam } end @@ -7836,7 +7836,7 @@ function widget:Initialize() -- For spectators, center on map and zoom out more (always on new game, even if has saved config) do - local currentGameID = Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID") + local currentGameID = Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID") local isNewGame = not miscState.savedGameID or miscState.savedGameID ~= currentGameID if isSpectator and isNewGame then -- Center on map @@ -7865,14 +7865,14 @@ function widget:Initialize() -- Minimap mode: hide the engine minimap since we're replacing it if isMinimapMode then -- Store original minimap geometry and minimize state for restoration on shutdown - miscState.oldMinimapGeometry = Spring.GetMiniMapGeometry() - miscState.oldMinimapMinimized = Spring.GetConfigInt("MinimapMinimize", 0) - miscState.oldMinimapDrawPings = Spring.GetConfigInt("MiniMapDrawPings", 1) + miscState.oldMinimapGeometry = SpringUnsynced.GetMiniMapGeometry() + miscState.oldMinimapMinimized = SpringUnsynced.GetConfigInt("MinimapMinimize", 0) + miscState.oldMinimapDrawPings = SpringUnsynced.GetConfigInt("MiniMapDrawPings", 1) -- Fully hide the engine minimap: slave it so it only renders when we call gl.DrawMiniMap() (which we don't) - Spring.SendCommands("minimap minimize 1") + SpringUnsynced.SendCommands("minimap minimize 1") gl.SlaveMiniMap(true) -- Disable engine minimap pings (the PIP draws its own) - Spring.SetConfigInt("MiniMapDrawPings", 0) + SpringUnsynced.SetConfigInt("MiniMapDrawPings", 0) -- Disable the gui_minimap widget if it's running (we're replacing it) -- Use FindWidget which works reliably during luaui reload if widgetHandler:FindWidget("Minimap") then @@ -8023,8 +8023,8 @@ function widget:Initialize() -- Bind per-pip hotkey if configured if button.keybind then - Spring.SendCommands("unbindkeyset " .. button.keybind) - Spring.SendCommands("bind " .. button.keybind .. " " .. button.actionName) + SpringUnsynced.SendCommands("unbindkeyset " .. button.keybind) + SpringUnsynced.SendCommands("bind " .. button.keybind .. " " .. button.actionName) end end end @@ -8038,7 +8038,7 @@ function widget:ViewResize() font = WG["fonts"].getFont(2) local oldVsx, oldVsy = render.vsx, render.vsy - render.vsx, render.vsy = Spring.GetViewGeometry() + render.vsx, render.vsy = SpringUnsynced.GetViewGeometry() -- In minimap mode, calculate position and size like the minimap widget does if isMinimapMode then @@ -8050,7 +8050,7 @@ function widget:ViewResize() -- Get current rotation to determine if dimensions should be swapped -- When rotation is 90° or 270°, the map appears rotated so width/height swap visually - local minimapRotation = Spring.GetMiniMapRotation and Spring.GetMiniMapRotation() or 0 + local minimapRotation = SpringUnsynced.GetMiniMapRotation and SpringUnsynced.GetMiniMapRotation() or 0 render.minimapRotation = minimapRotation render.lastMinimapRotation = minimapRotation @@ -8202,7 +8202,7 @@ function widget:ViewResize() render.dim.l, render.dim.r, render.dim.b, render.dim.t = render.dim.l / oldVsx, render.dim.r / oldVsx, render.dim.b / oldVsy, render.dim.t / oldVsy else -- Initialize with default values positioned in upper-right area of screen - Spring.Echo("PIP: Detected invalid dimensions, resetting to default position") + SpringShared.Echo("PIP: Detected invalid dimensions, resetting to default position") render.dim.l = 0.7 render.dim.r = 0.7 + (config.minPanelSize * render.widgetScale * 1.4) / render.vsx render.dim.b = 0.7 @@ -8279,7 +8279,7 @@ function widget:ViewResize() if savedDimsValid then -- Position based on where the window was (same logic as manual minimize) - local sw, sh = Spring.GetWindowGeometry() + local sw, sh = SpringUnsynced.GetWindowGeometry() if uiState.savedDimensions.l < sw * 0.5 then uiState.minModeL = uiState.savedDimensions.l else @@ -8384,7 +8384,7 @@ function widget:ViewResize() if miscState.engineMinimapActive then local w = render.dim.r - render.dim.l local h = render.dim.t - render.dim.b - Spring.SendCommands(string.format("minimap geometry %d %d %d %d", math.floor(render.dim.l), math.floor(render.vsy - render.dim.t), math.floor(w), math.floor(h))) + SpringUnsynced.SendCommands(string.format("minimap geometry %d %d %d %d", math.floor(render.dim.l), math.floor(render.vsy - render.dim.t), math.floor(w), math.floor(h))) end -- Force several frames of re-rendering so engine textures ($minimap, $shading) @@ -8403,7 +8403,7 @@ function widget:PlayerChanged(playerID) miscState.cachedTakeableTeams = nil -- Update spec state - cameraState.mySpecState = Spring.GetSpectatingState() + cameraState.mySpecState = SpringUnsynced.GetSpectatingState() -- Don't clear ghost buildings here: PlayerChanged fires frequently (on any player's -- state change, team switches, etc.) and clearing ghosts causes them to vanish. @@ -8582,20 +8582,20 @@ function widget:Shutdown() gl.SlaveMiniMap(false) -- Restore original icon scale if engine fallback was active if miscState.baseMinimapIconScale then - Spring.SendCommands("minimap unitsize " .. miscState.baseMinimapIconScale) - Spring.SetConfigFloat("MinimapIconScale", miscState.baseMinimapIconScale) + SpringUnsynced.SendCommands("minimap unitsize " .. miscState.baseMinimapIconScale) + SpringUnsynced.SetConfigFloat("MinimapIconScale", miscState.baseMinimapIconScale) miscState.baseMinimapIconScale = nil end -- Restore original minimize state if miscState.oldMinimapMinimized == 0 then - Spring.SendCommands("minimap minimize 0") + SpringUnsynced.SendCommands("minimap minimize 0") end if miscState.oldMinimapGeometry then - Spring.SendCommands("minimap geometry " .. miscState.oldMinimapGeometry) + SpringUnsynced.SendCommands("minimap geometry " .. miscState.oldMinimapGeometry) end -- Restore original MiniMapDrawPings if miscState.oldMinimapDrawPings then - Spring.SetConfigInt("MiniMapDrawPings", miscState.oldMinimapDrawPings) + SpringUnsynced.SetConfigInt("MiniMapDrawPings", miscState.oldMinimapDrawPings) end -- Re-enable the gui_minimap widget if it exists if widgetHandler.knownWidgets and widgetHandler.knownWidgets["Minimap"] then @@ -8631,7 +8631,7 @@ function widget:Shutdown() -- Unbind per-pip hotkey if configured if button.keybind then - Spring.SendCommands("unbind " .. button.keybind .. " " .. button.actionName) + SpringUnsynced.SendCommands("unbind " .. button.keybind .. " " .. button.actionName) end end end @@ -8684,7 +8684,7 @@ function widget:GetConfigData() activityFocusIgnoreSpectators = config.activityFocusIgnoreSpectators, tvEnabled = miscState.tvEnabled, hideAICommands = config.hideAICommands, - gameID = Game.gameID or Spring.GetGameRulesParam("GameID"), + gameID = Game.gameID or SpringShared.GetGameRulesParam("GameID"), -- minimapModeMaxHeight now stored as ConfigFloat "MinimapMaxHeight" -- leftButtonPansCamera now stored as Spring ConfigInt "MinimapLeftClickMove" -- Minimap mode camera state (for luaui reload restoration) @@ -8763,17 +8763,17 @@ function widget:SetConfigData(data) uiState.savedDimensions.t = render.dim.t else -- Invalid dimensions - use default center position - Spring.Echo("PIP: Invalid saved dimensions detected, resetting to default position") + SpringShared.Echo("PIP: Invalid saved dimensions detected, resetting to default position") end else -- Invalid position data - don't restore - Spring.Echo("PIP: Corrupted position data detected, resetting to default position") + SpringShared.Echo("PIP: Corrupted position data detected, resetting to default position") end end -- Always force minimize if in pregame AND it's a new game (different gameID) - local gameFrame = Spring.GetGameFrame() - local currentGameID = Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID") + local gameFrame = SpringShared.GetGameFrame() + local currentGameID = Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID") local isSameGame = (data.gameID and currentGameID and data.gameID == currentGameID) if gameFrame == 0 and not isSameGame then @@ -8866,7 +8866,7 @@ function widget:SetConfigData(data) --if data.engineMinimapFallbackThreshold ~= nil then config.engineMinimapFallbackThreshold = data.engineMinimapFallbackThreshold end if data.tvEnabled ~= nil then -- Only restore TV mode if we're a spectator (or tvModeSpectatorsOnly is off) - if data.tvEnabled and config.tvModeSpectatorsOnly and not Spring.GetSpectatingState() then + if data.tvEnabled and config.tvModeSpectatorsOnly and not SpringUnsynced.GetSpectatingState() then miscState.tvEnabled = false else miscState.tvEnabled = data.tvEnabled @@ -8881,19 +8881,19 @@ function widget:SetConfigData(data) -- Migrate old minimapModeMaxHeight config data to ConfigFloat (one-time) if data.minimapModeMaxHeight and type(data.minimapModeMaxHeight) == "number" and data.minimapModeMaxHeight > 0 and data.minimapModeMaxHeight <= 1 then - if Spring.GetConfigFloat("MinimapMaxHeight", -1) == -1 then - Spring.SetConfigFloat("MinimapMaxHeight", data.minimapModeMaxHeight) + if SpringUnsynced.GetConfigFloat("MinimapMaxHeight", -1) == -1 then + SpringUnsynced.SetConfigFloat("MinimapMaxHeight", data.minimapModeMaxHeight) end - config.minimapModeMaxHeight = Spring.GetConfigFloat("MinimapMaxHeight", 0.32) + config.minimapModeMaxHeight = SpringUnsynced.GetConfigFloat("MinimapMaxHeight", 0.32) end -- leftButtonPansCamera now read from Spring ConfigInt "MinimapLeftClickMove" - if data.leftButtonPansCamera ~= nil and Spring.GetConfigInt("MinimapLeftClickMove", -1) == -1 then + if data.leftButtonPansCamera ~= nil and SpringUnsynced.GetConfigInt("MinimapLeftClickMove", -1) == -1 then -- Migrate old config data to new ConfigInt (one-time) config.leftButtonPansCamera = data.leftButtonPansCamera - Spring.SetConfigInt("MinimapLeftClickMove", data.leftButtonPansCamera and 1 or 0) + SpringUnsynced.SetConfigInt("MinimapLeftClickMove", data.leftButtonPansCamera and 1 or 0) end - local currentGameID = Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID") + local currentGameID = Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID") local isSameGame = (data.gameID and currentGameID and data.gameID == currentGameID) -- Restore ghost buildings from saved config (same game only — positions are game-specific) @@ -8901,7 +8901,7 @@ function widget:SetConfigData(data) ghostBuildings = data.ghostBuildings end - if Spring.GetGameFrame() > 0 or isSameGame then + if SpringShared.GetGameFrame() > 0 or isSameGame then interactionState.areTracking = data.areTracking -- Restore player tracking if same game and player still exists @@ -9155,7 +9155,7 @@ end local function DrawCommandQueuesOverlay(cachedSelectedUnits) -- Check if Shift+Space (meta) is held to show all visible units - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() local showAllUnits = shift and meta -- Reuse pool table instead of allocating new one @@ -9390,7 +9390,7 @@ local function DrawBuildPreview(mx, my, iconRadiusZoomDistMult) return end - local _, activeCmdID = Spring.GetActiveCommand() + local _, activeCmdID = SpringUnsynced.GetActiveCommand() -- Exit early if no active command if not activeCmdID then @@ -9425,7 +9425,7 @@ local function DrawBuildPreview(mx, my, iconRadiusZoomDistMult) local mexBuildings = WG["resource_spot_builder"] and WG["resource_spot_builder"].GetMexBuildings() if mexBuildings then if not frameSel then - frameSel = Spring.GetSelectedUnits() + frameSel = SpringUnsynced.GetSelectedUnits() end local selectedUnits = frameSel local mexConstructors = WG["resource_spot_builder"] and WG["resource_spot_builder"].GetMexConstructors() @@ -9501,14 +9501,14 @@ local function DrawBuildPreview(mx, my, iconRadiusZoomDistMult) if buildIcon then local iconSize = iconRadiusZoomDistMult * buildIcon.size local cx, cy = WorldToPipCoords(wx, wz) - local buildFacing = Spring.GetBuildFacing() - local canBuild = Spring.TestBuildOrder(buildDefID, wx, wy, wz, buildFacing) + local buildFacing = SpringUnsynced.GetBuildFacing() + local canBuild = SpringShared.TestBuildOrder(buildDefID, wx, wy, wz, buildFacing) if canBuild == 2 then glFunc.Color(1, 1, 1, 0.5) elseif canBuild == 1 then local blockedByMobile = false - local nearbyUnits = Spring.GetUnitsInCylinder(wx, wz, 64) + local nearbyUnits = SpringShared.GetUnitsInCylinder(wx, wz, 64) if nearbyUnits then for _, unitID in ipairs(nearbyUnits) do local unitDefID = spFunc.GetUnitDefID(unitID) @@ -9552,7 +9552,7 @@ local function DrawBuildDragPreview(iconRadiusZoomDistMult) return end - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if not cmdID or cmdID >= 0 then return end @@ -9563,7 +9563,7 @@ local function DrawBuildDragPreview(iconRadiusZoomDistMult) return end - local buildFacing = Spring.GetBuildFacing() + local buildFacing = SpringUnsynced.GetBuildFacing() local buildWidth, buildHeight = GetBuildingDimensions(buildDefID, buildFacing) local centerX, centerY = WorldToPipCoords(0, 0) local edgeX, edgeY = WorldToPipCoords(buildWidth, 0) @@ -9574,14 +9574,14 @@ local function DrawBuildDragPreview(iconRadiusZoomDistMult) for i = 1, #interactionState.buildDragPositions do local pos = interactionState.buildDragPositions[i] local cx, cy = WorldToPipCoords(pos.wx, pos.wz) - local canBuild = Spring.TestBuildOrder(buildDefID, pos.wx, spFunc.GetGroundHeight(pos.wx, pos.wz), pos.wz, buildFacing) + local canBuild = SpringShared.TestBuildOrder(buildDefID, pos.wx, spFunc.GetGroundHeight(pos.wx, pos.wz), pos.wz, buildFacing) local alpha = math.max(0.3, 0.6 - (i - 1) * 0.05) if canBuild == 2 then glFunc.Color(1, 1, 1, alpha) elseif canBuild == 1 then local blockedByMobile = false - local nearbyUnits = Spring.GetUnitsInCylinder(pos.wx, pos.wz, 64) + local nearbyUnits = SpringShared.GetUnitsInCylinder(pos.wx, pos.wz, 64) if nearbyUnits then for _, unitID in ipairs(nearbyUnits) do local unitDefID = spFunc.GetUnitDefID(unitID) @@ -9733,7 +9733,7 @@ local function GL4DrawIcons(checkAllyTeamID, selectedSet, trackingSet) -- Simplifies to: unitBaseSize * (mapX*mapZ/40000)^0.25 * sqrt(zoom). -- Independent of PIP pixel dimensions (aspect ratio doesn't affect icon size). local resScale = render.contentScale or 1 - local unitBaseSize = Spring.GetConfigFloat("MinimapIconScale", 3.5) + local unitBaseSize = SpringUnsynced.GetConfigFloat("MinimapIconScale", 3.5) local iconRadiusZoomDistMult = unitBaseSize * (mapInfo.mapSizeX * mapInfo.mapSizeZ / 40000) ^ 0.25 * math.sqrt(cameraState.zoom) * resScale -- Resolution boost: icons look relatively small on high-res screens, so scale them up @@ -9887,8 +9887,8 @@ local function GL4DrawIcons(checkAllyTeamID, selectedSet, trackingSet) if not miscState.cachedTakeableTeams then miscState.cachedTakeableTeams = {} if not miscState.isGameOver then - for _, tID in ipairs(Spring.GetTeamList()) do - local _, leader, isDead, hasAI = Spring.GetTeamInfo(tID, false) + for _, tID in ipairs(SpringShared.GetTeamList()) do + local _, leader, isDead, hasAI = SpringShared.GetTeamInfo(tID, false) if leader == -1 and not isDead and not hasAI then miscState.cachedTakeableTeams[tID] = true end @@ -10190,7 +10190,7 @@ local function GL4DrawIcons(checkAllyTeamID, selectedSet, trackingSet) -- they almost certainly won't this frame either. Worst case: one extra rebuild. -- At low zoom, extend forced rebuild interval (LOS changes less visible at full-map view) local bldgBlockGameFrameLimit = cameraState.zoom < 0.15 and 90 or 30 - local bldgBlockWillRebuild = useUnitpics or not gl4Icons._bldgBlock or (Spring.GetGameFrame() - (gl4Icons._bldgBlockFrame or 0)) >= bldgBlockGameFrameLimit + local bldgBlockWillRebuild = useUnitpics or not gl4Icons._bldgBlock or (SpringShared.GetGameFrame() - (gl4Icons._bldgBlockFrame or 0)) >= bldgBlockGameFrameLimit for i = 1, unitCount do local uID = pipUnits[i] -- Skip crashing units early @@ -10318,7 +10318,7 @@ local function GL4DrawIcons(checkAllyTeamID, selectedSet, trackingSet) local bldgProcessed = 0 local mobileProcessed = 0 local slowMobileProcessed = 0 - local currentGameFrame = Spring.GetGameFrame() + local currentGameFrame = SpringShared.GetGameFrame() local bldgUsedElements = 0 -- Total building+ghost elements for building VBO -- ======================================================================== @@ -11273,7 +11273,7 @@ local function GL4DrawIcons(checkAllyTeamID, selectedSet, trackingSet) -- Draw start unit icon before game starts (when commander is not yet placed) if not gameHasStarted and not isMinimapMode and miscState.startX and miscState.startX >= 0 then local myTeamID = Spring.GetMyTeamID() - local startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") + local startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") if startDefID and cacheUnitIcon[startDefID] then local iconData = cacheUnitIcon[startDefID] local iconSize = iconRadiusZoomDistMult * iconData.size @@ -11326,7 +11326,7 @@ local function DrawUnitsAndFeatures(cachedSelectedUnits) -- Otherwise, GetUnitsInRectangle returns units visible to our team if interactionState.trackingPlayerID and cameraState.mySpecState then -- Spectating and tracking: get all units (pass -1 to get all units regardless of visibility) - miscState.pipUnits = Spring.GetAllUnits() + miscState.pipUnits = SpringShared.GetAllUnits() -- Filter to only units in the rectangle (do this manually since we got all units) local unitsInRect = {} for i = 1, #miscState.pipUnits do @@ -11347,12 +11347,12 @@ local function DrawUnitsAndFeatures(cachedSelectedUnits) -- Pre-compute per-frame visibility context (avoids redundant API calls per unit) local checkAllyTeamID = nil - local _, fullview = Spring.GetSpectatingState() + local _, fullview = SpringUnsynced.GetSpectatingState() local myAllyTeam = Spring.GetMyAllyTeamID() if interactionState.trackingPlayerID and cameraState.mySpecState then local _, _, _, playerTeamID = spFunc.GetPlayerInfo(interactionState.trackingPlayerID, false) if playerTeamID then - local playerAllyTeamID = teamAllyTeamCache[playerTeamID] or Spring.GetTeamAllyTeamID(playerTeamID) + local playerAllyTeamID = teamAllyTeamCache[playerTeamID] or SpringShared.GetTeamAllyTeamID(playerTeamID) if not fullview and playerAllyTeamID ~= myAllyTeam then checkAllyTeamID = myAllyTeam else @@ -11363,7 +11363,7 @@ local function DrawUnitsAndFeatures(cachedSelectedUnits) checkAllyTeamID = state.losViewAllyTeam elseif not cameraState.mySpecState then local myTeamID = Spring.GetMyTeamID() - checkAllyTeamID = teamAllyTeamCache[myTeamID] or Spring.GetTeamAllyTeamID(myTeamID) + checkAllyTeamID = teamAllyTeamCache[myTeamID] or SpringShared.GetTeamAllyTeamID(myTeamID) elseif cameraState.mySpecState then if not fullview then checkAllyTeamID = myAllyTeam @@ -11698,7 +11698,7 @@ local function DrawUnitsAndFeatures(cachedSelectedUnits) if interactionState.trackingPlayerID then selectedSet = WG["allyselectedunits"] and WG["allyselectedunits"].getPlayerSelectedUnits(interactionState.trackingPlayerID) else - local selUnits2 = cachedSelectedUnits or Spring.GetSelectedUnits() + local selUnits2 = cachedSelectedUnits or SpringUnsynced.GetSelectedUnits() local set = pools.selectedSet if not set then set = {} @@ -11725,32 +11725,32 @@ local function DrawUnitsAndFeatures(cachedSelectedUnits) -- Rebuild name cache if dirty (player changed, periodic refresh) if comNametagCache.dirty then comNametagCache.dirty = false - local tList = Spring.GetTeamList() + local tList = SpringShared.GetTeamList() for ti = 1, #tList do local tID = tList[ti] if tID ~= gaiaTeamID and not scavRaptorTeams[tID] then local name - local luaAI = Spring.GetTeamLuaAI(tID) or "" + local luaAI = SpringShared.GetTeamLuaAI(tID) or "" if luaAI ~= "" then -- Lua AI team (e.g. Scavengers): use AI display name from game rules - local aiDisplayName = Spring.GetGameRulesParam("ainame_" .. tID) + local aiDisplayName = SpringShared.GetGameRulesParam("ainame_" .. tID) if aiDisplayName then name = aiDisplayName .. " (AI)" else name = luaAI .. " (AI)" end - elseif Spring.GetGameRulesParam("ainame_" .. tID) then + elseif SpringShared.GetGameRulesParam("ainame_" .. tID) then -- Native/C++ AI team (e.g. BARb): no LuaAI, but has ainame_ game rule - name = Spring.GetGameRulesParam("ainame_" .. tID) .. " (AI)" + name = SpringShared.GetGameRulesParam("ainame_" .. tID) .. " (AI)" else -- Human player: find the best player on this team -- Prefer active non-spec, fall back to any non-spec (disconnected), then any player - local players = Spring.GetPlayerList(tID) + local players = SpringShared.GetPlayerList(tID) if players then local fallbackName for pi = 1, #players do local pID = players[pi] - local pname, active, isspec = Spring.GetPlayerInfo(pID, false) + local pname, active, isspec = SpringShared.GetPlayerInfo(pID, false) if not isspec then local resolvedName = (WG.playernames and WG.playernames.getPlayername and WG.playernames.getPlayername(pID)) or pname if active then @@ -11805,7 +11805,7 @@ local function DrawUnitsAndFeatures(cachedSelectedUnits) local localCacheUnitIcon = cache.unitIcon local resScale = render.contentScale or 1 -- Cap icon size for nametag/health bar positioning to match the capped shader icons - local cappedIconRadius = math.min(iconRadiusZoomDistMult, Spring.GetConfigFloat("MinimapIconScale", 3.5) * (mapInfo.mapSizeX * mapInfo.mapSizeZ / 40000) ^ 0.25 * math.sqrt(0.95) * resScale) + local cappedIconRadius = math.min(iconRadiusZoomDistMult, SpringUnsynced.GetConfigFloat("MinimapIconScale", 3.5) * (mapInfo.mapSizeX * mapInfo.mapSizeZ / 40000) ^ 0.25 * math.sqrt(0.95) * resScale) -- When unitpics are shown, icons are rendered larger (unitpicSizeMult + borders). -- Precompute the per-icon multiplier and total border size to position nametags correctly. local unitpicsActive = config.showUnitpics and cameraState.targetZoom >= config.unitpicZoomThreshold @@ -12007,7 +12007,7 @@ local function DrawUnitsAndFeatures(cachedSelectedUnits) -- Get player's team color local _, _, _, teamID = spFunc.GetPlayerInfo(interactionState.trackingPlayerID, false) if teamID then - local r, g, b = Spring.GetTeamColor(teamID) + local r, g, b = SpringUnsynced.GetTeamColor(teamID) -- Scale cursor size: larger at low zoom, stays reasonable at high zoom local resScale = config.contentResolutionScale or 1 local cursorSize = render.vsy * 0.0073 * resScale @@ -12101,9 +12101,9 @@ local function DrawUnitsAndFeatures(cachedSelectedUnits) -- Debug echo every 2 seconds if config.showPipTimers and tEnd - perfTimers.lastEchoTime > 2.0 then perfTimers.lastEchoTime = tEnd - Spring.Echo(string.format("[PIP%d] total=%.1fms feat=%.2fms proj=%.2fms expl=%.2fms icons=%.2fms items=%d", pipNumber, perfTimers.total * 1000, perfTimers.features * 1000, perfTimers.projectiles * 1000, perfTimers.explosions * 1000, perfTimers.icons * 1000, perfTimers.itemCount)) - Spring.Echo(string.format(" icons: ghost=%.2fms keysort=%.2fms sort=%.2fms process=%.2fms upload=%.2fms draw=%.2fms unitpics=%.2fms vboReuse=%.0f%%", perfTimers.icGhost * 1000, perfTimers.icKeysort * 1000, perfTimers.icSort * 1000, perfTimers.icProcess * 1000, perfTimers.icUpload * 1000, perfTimers.icDraw * 1000, perfTimers.icUnitpics * 1000, perfTimers.icVboReuse * 100)) - Spring.Echo(string.format(" process: bldg=%.2fms(%d) slowMob=%.2fms(%d) fastMob=%.2fms(%d)", perfTimers.icProcBldg * 1000, perfTimers.icProcBldgN, perfTimers.icProcSlowMobile * 1000, perfTimers.icProcSlowMobileN, perfTimers.icProcMobile * 1000, perfTimers.icProcMobileN)) + SpringShared.Echo(string.format("[PIP%d] total=%.1fms feat=%.2fms proj=%.2fms expl=%.2fms icons=%.2fms items=%d", pipNumber, perfTimers.total * 1000, perfTimers.features * 1000, perfTimers.projectiles * 1000, perfTimers.explosions * 1000, perfTimers.icons * 1000, perfTimers.itemCount)) + SpringShared.Echo(string.format(" icons: ghost=%.2fms keysort=%.2fms sort=%.2fms process=%.2fms upload=%.2fms draw=%.2fms unitpics=%.2fms vboReuse=%.0f%%", perfTimers.icGhost * 1000, perfTimers.icKeysort * 1000, perfTimers.icSort * 1000, perfTimers.icProcess * 1000, perfTimers.icUpload * 1000, perfTimers.icDraw * 1000, perfTimers.icUnitpics * 1000, perfTimers.icVboReuse * 100)) + SpringShared.Echo(string.format(" process: bldg=%.2fms(%d) slowMob=%.2fms(%d) fastMob=%.2fms(%d)", perfTimers.icProcBldg * 1000, perfTimers.icProcBldgN, perfTimers.icProcSlowMobile * 1000, perfTimers.icProcSlowMobileN, perfTimers.icProcMobile * 1000, perfTimers.icProcMobileN)) end end @@ -12134,7 +12134,7 @@ end -- Helper function to calculate maximize icon rotation angle based on expansion direction local function GetMaximizeIconRotation() -- Determine expansion direction based on current or minimize button position - local sw, sh = Spring.GetWindowGeometry() + local sw, sh = SpringUnsynced.GetWindowGeometry() local posL, posB -- Use current position when maximized (for minimize button rotation during drag/resize) @@ -12227,7 +12227,7 @@ local function RenderFrameButtons() local isTracking = interactionState.areTracking ~= nil local isTrackingPlayer = interactionState.trackingPlayerID ~= nil -- Show player tracking button when tracking, when spectating, or when having alive teammates - local spec = Spring.GetSpectatingState() + local spec = SpringUnsynced.GetSpectatingState() local aliveTeammates = GetAliveTeammates() local showPlayerTrackButton = isTrackingPlayer or spec or (#aliveTeammates > 0) local visibleButtons = pools.visibleButtons @@ -12252,7 +12252,7 @@ local function RenderFrameButtons() if btn.command == "pip_switch" or btn.command == "pip_copy" then skipButton = true elseif btn.command == "pip_view" then - local _, fullview = Spring.GetSpectatingState() + local _, fullview = SpringUnsynced.GetSpectatingState() if not fullview then skipButton = true end @@ -12322,13 +12322,13 @@ end -- Helper function to determine if LOS overlay should be shown and which allyteam to use local function ShouldShowLOS() local myAllyTeam = Spring.GetMyAllyTeamID() - local mySpec, fullview = Spring.GetSpectatingState() + local mySpec, fullview = SpringUnsynced.GetSpectatingState() -- If tracking a player's camera, use their allyteam (priority over LOS view) if interactionState.trackingPlayerID then local _, _, isSpec, teamID = spFunc.GetPlayerInfo(interactionState.trackingPlayerID, false) if teamID then - local allyTeamID = Spring.GetTeamAllyTeamID(teamID) + local allyTeamID = SpringShared.GetTeamAllyTeamID(teamID) -- Always return the tracked player's allyteam for LOS generation -- Even without fullview, we can manually generate their LOS at this location return true, allyTeamID @@ -12377,7 +12377,7 @@ local function GetWaterLevel() -- Lazy fallback: try reading game rule on first use (covers the gap between -- widget init and the first Update() poll, avoiding wrong waterLevel=0 on lava maps) if mapInfo.isLava then - local level = Spring.GetGameRulesParam("lavaLevel") + local level = SpringShared.GetGameRulesParam("lavaLevel") if level and level ~= -99999 then mapInfo.dynamicWaterLevel = level return level @@ -12405,20 +12405,20 @@ local function UpdateLavaRenderState() end -- gadget is handling it -- Compute tide-adjusted level (same formula as gadget's GameFrame) - local baseLavaLevel = Spring.GetGameRulesParam("lavaLevel") + local baseLavaLevel = SpringShared.GetGameRulesParam("lavaLevel") if baseLavaLevel and baseLavaLevel ~= -99999 then - local gameFrame = Spring.GetGameFrame() + local gameFrame = SpringShared.GetGameFrame() local tidePeriod = mapInfo.lavaTidePeriod or 200 local tideAmplitude = mapInfo.lavaTideAmplitude or 2 lrs.level = math.sin(gameFrame / tidePeriod) * tideAmplitude + baseLavaLevel end -- Compute heat distortion (same formula as gadget's DrawWorldPreUnit) - local _, _, isPaused = Spring.GetGameSpeed() + local _, _, isPaused = SpringUnsynced.GetGameSpeed() if not isPaused then - local camX, camY, camZ = Spring.GetCameraDirection() + local camX, camY, camZ = SpringUnsynced.GetCameraDirection() local camvlength = math.sqrt(camX * camX + camZ * camZ + 0.01) - lrs.smoothFPS = 0.9 * lrs.smoothFPS + 0.1 * math.max(Spring.GetFPS(), 15) + lrs.smoothFPS = 0.9 * lrs.smoothFPS + 0.1 * math.max(SpringUnsynced.GetFPS(), 15) lrs.heatDistortX = lrs.heatDistortX - camX / (camvlength * lrs.smoothFPS) lrs.heatDistortZ = lrs.heatDistortZ - camZ / (camvlength * lrs.smoothFPS) end @@ -12449,7 +12449,7 @@ local function DrawWaterAndLOSOverlays() gl.UniformFloat(gl.GetUniformLocation(shaders.water, "waterLevel"), GetWaterLevel()) gl.UniformFloat(gl.GetUniformLocation(shaders.water, "isLava"), mapInfo.isLava and 1.0 or 0.0) gl.UniformFloat(gl.GetUniformLocation(shaders.water, "hasLavaTex"), mapInfo.lavaDiffuseEmitTex and 1.0 or 0.0) - gl.UniformFloat(gl.GetUniformLocation(shaders.water, "gameFrames"), Spring.GetGameFrame()) + gl.UniformFloat(gl.GetUniformLocation(shaders.water, "gameFrames"), SpringShared.GetGameFrame()) gl.UniformFloat(gl.GetUniformLocation(shaders.water, "lavaCoastColor"), mapInfo.lavaCoastColor[1], mapInfo.lavaCoastColor[2], mapInfo.lavaCoastColor[3]) gl.UniformFloat(gl.GetUniformLocation(shaders.water, "colorCorrection"), mapInfo.lavaColorCorrection[1], mapInfo.lavaColorCorrection[2], mapInfo.lavaColorCorrection[3]) gl.UniformFloat(gl.GetUniformLocation(shaders.water, "lavaCoastWidth"), mapInfo.lavaCoastWidth) @@ -12593,7 +12593,7 @@ local function DrawMapMarkers() -- Filter markers by allyteam if LOS view is limited local shouldDraw = true if filterByAllyTeam and marker.teamID then - local markerAllyTeam = Spring.GetTeamAllyTeamID(marker.teamID) + local markerAllyTeam = SpringShared.GetTeamAllyTeamID(marker.teamID) shouldDraw = (markerAllyTeam == losAllyTeam) end @@ -12643,7 +12643,7 @@ local function DrawMapMarkers() if marker.isSpectator then r, g, b = 1, 1, 1 -- White for spectators elseif marker.teamID then - r, g, b = Spring.GetTeamColor(marker.teamID) + r, g, b = SpringUnsynced.GetTeamColor(marker.teamID) end -- Draw rotating rectangle @@ -12687,7 +12687,7 @@ local function DrawBuildCursorWithRotation() local mx, my = spFunc.GetMouseState() -- Get active command - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if not cmdID then return end @@ -12698,7 +12698,7 @@ local function DrawBuildCursorWithRotation() -- then show the preview if that world position falls within the PIP's visible area local worldTraceX, worldTraceZ if not mouseOverPip then - local _, pos = Spring.TraceScreenRay(mx, my, true) + local _, pos = SpringUnsynced.TraceScreenRay(mx, my, true) if pos then worldTraceX, worldTraceZ = pos[1], pos[3] -- Check if the traced world position is visible in the PIP @@ -12754,7 +12754,7 @@ local function DrawBuildCursorWithRotation() local mexBuildings = WG["resource_spot_builder"] and WG["resource_spot_builder"].GetMexBuildings() if mexBuildings then if not frameSel then - frameSel = Spring.GetSelectedUnits() + frameSel = SpringUnsynced.GetSelectedUnits() end local selectedUnits = frameSel local mexConstructors = WG["resource_spot_builder"] and WG["resource_spot_builder"].GetMexConstructors() @@ -12764,7 +12764,7 @@ local function DrawBuildCursorWithRotation() local buildIcon = cache.unitIcon[selectedMex] if buildIcon then local resScale = render.contentScale or 1 - local unitBaseSize = Spring.GetConfigFloat("MinimapIconScale", 3.5) + local unitBaseSize = SpringUnsynced.GetConfigFloat("MinimapIconScale", 3.5) local iconRadiusZoomDistMult = unitBaseSize * (mapInfo.mapSizeX * mapInfo.mapSizeZ / 40000) ^ 0.25 * math.sqrt(cameraState.zoom) * resScale local iconSize = iconRadiusZoomDistMult * buildIcon.size * 0.8 local mapRotDeg = render.minimapRotation ~= 0 and (-render.minimapRotation * 180 / math.pi) or 0 @@ -12864,8 +12864,8 @@ local function DrawBuildCursorWithRotation() wy = spFunc.GetGroundHeight(wx, wz) end - local buildFacing = Spring.GetBuildFacing() - local buildTest = Spring.TestBuildOrder(buildDefID, wx, wy, wz, buildFacing) + local buildFacing = SpringUnsynced.GetBuildFacing() + local buildTest = SpringShared.TestBuildOrder(buildDefID, wx, wy, wz, buildFacing) -- Draw unit icon with buildability coloring if cache.unitIcon[buildDefID] then @@ -12873,7 +12873,7 @@ local function DrawBuildCursorWithRotation() local texture = iconData.bitmap -- Engine-matching icon size (same as GL4DrawIcons/DrawIcons) local resScale = render.contentScale or 1 - local unitBaseSize = Spring.GetConfigFloat("MinimapIconScale", 3.5) + local unitBaseSize = SpringUnsynced.GetConfigFloat("MinimapIconScale", 3.5) local iconSize = unitBaseSize * (mapInfo.mapSizeX * mapInfo.mapSizeZ / 40000) ^ 0.25 * math.sqrt(cameraState.zoom) * resScale * iconData.size local sx, sy = WorldToPipCoords(wx, wz) @@ -12882,7 +12882,7 @@ local function DrawBuildCursorWithRotation() glFunc.Color(1, 1, 1, 0.7) elseif buildTest == 1 then local blockedByMobile = false - local nearbyUnits = Spring.GetUnitsInCylinder(wx, wz, 64) + local nearbyUnits = SpringShared.GetUnitsInCylinder(wx, wz, 64) if nearbyUnits then for _, unitID in ipairs(nearbyUnits) do local unitDefID = spFunc.GetUnitDefID(unitID) @@ -13000,14 +13000,14 @@ local function DrawCameraViewBounds() end -- Get screen dimensions - local vsx, vsy = Spring.GetViewGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() -- Get camera position for ray origin - local camX, camY, camZ = Spring.GetCameraPosition() + local camX, camY, camZ = SpringUnsynced.GetCameraPosition() -- Trace screen center to find ground Y (matches engine's TraceRay::GuiTraceRay at screen center) local groundY - local _, centerPos = Spring.TraceScreenRay(math.floor(vsx / 2), math.floor(vsy / 2), true) + local _, centerPos = SpringUnsynced.TraceScreenRay(math.floor(vsx / 2), math.floor(vsy / 2), true) if centerPos then groundY = centerPos[2] else @@ -13021,7 +13021,7 @@ local function DrawCameraViewBounds() local farDist = 50000 -- reference distance for behind-camera projection scaling local negCount = 0 local function screenToGround(sx, sy) - local dirX, dirY, dirZ = Spring.GetPixelDir(sx, sy) + local dirX, dirY, dirZ = SpringUnsynced.GetPixelDir(sx, sy) -- Compute intersection parameter with groundY plane -- Use farDist-scaled direction so t=1 means the far reference point (like engine's frustum vert) @@ -13561,7 +13561,7 @@ end -- Called inside R2T context for the oversized unitsTex local function RenderExpensiveLayers() if not frameSel then - frameSel = Spring.GetSelectedUnits() + frameSel = SpringUnsynced.GetSelectedUnits() end local cachedSelectedUnits = frameSel @@ -13593,7 +13593,7 @@ end local function RenderPipContents() -- Use frame-cached selected units to avoid redundant API call if not frameSel then - frameSel = Spring.GetSelectedUnits() + frameSel = SpringUnsynced.GetSelectedUnits() end local cachedSelectedUnits = frameSel @@ -13692,7 +13692,7 @@ local function DrawBoxSelection() local selectionboxEnabled = widgetHandler:IsWidgetKnown("Selectionbox") and (widgetHandler.orderList["Selectionbox"] and widgetHandler.knownWidgets["Selectionbox"].active) -- Get modifier key states (ignoring alt as requested) - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() -- Determine background color based on modifier keys (only if selectionbox widget is enabled) local bgAlpha = 0.03 @@ -13762,7 +13762,7 @@ local function DrawAreaCommand() end local mx, my = spFunc.GetMouseState() - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if not cmdID or cmdID <= 0 then return end @@ -13822,7 +13822,7 @@ local function DrawBuildCursor() end -- Get active command - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if not cmdID or cmdID >= 0 then return end @@ -13845,10 +13845,10 @@ local function DrawBuildCursor() local wy = spFunc.GetGroundHeight(wx, wz) -- Get build facing - local buildFacing = Spring.GetBuildFacing() + local buildFacing = SpringUnsynced.GetBuildFacing() -- Test if building can be placed here (returns 0 if not buildable, or a positive value if buildable) - local buildTest = Spring.TestBuildOrder(buildDefID, wx, wy, wz, buildFacing) + local buildTest = SpringShared.TestBuildOrder(buildDefID, wx, wy, wz, buildFacing) local canBuild = (buildTest and buildTest > 0) -- Draw unit icon at cursor position with 0.7 opacity @@ -13858,7 +13858,7 @@ local function DrawBuildCursor() -- Engine-matching icon size (same as GL4DrawIcons/DrawIcons) local resScale = render.contentScale or 1 - local unitBaseSize = Spring.GetConfigFloat("MinimapIconScale", 3.5) + local unitBaseSize = SpringUnsynced.GetConfigFloat("MinimapIconScale", 3.5) local iconSize = unitBaseSize * (mapInfo.mapSizeX * mapInfo.mapSizeZ / 40000) ^ 0.25 * math.sqrt(cameraState.zoom) * resScale * iconData.size local sx, sy = WorldToPipCoords(wx, wz) @@ -13973,7 +13973,7 @@ local function DrawTrackedPlayerName() end -- Get team color - local r, g, b = Spring.GetTeamColor(teamID) + local r, g, b = SpringUnsynced.GetTeamColor(teamID) local fontSize = math.floor(20 * render.widgetScale) local padding = math.floor(17 * render.widgetScale) local centerX = (render.dim.l + render.dim.r) / 2 @@ -14028,22 +14028,22 @@ local function DrawTrackedPlayerResourceBars() -- Get team resources - this works for spectators viewing any team -- Returns: current, storage, pull, income, expense, share - local metalCur, metalMax, metalPull, metalIncome, metalExpense, metalShare = Spring.GetTeamResources(teamID, "metal") - local energyCur, energyMax, energyPull, energyIncome, energyExpense, energyShare = Spring.GetTeamResources(teamID, "energy") + local metalCur, metalMax, metalPull, metalIncome, metalExpense, metalShare = SpringShared.GetTeamResources(teamID, "metal") + local energyCur, energyMax, energyPull, energyIncome, energyExpense, energyShare = SpringShared.GetTeamResources(teamID, "energy") if not (metalCur and energyCur) then return end -- Get energy conversion level (mmLevel) - local mmLevel = Spring.GetTeamRulesParam(teamID, "mmLevel") + local mmLevel = SpringShared.GetTeamRulesParam(teamID, "mmLevel") if mmLevel == nil then mmLevel = 1 end -- Check if player has teammates (for share slider) - local _, _, _, _, _, allyTeamID = Spring.GetTeamInfo(teamID, false) - local allyTeamList = Spring.GetTeamList(allyTeamID) + local _, _, _, _, _, allyTeamID = SpringShared.GetTeamInfo(teamID, false) + local allyTeamList = SpringShared.GetTeamList(allyTeamID) local hasTeammates = allyTeamList and #allyTeamList > 1 -- Calculate bar dimensions - compact version at top of PIP @@ -14501,7 +14501,7 @@ local function DrawTrackedPlayerMinimap() gl.UniformFloat(gl.GetUniformLocation(shaders.water, "waterLevel"), GetWaterLevel()) gl.UniformFloat(gl.GetUniformLocation(shaders.water, "isLava"), mapInfo.isLava and 1.0 or 0.0) gl.UniformFloat(gl.GetUniformLocation(shaders.water, "hasLavaTex"), mapInfo.lavaDiffuseEmitTex and 1.0 or 0.0) - gl.UniformFloat(gl.GetUniformLocation(shaders.water, "gameFrames"), Spring.GetGameFrame()) + gl.UniformFloat(gl.GetUniformLocation(shaders.water, "gameFrames"), SpringShared.GetGameFrame()) gl.UniformFloat(gl.GetUniformLocation(shaders.water, "lavaCoastColor"), mapInfo.lavaCoastColor[1], mapInfo.lavaCoastColor[2], mapInfo.lavaCoastColor[3]) gl.UniformFloat(gl.GetUniformLocation(shaders.water, "colorCorrection"), mapInfo.lavaColorCorrection[1], mapInfo.lavaColorCorrection[2], mapInfo.lavaColorCorrection[3]) gl.UniformFloat(gl.GetUniformLocation(shaders.water, "lavaCoastWidth"), mapInfo.lavaCoastWidth) @@ -14770,7 +14770,7 @@ local function UpdateR2TUnits(currentTime, pipUpdateInterval, pipWidth, pipHeigh end -- Get current rotation early (before shouldUpdate check) so rotation changes are detected - local currentRotation = Spring.GetMiniMapRotation and Spring.GetMiniMapRotation() or 0 + local currentRotation = SpringUnsynced.GetMiniMapRotation and SpringUnsynced.GetMiniMapRotation() or 0 local resScale = config.contentResolutionScale local margin = config.smoothCameraMargin @@ -14890,7 +14890,7 @@ local function UpdateR2TUnits(currentTime, pipUpdateInterval, pipWidth, pipHeigh -- Use pcall so restore always runs even if rendering errors local ok, err = pcall(RenderExpensiveLayers) if not ok then - Spring.Echo("[PIP] Units render error: " .. tostring(err)) + SpringShared.Echo("[PIP] Units render error: " .. tostring(err)) -- Emergency GL state cleanup: RenderExpensiveLayers may have left dirty state gl.UseShader(0) glFunc.Texture(0, false) @@ -14937,7 +14937,7 @@ local function UpdateR2TCheapLayers(currentTime, pipUpdateInterval, pipWidth, pi local sizeChanged = math.floor(pipWidth) ~= pipR2T.contentLastWidth or math.floor(pipHeight) ~= pipR2T.contentLastHeight -- Check if rotation changed (rotation is baked into the texture) - local currentRotation = Spring.GetMiniMapRotation and Spring.GetMiniMapRotation() or 0 + local currentRotation = SpringUnsynced.GetMiniMapRotation and SpringUnsynced.GetMiniMapRotation() or 0 local rotChanged = pipR2T.contentRotation ~= currentRotation -- Check if camera has drifted far enough to consume most of the margin @@ -15056,7 +15056,7 @@ local function UpdateR2TCheapLayers(currentTime, pipUpdateInterval, pipWidth, pi -- Render cheap layers (ground, water, LOS) local ok, err = pcall(RenderCheapLayers) if not ok then - Spring.Echo("[PIP] Cheap layers render error: " .. tostring(err)) + SpringShared.Echo("[PIP] Cheap layers render error: " .. tostring(err)) -- Emergency GL state cleanup: RenderCheapLayers may have left dirty state -- (active shader, wrong blend equation, pushed matrix, bound textures, scissor) gl.UseShader(0) @@ -15118,7 +15118,7 @@ InitGL4Decals = function() local vbo = gl.GetVBO(GL.ARRAY_BUFFER, true) if not vbo then - Spring.Echo("[PIP] GL4 decals: Failed to create VBO") + SpringShared.Echo("[PIP] GL4 decals: Failed to create VBO") return end vbo:Define(decalGL4.MAX_INSTANCES, { @@ -15130,7 +15130,7 @@ InitGL4Decals = function() local vao = gl.GetVAO() if not vao then - Spring.Echo("[PIP] GL4 decals: Failed to create VAO") + SpringShared.Echo("[PIP] GL4 decals: Failed to create VAO") vbo:Delete() return end @@ -15152,7 +15152,7 @@ InitGL4Decals = function() invMapSize = gl.GetUniformLocation(shaders.decal, "invMapSize"), } - Spring.Echo("[PIP] GL4 instanced decal rendering enabled") + SpringShared.Echo("[PIP] GL4 instanced decal rendering enabled") end -- Destroy GL4 decal resources @@ -15281,7 +15281,7 @@ local function UpdateDecalTexture() end -- Rate-limit: only run every N game frames (~1 sec) - local frame = Spring.GetGameFrame() + local frame = SpringShared.GetGameFrame() if (frame - pipR2T.decalLastCheckFrame) < pipR2T.decalCheckInterval then return end @@ -15333,7 +15333,7 @@ local function UpdateLOSTexture(currentTime) local useEngineLOS = (losAllyTeam == myAllyTeam) if interactionState.trackingPlayerID and losAllyTeam ~= myAllyTeam then -- Tracking an enemy player - must have fullview to use engine LOS - local _, fullview = Spring.GetSpectatingState() + local _, fullview = SpringUnsynced.GetSpectatingState() if not fullview then -- Without fullview, must manually generate enemy LOS useEngineLOS = false @@ -15379,7 +15379,7 @@ local function UpdateLOSTexture(currentTime) -- Check if we can actually query this allyTeam's LOS -- Without fullview, we can only query our own allyTeam if losAllyTeam ~= myAllyTeam then - local _, fullview = Spring.GetSpectatingState() + local _, fullview = SpringUnsynced.GetSpectatingState() if not fullview then -- Can't query enemy LOS without fullview - skip update return @@ -15512,7 +15512,7 @@ local function DrawTrackingIndicators() if interactionState.trackingPlayerID then local playerName, active, isSpec, teamID = spFunc.GetPlayerInfo(interactionState.trackingPlayerID, false) if teamID then - local r, g, b = Spring.GetTeamColor(teamID) + local r, g, b = SpringUnsynced.GetTeamColor(teamID) local lineWidth = math.ceil(3 * (render.vsx / 1920)) glFunc.Color(r, g, b, 0.5) render.RectRoundOutline(render.dim.l, render.dim.b, render.dim.r, render.dim.t, render.elementCorner * 0.5, lineWidth, 1, 1, 1, 1, { r, g, b, 0.5 }, { r, g, b, 0.5 }) @@ -15575,24 +15575,24 @@ local function HandleHoverAndCursor(mx, my) -- Handle cursor - this runs every frame for smooth cursor updates -- Don't change cursor for spectators (unless config allows it) - local isSpec = Spring.GetSpectatingState() + local isSpec = SpringUnsynced.GetSpectatingState() local canGiveCommands = not isSpec or config.allowCommandsWhenSpectating local lastHoveredUnitID = interactionState.lastHoveredUnitID if canGiveCommands then - local _, activeCmdID = Spring.GetActiveCommand() + local _, activeCmdID = SpringUnsynced.GetActiveCommand() if not activeCmdID then - local defaultCmd = Spring.GetDefaultCommand() + local defaultCmd = SpringUnsynced.GetDefaultCommand() if not defaultCmd or defaultCmd == 0 then if frameSelCount > 0 then if not frameSel then - frameSel = Spring.GetSelectedUnits() + frameSel = SpringUnsynced.GetSelectedUnits() end local selectedUnits = frameSel -- Check if hovering over an enemy unit with units that can attack -- But don't show attack cursor for neutral units - if lastHoveredUnitID and not Spring.IsUnitAllied(lastHoveredUnitID) then - local allyTeam = Spring.GetUnitAllyTeam(lastHoveredUnitID) + if lastHoveredUnitID and not SpringUnsynced.IsUnitAllied(lastHoveredUnitID) then + local allyTeam = SpringShared.GetUnitAllyTeam(lastHoveredUnitID) local isNeutral = (allyTeam == cache.gaiaAllyTeamID) -- Check if unit is visible (LOS or radar) @@ -15609,7 +15609,7 @@ local function HandleHoverAndCursor(mx, my) for i = 1, #selectedUnits do local uDefID = spFunc.GetUnitDefID(selectedUnits[i]) if uDefID and cache.canAttack[uDefID] then - Spring.SetMouseCursor("Attack") + SpringUnsynced.SetMouseCursor("Attack") return end end @@ -15618,11 +15618,11 @@ local function HandleHoverAndCursor(mx, my) -- Check if we have a transport and are hovering over a transportable unit -- Use cached result from throttled check above - if lastHoveredUnitID and Spring.IsUnitAllied(lastHoveredUnitID) then + if lastHoveredUnitID and SpringUnsynced.IsUnitAllied(lastHoveredUnitID) then -- Check if any transport in selection can load this unit for i = 1, #selectedUnits do if CanTransportLoadUnit(selectedUnits[i], lastHoveredUnitID) then - Spring.SetMouseCursor("Load") + SpringUnsynced.SetMouseCursor("Load") return end end @@ -15632,20 +15632,20 @@ local function HandleHoverAndCursor(mx, my) for i = 1, #selectedUnits do local uDefID = spFunc.GetUnitDefID(selectedUnits[i]) if uDefID and (cache.canMove[uDefID] or cache.canFly[uDefID]) then - Spring.SetMouseCursor("Move") + SpringUnsynced.SetMouseCursor("Move") return end end end - elseif defaultCmd == CMD.ATTACK and lastHoveredUnitID and not Spring.IsUnitAllied(lastHoveredUnitID) then + elseif defaultCmd == CMD.ATTACK and lastHoveredUnitID and not SpringUnsynced.IsUnitAllied(lastHoveredUnitID) then -- Hovering over enemy unit with units that can attack - Spring.SetMouseCursor("Attack") + SpringUnsynced.SetMouseCursor("Attack") return end else local cursorName = cmdCursors[activeCmdID] if cursorName then - Spring.SetMouseCursor(cursorName) + SpringUnsynced.SetMouseCursor(cursorName) end end end @@ -15687,7 +15687,7 @@ local function DrawInteractiveOverlays(mx, my, usedButtonSize) if btn.command == "pip_switch" or btn.command == "pip_copy" then skipButton = true elseif btn.command == "pip_view" then - local _, fullview = Spring.GetSpectatingState() + local _, fullview = SpringUnsynced.GetSpectatingState() if not fullview then skipButton = true end @@ -15820,7 +15820,7 @@ function widget:DrawScreen() -- Guards against other widgets (e.g. Minimap widget briefly enabled during reload) -- or engine commands resetting the minimize/slave state between frames. if isMinimapMode and not miscState.engineMinimapActive then - Spring.SendCommands("minimap minimize 1") + SpringUnsynced.SendCommands("minimap minimize 1") end -- In minimap mode, honour MinimapMinimize to hide the PIP minimap @@ -15837,7 +15837,7 @@ function widget:DrawScreen() render.UiElement(btnL - render.elementPadding, btnB - render.elementPadding, btnR + render.elementPadding, btnT + render.elementPadding, tl, tr, br, bl, nil, nil, nil, nil, nil, nil, nil, nil) -- Icon with rotation based on expansion direction - local sw, sh = Spring.GetWindowGeometry() + local sw, sh = SpringUnsynced.GetWindowGeometry() local onLeftSide = (btnL < sw * 0.5) local onBottomSide = (btnB < sh * 0.25) local rotation @@ -15887,7 +15887,7 @@ function widget:DrawScreen() local offset = render.elementPadding + 2 -- to prevent touching screen edges and FlowUI Element will remove borders -- Check if we need to recreate display list due to position change (affects rotation) - local sw, sh = Spring.GetWindowGeometry() + local sw, sh = SpringUnsynced.GetWindowGeometry() local currentQuadrant = (uiState.minModeL < sw * 0.5 and 1 or 2) + (uiState.minModeB < sh * 0.25 and 0 or 2) -- Also track edge state for chamfered corners local actualL = uiState.minModeL - render.elementPadding @@ -15987,24 +15987,24 @@ function widget:DrawScreen() if useEngineMinimapFallback then -- Transition: PIP → engine minimap if not miscState.engineMinimapActive then - miscState.baseMinimapIconScale = Spring.GetConfigFloat("MinimapIconScale", 3.5) + miscState.baseMinimapIconScale = SpringUnsynced.GetConfigFloat("MinimapIconScale", 3.5) miscState.engineMinimapActive = true end -- Always update geometry (handles animation, resize, position changes) - Spring.SendCommands(string.format("minimap geometry %d %d %d %d", math.floor(render.dim.l), math.floor(render.vsy - render.dim.t), math.floor(pipWidth), math.floor(pipHeight))) + SpringUnsynced.SendCommands(string.format("minimap geometry %d %d %d %d", math.floor(render.dim.l), math.floor(render.vsy - render.dim.t), math.floor(pipWidth), math.floor(pipHeight))) -- Apply density-scaled icon size for engine minimap if config.iconDensityScaling and miscState.baseMinimapIconScale then local totalUnits = #miscState.pipUnits local unitFraction = math.min(totalUnits / config.iconDensityMaxUnits, 1.0) local densityScale = 1.0 - (1.0 - config.iconDensityMinScale) * unitFraction local resBoost = 1.0 + 0.18 * math.min(math.max((render.vsy - 1080) / (2880 - 1080), 0), 1) - Spring.SendCommands("minimap unitsize " .. (miscState.baseMinimapIconScale * densityScale * resBoost)) + SpringUnsynced.SendCommands("minimap unitsize " .. (miscState.baseMinimapIconScale * densityScale * resBoost)) end -- Keep minimap unminimized so the engine updates its internal FBO each frame. -- SlaveMiniMap(true) prevents the engine from drawing it visually — we control -- when it appears via gl.DrawMiniMap(). Without this, the minimap FBO is stale -- because the engine skips updating minimized minimaps. - Spring.SendCommands("minimap minimize 0") + SpringUnsynced.SendCommands("minimap minimize 0") gl.SlaveMiniMap(true) gl.DrawMiniMap() @@ -16050,11 +16050,11 @@ function widget:DrawScreen() if miscState.engineMinimapActive then -- Restore original icon scale if miscState.baseMinimapIconScale then - Spring.SendCommands("minimap unitsize " .. miscState.baseMinimapIconScale) - Spring.SetConfigFloat("MinimapIconScale", miscState.baseMinimapIconScale) + SpringUnsynced.SendCommands("minimap unitsize " .. miscState.baseMinimapIconScale) + SpringUnsynced.SetConfigFloat("MinimapIconScale", miscState.baseMinimapIconScale) miscState.baseMinimapIconScale = nil end - Spring.SendCommands("minimap minimize 1") + SpringUnsynced.SendCommands("minimap minimize 1") miscState.engineMinimapActive = false pipR2T.contentNeedsUpdate = true pipR2T.unitsNeedsUpdate = true @@ -16094,7 +16094,7 @@ function widget:DrawScreen() -- The main transition detection code (below) runs AFTER UpdateR2TUnits, -- so detect the change here to ensure the ghost pass runs on the same frame. do - local _, fv = Spring.GetSpectatingState() + local _, fv = SpringUnsynced.GetSpectatingState() if miscState.lastFullview ~= nil and miscState.lastFullview ~= fv then pipR2T.unitsNeedsUpdate = true end @@ -16606,7 +16606,7 @@ function widget:DrawWorld() local radius = math.sqrt(dx * dx + dz * dz) if radius > 5 then -- Only draw if dragged more than 5 elmos - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if cmdID and cmdID > 0 then local color = cmdColors[cmdID] or cmdColors.unknown local wy = spFunc.GetGroundHeight(startWX, startWZ) @@ -16730,7 +16730,7 @@ function widget:DrawInMiniMap(minimapWidth, minimapHeight) if interactionState.trackingPlayerID then local _, _, _, teamID = spFunc.GetPlayerInfo(interactionState.trackingPlayerID, false) if teamID then - r, g, b = Spring.GetTeamColor(teamID) + r, g, b = SpringUnsynced.GetTeamColor(teamID) end end @@ -16780,7 +16780,7 @@ function widget:Update(dt) cache.guishaderWasActive = guishaderActive -- Poll ConfigFloat for external changes (e.g. from gui_options) if isMinimapMode then - local cfgMaxHeight = Spring.GetConfigFloat("MinimapMaxHeight", 0.32) + local cfgMaxHeight = SpringUnsynced.GetConfigFloat("MinimapMaxHeight", 0.32) if cfgMaxHeight ~= config.minimapModeMaxHeight then config.minimapModeMaxHeight = cfgMaxHeight widget:ViewResize() @@ -16789,7 +16789,7 @@ function widget:Update(dt) -- Detect team color changes (e.g. anonymous mode toggle, player swaps) local colorsChanged = false for tID, cached in pairs(teamColors) do - local r, g, b, a = Spring.GetTeamColor(tID) + local r, g, b, a = SpringUnsynced.GetTeamColor(tID) if r ~= cached[1] or g ~= cached[2] or b ~= cached[3] then cached[1], cached[2], cached[3], cached[4] = r, g, b, a colorsChanged = true @@ -16811,10 +16811,10 @@ function widget:Update(dt) -- Auto-disable LOS view when the watched allyteam is fully dead if state.losViewEnabled and state.losViewAllyTeam then local allDead = true - local teams = Spring.GetTeamList(state.losViewAllyTeam) + local teams = SpringShared.GetTeamList(state.losViewAllyTeam) if teams then for t = 1, #teams do - local _, _, isDead = Spring.GetTeamInfo(teams[t], false) + local _, _, isDead = SpringShared.GetTeamInfo(teams[t], false) if not isDead then allDead = false break @@ -16880,7 +16880,7 @@ function widget:Update(dt) cache.leftClickMoveTimer = (cache.leftClickMoveTimer or 0) + dt if cache.leftClickMoveTimer >= 2.0 then cache.leftClickMoveTimer = 0 - local cur = Spring.GetConfigInt("MinimapLeftClickMove", 1) == 1 + local cur = SpringUnsynced.GetConfigInt("MinimapLeftClickMove", 1) == 1 if cur ~= config.leftButtonPansCamera then config.leftButtonPansCamera = cur end @@ -16889,7 +16889,7 @@ function widget:Update(dt) -- In minimap mode, check if rotation changed and recalculate dimensions if needed if isMinimapMode then - local currentRotation = Spring.GetMiniMapRotation and Spring.GetMiniMapRotation() or 0 + local currentRotation = SpringUnsynced.GetMiniMapRotation and SpringUnsynced.GetMiniMapRotation() or 0 -- Only care about rotation category changes (0°/180° vs 90°/270°) local function getRotationCategory(rot) @@ -16925,7 +16925,7 @@ function widget:Update(dt) end else -- Non-minimap mode: detect rotation category changes and re-clamp camera - local currentRotation = Spring.GetMiniMapRotation and Spring.GetMiniMapRotation() or 0 + local currentRotation = SpringUnsynced.GetMiniMapRotation and SpringUnsynced.GetMiniMapRotation() or 0 local function getRotCat(rot) local rotDeg = math.abs(rot * 180 / math.pi) % 180 return (rotDeg > 45 and rotDeg < 135) and 1 or 0 @@ -16977,7 +16977,7 @@ function widget:Update(dt) pipR2T.contentNeedsUpdate = true end -- Non-lava water: poll base water level from game rules - local lavaLevel = Spring.GetGameRulesParam("lavaLevel") + local lavaLevel = SpringShared.GetGameRulesParam("lavaLevel") if lavaLevel and lavaLevel ~= -99999 then if mapInfo.dynamicWaterLevel ~= lavaLevel then local oldLevel = mapInfo.dynamicWaterLevel @@ -16997,7 +16997,7 @@ function widget:Update(dt) widgetHandler:DisableWidget("Minimap") end -- Also ensure the engine minimap stays minimized - Spring.SendCommands("minimap minimize 1") + SpringUnsynced.SendCommands("minimap minimize 1") -- Re-register WG['minimap'] API: the standard Minimap widget's Initialize -- may have overwritten our registration (it has a higher layer number so -- it initializes after us during luaui reload) @@ -17008,20 +17008,20 @@ function widget:Update(dt) -- In minimap mode, poll MinimapMinimize to honour the user's minimize setting -- Skip while animation is in progress (animation completion handles the state change) if isMinimapMode and not miscState.minimapMinimizeAnimating and not uiState.isAnimating then - local wantMinimized = Spring.GetConfigInt("MinimapMinimize", 0) == 1 + local wantMinimized = SpringUnsynced.GetConfigInt("MinimapMinimize", 0) == 1 if wantMinimized ~= miscState.minimapMinimized then miscState.minimapMinimized = wantMinimized -- Deactivate engine minimap fallback if active (transition code re-fires on next DrawScreen) if miscState.engineMinimapActive then if miscState.baseMinimapIconScale then - Spring.SendCommands("minimap unitsize " .. miscState.baseMinimapIconScale) - Spring.SetConfigFloat("MinimapIconScale", miscState.baseMinimapIconScale) + SpringUnsynced.SendCommands("minimap unitsize " .. miscState.baseMinimapIconScale) + SpringUnsynced.SetConfigFloat("MinimapIconScale", miscState.baseMinimapIconScale) miscState.baseMinimapIconScale = nil end miscState.engineMinimapActive = false end -- Ensure engine minimap stays minimized and slaved (PIP controls rendering) - Spring.SendCommands("minimap minimize 1") + SpringUnsynced.SendCommands("minimap minimize 1") gl.SlaveMiniMap(true) -- Update guishader blur: remove when hidden, re-add when shown if wantMinimized then @@ -17061,7 +17061,7 @@ function widget:Update(dt) -- Update spectating state and check if it changed local oldSpecState = cameraState.mySpecState - local specState, fullviewState = Spring.GetSpectatingState() + local specState, fullviewState = SpringUnsynced.GetSpectatingState() cameraState.mySpecState = specState -- If spec state changed, update LOS texture @@ -17119,23 +17119,23 @@ function widget:Update(dt) for gID in pairs(ghostBuildings) do stale[gID] = true end - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for i = 1, #allUnits do local uID = allUnits[i] - local defID = Spring.GetUnitDefID(uID) + local defID = SpringShared.GetUnitDefID(uID) if defID and cache.isBuilding[defID] then - local uTeam = Spring.GetUnitTeam(uID) + local uTeam = SpringShared.GetUnitTeam(uID) if uTeam then - local uAllyTeam = Spring.GetTeamAllyTeamID(uTeam) + local uAllyTeam = SpringShared.GetTeamAllyTeamID(uTeam) if uAllyTeam ~= scanAllyTeam then -- Only record/keep buildings the viewed allyteam has seen (INLOS or PREVLOS). -- With fullview, GetUnitLosState reliably returns any allyteam's LOS. -- stale[uID] is only cleared inside the PREVLOS check so ghosts for -- buildings the allyteam has NEVER seen get swept (not preserved). - local losBits = Spring.GetUnitLosState(uID, scanAllyTeam, true) + local losBits = SpringShared.GetUnitLosState(uID, scanAllyTeam, true) if losBits and (losBits % 2 >= 1 or losBits % 8 >= 4) then stale[uID] = nil -- seen and still alive, don't sweep - local x, _, z = Spring.GetUnitBasePosition(uID) + local x, _, z = SpringShared.GetUnitBasePosition(uID) if x then local g = ghostBuildings[uID] if g then @@ -17184,7 +17184,7 @@ function widget:Update(dt) interactionState.lastHoverCheckX = mx interactionState.lastHoverCheckY = my - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() local wx, wz = PipToWorldCoords(mx, my) local unitID = GetUnitAtPoint(wx, wz) @@ -17196,7 +17196,7 @@ function widget:Update(dt) -- Validate if this unit is a valid target for the command elseif unitID then local isValidTarget = true - local isAlly = Spring.IsUnitAllied(unitID) + local isAlly = SpringUnsynced.IsUnitAllied(unitID) local setTargetCmd = GameCMD and GameCMD.UNIT_SET_TARGET_NO_GROUND -- Commands that can only target enemy units @@ -17215,11 +17215,11 @@ function widget:Update(dt) -- No active command - check if we should highlight for transport loading or attack elseif unitID then if not frameSel then - frameSel = Spring.GetSelectedUnits() + frameSel = SpringUnsynced.GetSelectedUnits() end local selectedUnits = frameSel local shouldHighlight = false - local isAlly = Spring.IsUnitAllied(unitID) + local isAlly = SpringUnsynced.IsUnitAllied(unitID) if isAlly then -- Check if any transport in selection can load this target unit @@ -17232,7 +17232,7 @@ function widget:Update(dt) else -- Enemy unit - check if any selected unit can attack -- But don't highlight neutral units - local allyTeam = Spring.GetUnitAllyTeam(unitID) + local allyTeam = SpringShared.GetUnitAllyTeam(unitID) local isNeutral = (allyTeam == cache.gaiaAllyTeamID) -- Check if unit is visible (LOS or radar) @@ -17300,10 +17300,10 @@ function widget:Update(dt) drawData.lastSelectionboxEnabled = selectionboxEnabled if selectionboxEnabled then -- Selectionbox widget is now enabled, disable engine's default selection box - Spring.LoadCmdColorsConfig("mouseBoxLineWidth 0") + SpringUnsynced.LoadCmdColorsConfig("mouseBoxLineWidth 0") else -- Selectionbox widget is now disabled, restore engine's default selection box - Spring.LoadCmdColorsConfig("mouseBoxLineWidth 1.5") + SpringUnsynced.LoadCmdColorsConfig("mouseBoxLineWidth 1.5") end end @@ -17332,7 +17332,7 @@ function widget:Update(dt) wallClockTime = wallClockTime + dt -- Update game time (only when game is not paused) - local _, _, isPaused = Spring.GetGameSpeed() + local _, _, isPaused = SpringUnsynced.GetGameSpeed() if not isPaused then gameTime = gameTime + dt end @@ -17363,11 +17363,11 @@ function widget:Update(dt) -- (so transition code re-fires correctly on next unminimize) if miscState.engineMinimapActive then if miscState.baseMinimapIconScale then - Spring.SendCommands("minimap unitsize " .. miscState.baseMinimapIconScale) - Spring.SetConfigFloat("MinimapIconScale", miscState.baseMinimapIconScale) + SpringUnsynced.SendCommands("minimap unitsize " .. miscState.baseMinimapIconScale) + SpringUnsynced.SetConfigFloat("MinimapIconScale", miscState.baseMinimapIconScale) miscState.baseMinimapIconScale = nil end - Spring.SendCommands("minimap minimize 1") + SpringUnsynced.SendCommands("minimap minimize 1") miscState.engineMinimapActive = false end -- Restore full dimensions so maximize animation can use them @@ -17802,9 +17802,9 @@ function widget:Update(dt) if not gameHasStarted and not isMinimapMode then -- Only auto-focus on start position if not spectating or not tracking another player -- Don't do this in minimap mode - the minimap should show the full map - local isSpec = Spring.GetSpectatingState() + local isSpec = SpringUnsynced.GetSpectatingState() if not isSpec and not interactionState.trackingPlayerID then - local newX, _, newZ = Spring.GetTeamStartPosition(Spring.GetMyTeamID()) + local newX, _, newZ = SpringShared.GetTeamStartPosition(Spring.GetMyTeamID()) if newX ~= miscState.startX then miscState.startX, miscState.startZ = newX, newZ -- Apply map margin limits to start position @@ -17827,7 +17827,7 @@ function widget:Update(dt) -- Check for modifier key changes during box selection if interactionState.areBoxSelecting then - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() local modifiersChanged = alt ~= interactionState.lastModifierState[1] or ctrl ~= interactionState.lastModifierState[2] or meta ~= interactionState.lastModifierState[3] or shift ~= interactionState.lastModifierState[4] -- Also check for units moving in/out of selection box (throttled to ~15fps for continuous updates) @@ -17850,7 +17850,7 @@ function widget:Update(dt) WG.SmartSelect_SelectUnits(unitsInBox) else -- Fallback to engine default if smart select is disabled - Spring.SelectUnitArray(unitsInBox, shift) -- shift = append mode + SpringUnsynced.SelectUnitArray(unitsInBox, shift) -- shift = append mode end end end @@ -17865,7 +17865,7 @@ function widget:GameStart() end -- Automatically track the commander at game start (not for spectators or minimap mode) - local spec = Spring.GetSpectatingState() + local spec = SpringUnsynced.GetSpectatingState() if not spec and not isMinimapMode then local commanderID = FindMyCommander() if commanderID then @@ -17876,7 +17876,7 @@ function widget:GameStart() -- On lava/water maps, read the lava level now that the gadget has initialized -- (may not have been available during widget module-level init) if mapInfo.isLava or mapInfo.hasWater then - local lavaLevel = Spring.GetGameRulesParam("lavaLevel") + local lavaLevel = SpringShared.GetGameRulesParam("lavaLevel") if lavaLevel and lavaLevel ~= -99999 then if mapInfo.dynamicWaterLevel ~= lavaLevel then mapInfo.dynamicWaterLevel = lavaLevel @@ -17892,8 +17892,8 @@ function widget:UnitSeismicPing(x, y, z, strength, allyTeam, unitID, unitDefID) end local myAllyTeam = Spring.GetMyAllyTeamID() - local spec, fullview = Spring.GetSpectatingState() - local unitAllyTeam = unitID and Spring.GetUnitAllyTeam(unitID) or allyTeam + local spec, fullview = SpringUnsynced.GetSpectatingState() + local unitAllyTeam = unitID and SpringShared.GetUnitAllyTeam(unitID) or allyTeam if (spec or allyTeam == myAllyTeam) and unitAllyTeam ~= allyTeam then -- Calculate ping radius based on strength (strength is typically 1-10) @@ -17975,7 +17975,7 @@ local function CreateIconShatter(unitID, unitDefID, unitTeam, unitVelX, unitVelZ end -- Ensure icon has size data -- Engine-matching icon size (same as GL4DrawIcons/DrawIcons) local resScale = render.contentScale or 1 - local unitBaseSize = Spring.GetConfigFloat("MinimapIconScale", 3.5) + local unitBaseSize = SpringUnsynced.GetConfigFloat("MinimapIconScale", 3.5) local iconSize = unitBaseSize * (mapInfo.mapSizeX * mapInfo.mapSizeZ / 40000) ^ 0.25 * math.sqrt(cameraState.zoom) * resScale * iconData.size -- Skip shattering for tiny icons (too small to see fragments when zoomed out) @@ -18085,7 +18085,7 @@ function widget:CrashingAircraft(unitID, unitDefID, teamID) -- Create shatter effect with unit's current velocity (skip when minimized) if not uiState.inMinMode then - local vx, vy, vz = Spring.GetUnitVelocity(unitID) + local vx, vy, vz = SpringShared.GetUnitVelocity(unitID) CreateIconShatter(unitID, unitDefID, teamID, vx, vz) end end @@ -18112,7 +18112,7 @@ function widget:UnitDestroyed(unitID, unitDefID, unitTeam) -- Skip when minimized — nothing is being drawn, shatters would be wasted if not miscState.crashingUnits[unitID] and not uiState.inMinMode then -- Get unit velocity so shatter fragments carry the unit's momentum - local vx, vy, vz = Spring.GetUnitVelocity(unitID) + local vx, vy, vz = SpringShared.GetUnitVelocity(unitID) CreateIconShatter(unitID, unitDefID, unitTeam, vx, vz) -- Suppress icon immediately so it doesn't linger during death animation miscState.crashingUnits[unitID] = true @@ -18134,8 +18134,8 @@ function widget:UnitDestroyed(unitID, unitDefID, unitTeam) if ghostBuildings[unitID] then local ghost = ghostBuildings[unitID] if state.losViewEnabled and state.losViewAllyTeam then - local gy = Spring.GetGroundHeight(ghost.x, ghost.z) - if Spring.IsPosInLos(ghost.x, gy, ghost.z, state.losViewAllyTeam) then + local gy = SpringShared.GetGroundHeight(ghost.x, ghost.z) + if SpringShared.IsPosInLos(ghost.x, gy, ghost.z, state.losViewAllyTeam) then ghostBuildings[unitID] = nil -- destroyed in LOS, remove ghost end -- else: destroyed in FoW, ghost persists until LOS reaches the position @@ -18223,12 +18223,12 @@ function widget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOp if interactionState.trackingPlayerID then local _, _, _, playerTeamID = spFunc.GetPlayerInfo(interactionState.trackingPlayerID, false) if playerTeamID then - viewAllyTeam = teamAllyTeamCache[playerTeamID] or Spring.GetTeamAllyTeamID(playerTeamID) + viewAllyTeam = teamAllyTeamCache[playerTeamID] or SpringShared.GetTeamAllyTeamID(playerTeamID) end elseif state.losViewEnabled and state.losViewAllyTeam then viewAllyTeam = state.losViewAllyTeam else - local _, fullview = Spring.GetSpectatingState() + local _, fullview = SpringUnsynced.GetSpectatingState() if not fullview then viewAllyTeam = Spring.GetMyAllyTeamID() end @@ -18346,11 +18346,11 @@ function widget:UnitFinished(unitID, unitDefID, unitTeam) -- Only ghost buildings the viewed allyteam has actually seen (PREVLOS or INLOS) if cameraState.mySpecState and cache.isBuilding[unitDefID] then local myAllyTeam = Spring.GetMyAllyTeamID() - local uAllyTeam = Spring.GetTeamAllyTeamID(unitTeam) + local uAllyTeam = SpringShared.GetTeamAllyTeamID(unitTeam) if uAllyTeam ~= myAllyTeam then - local losBits = Spring.GetUnitLosState(unitID, myAllyTeam, true) + local losBits = SpringShared.GetUnitLosState(unitID, myAllyTeam, true) if losBits and (losBits % 2 >= 1 or losBits % 8 >= 4) then - local x, _, z = Spring.GetUnitBasePosition(unitID) + local x, _, z = SpringShared.GetUnitBasePosition(unitID) if x then ghostBuildings[unitID] = { defID = unitDefID, x = x, z = z, teamID = unitTeam } end @@ -18408,7 +18408,7 @@ function widget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer) -- Bonus scales from +3 at 50% HP to +12 at 0% HP local dangerBonus = (1 - healthFrac * 2) * 12 -- Verify enemy is actually nearby (within 600 elmos) - local nearestEnemy = Spring.GetUnitNearestEnemy(unitID, 600, true) + local nearestEnemy = SpringShared.GetUnitNearestEnemy(unitID, 600, true) if nearestEnemy then weight = weight + dangerBonus end @@ -18428,7 +18428,7 @@ end function widget:UnitEnteredLos(unitID, unitTeam) -- Skip for fullview spectators (they see everything, ghosts are recorded in processUnit) if cameraState.mySpecState then - local _, fullview = Spring.GetSpectatingState() + local _, fullview = SpringUnsynced.GetSpectatingState() if fullview then return end @@ -18507,7 +18507,7 @@ function widget:VisibleExplosion(px, py, pz, weaponID, ownerID) y = py, z = pz, radius = radius, - startFrame = Spring.GetGameFrame(), -- game-frame based: freezes when paused + startFrame = SpringShared.GetGameFrame(), -- game-frame based: freezes when paused randomSeed = math.random() * 1000, -- For consistent per-explosion randomness rotationSpeed = (math.random() - 0.5) * 4, -- Random rotation speed particles = {}, -- Will store particle debris @@ -18526,7 +18526,7 @@ function widget:VisibleExplosion(px, py, pz, weaponID, ownerID) if radius >= 100 then explosion.isBigFlash = true elseif isUnitExplosion and ownerID then - local ownerDefID = Spring.GetUnitDefID(ownerID) + local ownerDefID = SpringShared.GetUnitDefID(ownerID) if ownerDefID and cache.isCommander[ownerDefID] then explosion.isBigFlash = true end @@ -18610,7 +18610,7 @@ function widget:DefaultCommand() local wx, wz = PipToWorldCoords(mx, my) local uID = GetUnitAtPoint(wx, wz) if uID then - if Spring.IsUnitAllied(uID) then + if SpringUnsynced.IsUnitAllied(uID) then return CMD.GUARD else return CMD.ATTACK @@ -18636,7 +18636,7 @@ function widget:MapDrawCmd(playerID, cmdType, mx, my, mz, a, b, c) -- Store point markers for rendering (from any player, but not spectators) if cmdType == "point" then -- Get player's team and spec status - local _, _, isSpec, teamID = Spring.GetPlayerInfo(playerID, false) + local _, _, isSpec, teamID = SpringShared.GetPlayerInfo(playerID, false) -- Add marker if player is not a spectator, or if spectator pings are enabled in minimap mode local showMarker = not isSpec or (isMinimapMode and config.showSpectatorPings) @@ -18689,7 +18689,7 @@ function widget:MapDrawCmd(playerID, cmdType, mx, my, mz, a, b, c) end -- Block activity focus for ignored players (uses WG.ignoredAccounts from api_ignore widget) if triggerFocus and config.activityFocusBlockIgnoredPlayers and WG.ignoredAccounts then - local pName, _, _, _, _, _, _, _, _, _, pInfo = Spring.GetPlayerInfo(playerID) + local pName, _, _, _, _, _, _, _, _, _, pInfo = SpringShared.GetPlayerInfo(playerID) local pAccountID = pInfo and pInfo.accountid and tonumber(pInfo.accountid) if (pName and WG.ignoredAccounts[pName]) or (pAccountID and WG.ignoredAccounts[pAccountID]) then triggerFocus = false @@ -18822,7 +18822,7 @@ function widget:MapDrawCmd(playerID, cmdType, mx, my, mz, a, b, c) if cmdType == "point" then -- Place marker at PiP location - Spring.MarkerAddPoint(wx, markerHeight, wz, c or "") + SpringUnsynced.MarkerAddPoint(wx, markerHeight, wz, c or "") elseif cmdType == "line" then -- For line drawing in PiP - track for continuous drawing @@ -18830,7 +18830,7 @@ function widget:MapDrawCmd(playerID, cmdType, mx, my, mz, a, b, c) -- If we have a previous position, draw line from there to here if interactionState.lastMapDrawX and interactionState.lastMapDrawZ then local lastY = spFunc.GetGroundHeight(interactionState.lastMapDrawX, interactionState.lastMapDrawZ) + 5 - Spring.MarkerAddLine(interactionState.lastMapDrawX, lastY, interactionState.lastMapDrawZ, wx, markerHeight, wz) + SpringUnsynced.MarkerAddLine(interactionState.lastMapDrawX, lastY, interactionState.lastMapDrawZ, wx, markerHeight, wz) end -- Update last position for next segment @@ -18839,7 +18839,7 @@ function widget:MapDrawCmd(playerID, cmdType, mx, my, mz, a, b, c) elseif cmdType == "erase" then -- Erase at the PiP location - use ground height for better detection - Spring.MarkerErasePosition(wx, wy, wz) + SpringUnsynced.MarkerErasePosition(wx, wy, wz) end miscState.isProcessingMapDraw = false @@ -18904,7 +18904,7 @@ function widget:MouseWheel(up, value) if mx >= render.dim.l and mx <= render.dim.r and my >= render.dim.b and my <= render.dim.t then -- When altKeyRequiredForZoom is enabled, pass scroll through unless ALT or middle mouse is held if config.altKeyRequiredForZoom then - local alt = Spring.GetModKeyState() + local alt = SpringUnsynced.GetModKeyState() local _, _, _, middleButton = spFunc.GetMouseState() if not alt and not middleButton then return @@ -18930,7 +18930,7 @@ function widget:MouseWheel(up, value) end local zoomFactor = config.zoomWheel ^ absValue - if Spring.GetConfigInt("ScrollWheelSpeed", 1) > 0 then + if SpringUnsynced.GetConfigInt("ScrollWheelSpeed", 1) > 0 then if up then cameraState.targetZoom = math.max(cameraState.targetZoom / zoomFactor, GetEffectiveZoomMin()) else @@ -19018,11 +19018,11 @@ function widget:MousePress(mx, my, mButton) local btnT = render.dim.t if mx >= btnL and mx <= btnR and my >= btnB and my <= btnT then -- Clear minimized state and start expand animation - Spring.SetConfigInt("MinimapMinimize", 0) + SpringUnsynced.SetConfigInt("MinimapMinimize", 0) miscState.minimapMinimized = false -- Re-establish engine minimap slave and reset fallback so transition code re-fires gl.SlaveMiniMap(true) - Spring.SendCommands("minimap minimize 1") + SpringUnsynced.SendCommands("minimap minimize 1") miscState.engineMinimapActive = false -- Delete stale R2T textures and force full recreation if pipR2T.contentTex then @@ -19080,7 +19080,7 @@ function widget:MousePress(mx, my, mButton) local relY = 1 - ((my - mmBounds.drawB) / mmHeight) -- Flip Y (screen Y is bottom-up, map Z is top-down) -- Apply rotation to account for minimap rotation - local minimapRotation = Spring.GetMiniMapRotation() + local minimapRotation = SpringUnsynced.GetMiniMapRotation() if minimapRotation ~= 0 then -- Convert to center-based coordinates (0.5, 0.5 is center) local centeredX = relX - 0.5 @@ -19191,7 +19191,7 @@ function widget:MousePress(mx, my, mButton) -- Was maximize clicked? (or ALT+drag/middle drag to move window) if (mButton == 1 or mButton == 2) and mx >= uiState.minModeL and mx <= uiState.minModeL + math.floor(render.usedButtonSize * config.maximizeSizemult) and my >= uiState.minModeB and my <= uiState.minModeB + math.floor(render.usedButtonSize * config.maximizeSizemult) then - local altKey = Spring.GetModKeyState() + local altKey = SpringUnsynced.GetModKeyState() -- If ALT is held or middle mouse, start tracking for drag (to move window) if altKey or mButton == 2 then @@ -19268,8 +19268,8 @@ function widget:MousePress(mx, my, mButton) -- Minimizing? (or ALT+drag/middle drag to move window) -- In minimap mode, clicking the minimize button triggers MinimapMinimize (with animation) if isMinimapMode and mx >= render.dim.r - render.usedButtonSize and my >= render.dim.t - render.usedButtonSize then - Spring.SetConfigInt("MinimapMinimize", 1) - Spring.SendCommands("minimap minimize 1") + SpringUnsynced.SetConfigInt("MinimapMinimize", 1) + SpringUnsynced.SendCommands("minimap minimize 1") -- Animate shrink to the maximize button position (top-left corner) local buttonSize = math.floor(render.usedButtonSize * config.maximizeSizemult) uiState.savedDimensions = { @@ -19296,7 +19296,7 @@ function widget:MousePress(mx, my, mButton) return true end if not isMinimapMode and mx >= render.dim.r - render.usedButtonSize and my >= render.dim.t - render.usedButtonSize then - local altKey = Spring.GetModKeyState() + local altKey = SpringUnsynced.GetModKeyState() -- If ALT is held or middle mouse, start tracking for drag (to move window) if altKey or mButton == 2 then @@ -19306,7 +19306,7 @@ function widget:MousePress(mx, my, mButton) end -- Normal minimize (no ALT, left click only) - local sw, sh = Spring.GetWindowGeometry() + local sw, sh = SpringUnsynced.GetWindowGeometry() -- Save current dimensions before minimizing uiState.savedDimensions = { @@ -19375,7 +19375,7 @@ function widget:MousePress(mx, my, mButton) -- Button row if my <= render.dim.b + render.usedButtonSize then -- Calculate visible buttons - local selectedUnits = Spring.GetSelectedUnits() + local selectedUnits = SpringUnsynced.GetSelectedUnits() local hasSelection = #selectedUnits > 0 local isTracking = interactionState.areTracking ~= nil local isTrackingPlayer = interactionState.trackingPlayerID ~= nil @@ -19402,7 +19402,7 @@ function widget:MousePress(mx, my, mButton) if btn.command == "pip_switch" or btn.command == "pip_copy" then skipButton = true elseif btn.command == "pip_view" then - local _, fullview = Spring.GetSpectatingState() + local _, fullview = SpringUnsynced.GetSpectatingState() if not fullview then skipButton = true end @@ -19454,22 +19454,22 @@ function widget:MousePress(mx, my, mButton) -- In minimap mode with leftButtonPansCamera enabled, left-click moves the world camera -- Skip when ALT is held (ALT+left-click is used for panning) - local alt = Spring.GetModKeyState() + local alt = SpringUnsynced.GetModKeyState() if isMinimapMode and IsLeftClickPanActive() and not alt then - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() -- Only move world camera if there's no active command if not cmdID or cmdID == 0 then local groundHeight = spFunc.GetGroundHeight(wx, wz) or 0 - Spring.SetCameraTarget(wx, groundHeight, wz, 0.2) + SpringUnsynced.SetCameraTarget(wx, groundHeight, wz, 0.2) interactionState.worldCameraDragging = true return true end end - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if cmdID then -- Check if this is a build command with shift modifier for drag-to-build - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() -- Don't issue commands if alt is held without shift (user wants to pan instead) -- But if both alt+shift are held with a build command, allow build dragging @@ -19510,7 +19510,7 @@ function widget:MousePress(mx, my, mButton) local supportsArea = (cmdID == CMD.ATTACK or cmdID == CMD.RECLAIM or cmdID == CMD.REPAIR or cmdID == CMD.RESURRECT or cmdID == CMD.CAPTURE or cmdID == CMD.RESTORE or cmdID == CMD.LOAD_UNITS or (setTargetCmd and cmdID == setTargetCmd)) if supportsArea then -- Don't allow area commands as spectator (unless config allows it) - local isSpec = Spring.GetSpectatingState() + local isSpec = SpringUnsynced.GetSpectatingState() local canGiveCommands = not isSpec or config.allowCommandsWhenSpectating if canGiveCommands then -- Start area command drag @@ -19524,7 +19524,7 @@ function widget:MousePress(mx, my, mButton) IssueCommandAtPoint(cmdID, wx, wz, false, false) if not shift then - Spring.SetActiveCommand(0) + SpringUnsynced.SetActiveCommand(0) end return true @@ -19539,7 +19539,7 @@ function widget:MousePress(mx, my, mButton) IssueCommandAtPoint(cmdID, wx, wz, false, false) if not shift then - Spring.SetActiveCommand(0) + SpringUnsynced.SetActiveCommand(0) end return true @@ -19553,7 +19553,7 @@ function widget:MousePress(mx, my, mButton) if not interactionState.arePanning then -- Check if alt is held - if so, don't start box selection (panning will be handled in MouseMove) -- Also don't allow box selection when tracking a player's camera - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if not alt and not interactionState.trackingPlayerID then if IsLeftClickPanActive() and not interactionState.trackingPlayerID then interactionState.arePanning = true @@ -19568,7 +19568,7 @@ function widget:MousePress(mx, my, mButton) else -- Start box selection instead -- Save current selection before starting box selection - interactionState.selectionBeforeBox = Spring.GetSelectedUnits() + interactionState.selectionBeforeBox = SpringUnsynced.GetSelectedUnits() interactionState.areBoxSelecting = true interactionState.boxSelectStartX = mx @@ -19576,7 +19576,7 @@ function widget:MousePress(mx, my, mButton) interactionState.boxSelectEndX = mx interactionState.boxSelectEndY = my -- Initialize modifier state - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() interactionState.lastModifierState = { alt, ctrl, meta, shift } -- Check if we're starting a deselection (Ctrl held) interactionState.areBoxDeselecting = ctrl @@ -19598,11 +19598,11 @@ function widget:MousePress(mx, my, mButton) end -- Check if there's an active command (FIGHT, ATTACK, PATROL can be formation commands) - local _, activeCmd = Spring.GetActiveCommand() + local _, activeCmd = SpringUnsynced.GetActiveCommand() -- If it's a non-formation command, just clear it if activeCmd and activeCmd ~= CMD.FIGHT and activeCmd ~= CMD.ATTACK and activeCmd ~= CMD.PATROL then - Spring.SetActiveCommand(0) + SpringUnsynced.SetActiveCommand(0) return true end @@ -19619,9 +19619,9 @@ function widget:MousePress(mx, my, mButton) if not cmdID then local uID = GetUnitAtPoint(wx, wz) if uID then - if Spring.IsUnitAllied(uID) then + if SpringUnsynced.IsUnitAllied(uID) then -- Check if we should use LOAD_UNITS command - local selectedUnits = Spring.GetSelectedUnits() + local selectedUnits = SpringUnsynced.GetSelectedUnits() local canLoadTarget = false -- Check if any transport in selection can load this target unit @@ -19634,7 +19634,7 @@ function widget:MousePress(mx, my, mButton) if canLoadTarget then -- Don't allow area LOAD_UNITS as spectator (unless config allows it) - local isSpec = Spring.GetSpectatingState() + local isSpec = SpringUnsynced.GetSpectatingState() local canGiveCommands = not isSpec or config.allowCommandsWhenSpectating if canGiveCommands then -- Start area LOAD_UNITS drag instead of formation @@ -19642,7 +19642,7 @@ function widget:MousePress(mx, my, mButton) interactionState.areaCommandStartX = mx interactionState.areaCommandStartY = my -- Temporarily set LOAD_UNITS as active command for area drag - Spring.SetActiveCommand(Spring.GetCmdDescIndex(CMD.LOAD_UNITS)) + SpringUnsynced.SetActiveCommand(SpringUnsynced.GetCmdDescIndex(CMD.LOAD_UNITS)) return true end else @@ -19672,13 +19672,13 @@ function widget:MousePress(mx, my, mButton) if actualCmd then -- Don't allow formation dragging as spectator (unless config allows it) - local isSpec = Spring.GetSpectatingState() + local isSpec = SpringUnsynced.GetSpectatingState() local canGiveCommands = not isSpec or config.allowCommandsWhenSpectating if canGiveCommands then -- Start formation with world position -- Note: third parameter is fromMinimap, not shift behavior -- Check if we should queue commands (only for single unit) - local selectedUnits = Spring.GetSelectedUnits() + local selectedUnits = SpringUnsynced.GetSelectedUnits() local shouldQueue = selectedUnits and #selectedUnits == 1 -- Don't set pipForceShift yet - first command should replace, not queue @@ -19704,14 +19704,14 @@ end function widget:MouseMove(mx, my, dx, dy, mButton) -- Get modifier key states - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() -- Handle world camera dragging (leftButtonPansCamera mode in minimap mode) if interactionState.worldCameraDragging then -- Convert PIP coordinates to world coordinates and move world camera local wx, wz = PipToWorldCoords(mx, my) local groundHeight = spFunc.GetGroundHeight(wx, wz) or 0 - Spring.SetCameraTarget(wx, groundHeight, wz, 0.04) + SpringUnsynced.SetCameraTarget(wx, groundHeight, wz, 0.04) return true end @@ -19726,7 +19726,7 @@ function widget:MouseMove(mx, my, dx, dy, mButton) local relY = 1 - ((my - mmBounds.drawB) / mmHeight) -- Flip Y (screen Y is bottom-up, map Z is top-down) -- Apply inverse rotation to account for minimap rotation - local minimapRotation = Spring.GetMiniMapRotation() + local minimapRotation = SpringUnsynced.GetMiniMapRotation() if minimapRotation ~= 0 then -- Convert to center-based coordinates (0.5, 0.5 is center) local centeredX = relX - 0.5 @@ -19887,7 +19887,7 @@ function widget:MouseMove(mx, my, dx, dy, mButton) -- Skip if we're already doing minimize button drag if interactionState.leftMousePressed and alt and not interactionState.arePanning and not interactionState.minimizeButtonDragging and interactionState.minimizeButtonClickStartX == 0 and mx >= render.dim.l and mx <= render.dim.r and my >= render.dim.b and my <= render.dim.t then -- Check if we're holding a build command with shift (queuing buildings) - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() local isBuildCommand = (cmdID and cmdID < 0) local isQueueingBuilds = (isBuildCommand and shift) @@ -19905,7 +19905,7 @@ function widget:MouseMove(mx, my, dx, dy, mButton) interactionState.areBoxDeselecting = false -- Restore selection to what it was before box selection started if interactionState.selectionBeforeBox then - Spring.SelectUnitArray(interactionState.selectionBeforeBox) + SpringUnsynced.SelectUnitArray(interactionState.selectionBeforeBox) interactionState.selectionBeforeBox = nil end if WG.SmartSelect_ClearReference then @@ -20042,7 +20042,7 @@ function widget:MouseMove(mx, my, dx, dy, mButton) -- Pan the camera based on mouse movement (only if there's movement) if dx ~= 0 or dy ~= 0 then -- Get current minimap rotation (must fetch fresh) - local minimapRotation = Spring.GetMiniMapRotation and Spring.GetMiniMapRotation() or 0 + local minimapRotation = SpringUnsynced.GetMiniMapRotation and SpringUnsynced.GetMiniMapRotation() or 0 -- Apply inverse rotation to mouse deltas if minimap is rotated local panDx, panDy = dx, dy @@ -20078,9 +20078,9 @@ function widget:MouseMove(mx, my, dx, dy, mButton) -- Warp mouse back to center after processing movement local centerX = math.floor((render.dim.l + render.dim.r) / 2) local centerY = math.floor((render.dim.b + render.dim.t) / 2) - Spring.WarpMouse(centerX, centerY) + SpringUnsynced.WarpMouse(centerX, centerY) -- Reapply the current cursor to prevent it from disappearing after warp - Spring.SetMouseCursor(Spring.GetMouseCursor()) + SpringUnsynced.SetMouseCursor(SpringUnsynced.GetMouseCursor()) end elseif interactionState.areBoxSelecting then @@ -20099,10 +20099,10 @@ function widget:MouseMove(mx, my, dx, dy, mButton) WG.SmartSelect_SelectUnits(unitsInBox) else -- Fallback to engine default if smart select is disabled - local _, ctrl, _, shift = Spring.GetModKeyState() + local _, ctrl, _, shift = SpringUnsynced.GetModKeyState() if ctrl then -- Deselect mode - local currentSelection = Spring.GetSelectedUnits() + local currentSelection = SpringUnsynced.GetSelectedUnits() local newSelection = {} local unitsToDeselect = {} local boxCount = #unitsInBox @@ -20116,9 +20116,9 @@ function widget:MouseMove(mx, my, dx, dy, mButton) newSelection[#newSelection + 1] = unitID end end - Spring.SelectUnitArray(newSelection) + SpringUnsynced.SelectUnitArray(newSelection) else - Spring.SelectUnitArray(unitsInBox, shift) -- shift = append mode + SpringUnsynced.SelectUnitArray(unitsInBox, shift) -- shift = append mode end end end @@ -20145,10 +20145,10 @@ function widget:MouseMove(mx, my, dx, dy, mButton) local startWX, startWZ = PipToWorldCoords(interactionState.buildDragStartX, interactionState.buildDragStartY) local endWX, endWZ = PipToWorldCoords(mx, my) - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if cmdID and cmdID < 0 then local buildDefID = -cmdID - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() interactionState.buildDragPositions = CalculateBuildDragPositions(startWX, startWZ, endWX, endWZ, buildDefID, alt, ctrl, shift) end @@ -20164,10 +20164,10 @@ function widget:KeyRelease(key) local startWX, startWZ = PipToWorldCoords(interactionState.buildDragStartX, interactionState.buildDragStartY) local endWX, endWZ = PipToWorldCoords(mx, my) - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if cmdID and cmdID < 0 then local buildDefID = -cmdID - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() interactionState.buildDragPositions = CalculateBuildDragPositions(startWX, startWZ, endWX, endWZ, buildDefID, alt, ctrl, shift) end @@ -20210,7 +20210,7 @@ function widget:MouseRelease(mx, my, mButton) interactionState.isMouseOverPip = false else -- Minimize (we were in maximized mode) - local sw, sh = Spring.GetWindowGeometry() + local sw, sh = SpringUnsynced.GetWindowGeometry() -- Save current dimensions before minimizing uiState.savedDimensions = { @@ -20316,33 +20316,33 @@ function widget:MouseRelease(mx, my, mButton) if uID then -- Clicked on a unit - select it - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if ctrl then -- Ctrl+click: toggle selection if spFunc.IsUnitSelected(uID) then - local currentSelection = Spring.GetSelectedUnits() + local currentSelection = SpringUnsynced.GetSelectedUnits() local newSelection = {} for i = 1, #currentSelection do if currentSelection[i] ~= uID then newSelection[#newSelection + 1] = currentSelection[i] end end - Spring.SelectUnitArray(newSelection) + SpringUnsynced.SelectUnitArray(newSelection) else - Spring.SelectUnitArray({ uID }, true) + SpringUnsynced.SelectUnitArray({ uID }, true) end elseif shift then -- Shift+click: add to selection - Spring.SelectUnitArray({ uID }, true) + SpringUnsynced.SelectUnitArray({ uID }, true) else -- Normal click: select only this unit - Spring.SelectUnitArray({ uID }, false) + SpringUnsynced.SelectUnitArray({ uID }, false) end else -- Clicked empty space - deselect unless shift is held - local _, _, _, shift = Spring.GetModKeyState() + local _, _, _, shift = SpringUnsynced.GetModKeyState() if not shift then - Spring.SelectUnitArray({}) + SpringUnsynced.SelectUnitArray({}) end end @@ -20376,7 +20376,7 @@ function widget:MouseRelease(mx, my, mButton) if interactionState.areBoxDeselecting then -- Final deselection - remove units in box from current selection - local currentSelection = Spring.GetSelectedUnits() + local currentSelection = SpringUnsynced.GetSelectedUnits() local newSelection = {} -- Create a set for fast lookup of units to deselect local unitsToDeselect = {} @@ -20390,20 +20390,20 @@ function widget:MouseRelease(mx, my, mButton) newSelection[#newSelection + 1] = unitID end end - Spring.SelectUnitArray(newSelection) + SpringUnsynced.SelectUnitArray(newSelection) else -- Regular selection if WG.SmartSelect_SelectUnits then WG.SmartSelect_SelectUnits(unitsInBox) else -- Fallback if smart select is not available - local _, _, _, shift = Spring.GetModKeyState() + local _, _, _, shift = SpringUnsynced.GetModKeyState() if #unitsInBox > 0 then - Spring.SelectUnitArray(unitsInBox, shift) + SpringUnsynced.SelectUnitArray(unitsInBox, shift) else -- No units in box - clear selection unless shift is held if not shift then - Spring.SelectUnitArray({}) + SpringUnsynced.SelectUnitArray({}) end end end @@ -20413,35 +20413,35 @@ function widget:MouseRelease(mx, my, mButton) local wx, wz = PipToWorldCoords(mx, my) local uID = GetUnitAtPoint(wx, wz) if uID then - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if ctrl then -- Ctrl+click: toggle selection (add if not selected, remove if selected) if spFunc.IsUnitSelected(uID) then -- Deselect it - local currentSelection = Spring.GetSelectedUnits() + local currentSelection = SpringUnsynced.GetSelectedUnits() local newSelection = {} for i = 1, #currentSelection do if currentSelection[i] ~= uID then newSelection[#newSelection + 1] = currentSelection[i] end end - Spring.SelectUnitArray(newSelection) + SpringUnsynced.SelectUnitArray(newSelection) else -- Add to selection - Spring.SelectUnitArray({ uID }, true) + SpringUnsynced.SelectUnitArray({ uID }, true) end elseif shift then -- Shift+click: add to selection - Spring.SelectUnitArray({ uID }, true) + SpringUnsynced.SelectUnitArray({ uID }, true) else -- Normal click without modifier: select only this unit (replace selection) - Spring.SelectUnitArray({ uID }, false) + SpringUnsynced.SelectUnitArray({ uID }, false) end else -- Clicked empty space - deselect unless shift is held - local _, _, _, shift = Spring.GetModKeyState() + local _, _, _, shift = SpringUnsynced.GetModKeyState() if not shift then - Spring.SelectUnitArray({}) + SpringUnsynced.SelectUnitArray({}) end end end @@ -20464,7 +20464,7 @@ function widget:MouseRelease(mx, my, mButton) if mx >= render.dim.l and mx <= render.dim.r and my >= render.dim.b and my <= render.dim.t then local wx, wz = PipToWorldCoords(mx, my) local startWX, startWZ = PipToWorldCoords(interactionState.areaCommandStartX, interactionState.areaCommandStartY) - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if cmdID and cmdID > 0 then -- Check if this is a set target command @@ -20482,12 +20482,12 @@ function widget:MouseRelease(mx, my, mButton) if dragDistX > minDragDistance or dragDistY > minDragDistance then -- It's a drag - issue area set target command - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() local cmdOpts = GetCmdOpts(alt, ctrl, meta, shift, false) GiveNotifyingOrder(cmdID, { targetID, startWX, spFunc.GetGroundHeight(startWX, startWZ), startWZ, radius }, cmdOpts) else -- It's a click - issue single set target command - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() local cmdOpts = GetCmdOpts(alt, ctrl, meta, shift, false) GiveNotifyingOrder(cmdID, { targetID }, cmdOpts) end @@ -20508,9 +20508,9 @@ function widget:MouseRelease(mx, my, mButton) end end - local _, _, _, shift = Spring.GetModKeyState() + local _, _, _, shift = SpringUnsynced.GetModKeyState() if not shift then - Spring.SetActiveCommand(0) + SpringUnsynced.SetActiveCommand(0) end end end @@ -20548,9 +20548,9 @@ function widget:MouseRelease(mx, my, mButton) local cmdID = nil local uID = GetUnitAtPoint(wx, wz) if uID then - if Spring.IsUnitAllied(uID) then + if SpringUnsynced.IsUnitAllied(uID) then -- Check if we should use LOAD_UNITS command - local selectedUnits = Spring.GetSelectedUnits() + local selectedUnits = SpringUnsynced.GetSelectedUnits() local canLoadTarget = false -- Check if any transport in selection can load this target unit @@ -20593,10 +20593,10 @@ function widget:MouseRelease(mx, my, mButton) local dragDistY = math.abs(my - interactionState.buildDragStartY) local isDrag = dragDistX > minDragDistance or dragDistY > minDragDistance - local _, cmdID = Spring.GetActiveCommand() + local _, cmdID = SpringUnsynced.GetActiveCommand() if cmdID and cmdID < 0 then local buildDefID = -cmdID - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if isDrag and #interactionState.buildDragPositions > 0 then -- Issue build commands for all positions (force queue for multiple commands) @@ -20611,7 +20611,7 @@ function widget:MouseRelease(mx, my, mButton) end if not shift then - Spring.SetActiveCommand(0) + SpringUnsynced.SetActiveCommand(0) end end @@ -20635,7 +20635,7 @@ function widget:MouseRelease(mx, my, mButton) local groundHeight = spFunc.GetGroundHeight(wx, wz) or 0 -- Get current camera state - local curCamState = Spring.GetCameraState() + local curCamState = SpringUnsynced.GetCameraState() if curCamState then -- Set position curCamState.px = wx @@ -20691,10 +20691,10 @@ function widget:MouseRelease(mx, my, mButton) end end - Spring.SetCameraState(curCamState, 0.2) + SpringUnsynced.SetCameraState(curCamState, 0.2) else -- Fallback: just move camera target without zoom change - Spring.SetCameraTarget(wx, groundHeight, wz, 0.2) + SpringUnsynced.SetCameraTarget(wx, groundHeight, wz, 0.2) end end diff --git a/luaui/Widgets/gui_point_tracker.lua b/luaui/Widgets/gui_point_tracker.lua index 97594d436e2..61086db83c2 100644 --- a/luaui/Widgets/gui_point_tracker.lua +++ b/luaui/Widgets/gui_point_tracker.lua @@ -14,8 +14,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo local timeToLive = 330 local lineWidth = 1.0 @@ -26,10 +26,10 @@ local getCurrentMiniMapRotationOption = VFS.Include("luaui/Include/minimap_utils --speedups ---------------------------------------------------------------- -local ArePlayersAllied = Spring.ArePlayersAllied -local GetPlayerInfo = Spring.GetPlayerInfo -local GetTeamColor = Spring.GetTeamColor -local GetSpectatingState = Spring.GetSpectatingState +local ArePlayersAllied = SpringShared.ArePlayersAllied +local GetPlayerInfo = SpringShared.GetPlayerInfo +local GetTeamColor = SpringUnsynced.GetTeamColor +local GetSpectatingState = SpringUnsynced.GetSpectatingState local glLineWidth = gl.LineWidth @@ -48,7 +48,7 @@ local instanceIDgen = 1 local function GetPlayerColor(playerID) local _, _, isSpec, teamID = GetPlayerInfo(playerID, false) if isSpec then - return GetTeamColor(Spring.GetGaiaTeamID()) + return GetTeamColor(SpringShared.GetGaiaTeamID()) end if not teamID then return nil diff --git a/luaui/Widgets/gui_pregame_build.lua b/luaui/Widgets/gui_pregame_build.lua index 763df709162..fe77dc29e94 100644 --- a/luaui/Widgets/gui_pregame_build.lua +++ b/luaui/Widgets/gui_pregame_build.lua @@ -24,14 +24,14 @@ local tableInsert = table.insert local tableRemove = table.remove -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay -local spGetGroundHeight = Spring.GetGroundHeight -local spEcho = Spring.Echo +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetGroundHeight = SpringShared.GetGroundHeight +local spEcho = SpringShared.Echo -local spTestBuildOrder = Spring.TestBuildOrder +local spTestBuildOrder = SpringShared.TestBuildOrder local spawnWarpInFrame = Game.spawnWarpInFrame @@ -50,10 +50,10 @@ local buildModeState = { local prevShiftState = false -local isSpec = Spring.GetSpectatingState() +local isSpec = SpringUnsynced.GetSpectatingState() local myTeamID = spGetMyTeamID() local preGamestartPlayer = spGetGameFrame() == 0 and not isSpec -local startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") +local startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") local prevStartDefID = startDefID local isMetalMap = false @@ -85,18 +85,18 @@ local function buildFacingHandler(command, line, args) return end - local facing = Spring.GetBuildFacing() + local facing = SpringUnsynced.GetBuildFacing() local action = args and args[1] if action == "inc" then facing = (facing + 1) % 4 - Spring.SetBuildFacing(facing) + SpringUnsynced.SetBuildFacing(facing) return true elseif action == "dec" then facing = (facing - 1) % 4 - Spring.SetBuildFacing(facing) + SpringUnsynced.SetBuildFacing(facing) return true elseif action and facingMap[action] then - Spring.SetBuildFacing(facingMap[action]) + SpringUnsynced.SetBuildFacing(facingMap[action]) return true end end @@ -151,18 +151,18 @@ local function setPreGamestartDefID(uDefID) local isMex = UnitDefs[uDefID] and UnitDefs[uDefID].extractsMetal > 0 if isMex then - if Spring.GetMapDrawMode() ~= "metal" then - Spring.SendCommands("ShowMetalMap") + if SpringUnsynced.GetMapDrawMode() ~= "metal" then + SpringUnsynced.SendCommands("ShowMetalMap") end - elseif Spring.GetMapDrawMode() == "metal" then - Spring.SendCommands("ShowStandard") + elseif SpringUnsynced.GetMapDrawMode() == "metal" then + SpringUnsynced.SendCommands("ShowStandard") end return true end local function GetUnitCanCompleteQueue(unitID) - local unitDefID = Spring.GetUnitDefID(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) if unitDefID == startDefID then return true end @@ -206,7 +206,7 @@ local function buildmenuPregameDeselectHandler() end local function convertBuildQueueFaction(previousFactionSide, currentFactionSide) - Spring.Log("gui_pregame_build", LOG.DEBUG, string.format("Calling SubLogic.processBuildQueueSubstitution (in-place) from %s to %s for %d queue items.", previousFactionSide, currentFactionSide, #buildQueue)) + SpringShared.Log("gui_pregame_build", LOG.DEBUG, string.format("Calling SubLogic.processBuildQueueSubstitution (in-place) from %s to %s for %d queue items.", previousFactionSide, currentFactionSide, #buildQueue)) local result = SubLogic.processBuildQueueSubstitution(buildQueue, previousFactionSide, currentFactionSide) if result.substitutionFailed then @@ -216,7 +216,7 @@ end local function handleSelectedBuildingConversion(currentSelDefID, prevFactionSide, currentFactionSide, currentSelBuildData) if not currentSelDefID then - Spring.Log("gui_pregame_build", LOG.WARNING, "handleSelectedBuildingConversion: Called with nil currentSelDefID.") + SpringShared.Log("gui_pregame_build", LOG.WARNING, "handleSelectedBuildingConversion: Called with nil currentSelDefID.") return currentSelDefID end @@ -234,9 +234,9 @@ local function handleSelectedBuildingConversion(currentSelDefID, prevFactionSide if prevFactionSide ~= currentFactionSide then local originalUnitDef = UnitDefs[currentSelDefID] local originalUnitName = originalUnitDef and (originalUnitDef.humanName or originalUnitDef.name) or ("UnitDefID " .. tostring(currentSelDefID)) - Spring.Log("gui_pregame_build", LOG.INFO, string.format("Selected item '%s' remains unchanged for %s faction (or was already target faction).", originalUnitName, currentFactionSide)) + SpringShared.Log("gui_pregame_build", LOG.INFO, string.format("Selected item '%s' remains unchanged for %s faction (or was already target faction).", originalUnitName, currentFactionSide)) else - Spring.Log("gui_pregame_build", LOG.DEBUG, string.format("selBuildQueueDefID %s remained unchanged (sides were the same: %s).", tostring(currentSelDefID), currentFactionSide)) + SpringShared.Log("gui_pregame_build", LOG.DEBUG, string.format("selBuildQueueDefID %s remained unchanged (sides were the same: %s).", tostring(currentSelDefID), currentFactionSide)) end end return newSelDefID @@ -251,12 +251,12 @@ function widget:Initialize() widgetHandler:AddAction("buildspacing", buildSpacingHandler, nil, "p") widgetHandler:AddAction("buildmenu_pregame_deselect", buildmenuPregameDeselectHandler, nil, "p") - Spring.Log(widget:GetInfo().name, LOG.INFO, "Pregame Queue Initializing. Local SubLogic is assumed available.") + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "Pregame Queue Initializing. Local SubLogic is assumed available.") -- Get our starting unit if preGamestartPlayer then - if not startDefID or startDefID ~= Spring.GetTeamRulesParam(myTeamID, "startUnit") then - startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") + if not startDefID or startDefID ~= SpringShared.GetTeamRulesParam(myTeamID, "startUnit") then + startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") end end @@ -274,7 +274,7 @@ function widget:Initialize() inBuildOptions[opt] = true end else - Spring.Log(widget:GetInfo().name, LOG.WARNING, "setPreGamestartDefID: startDefID is nil or invalid, cannot determine build options.") + SpringShared.Log(widget:GetInfo().name, LOG.WARNING, "setPreGamestartDefID: startDefID is nil or invalid, cannot determine build options.") end if inBuildOptions[value] then @@ -631,11 +631,11 @@ end local function getMouseWorldPosition(unitDefID, x, y) local _, pos = spTraceScreenRay(x, y, true, false, false, isUnderwater(unitDefID)) if pos then - local buildFacing = Spring.GetBuildFacing() + local buildFacing = SpringUnsynced.GetBuildFacing() local posX = pos.x or pos[1] local posY = pos.y or pos[2] local posZ = pos.z or pos[3] - local bx, by, bz = Spring.Pos2BuildPos(unitDefID, posX, posY, posZ, buildFacing) + local bx, by, bz = SpringShared.Pos2BuildPos(unitDefID, posX, posY, posZ, buildFacing) return { x = bx, y = by, z = bz } end return nil @@ -656,7 +656,7 @@ function widget:Update(dt) local x, y, leftButton = spGetMouseState() - local _, _, _, shift = Spring.GetModKeyState() + local _, _, _, shift = SpringUnsynced.GetModKeyState() if prevShiftState and not shift and selBuildQueueDefID then setPreGamestartDefID(nil) end @@ -671,15 +671,15 @@ function widget:Update(dt) local buildPosY = buildPos.y local buildPosZ = buildPos.z local buildPosFacing = buildPos.facing - local posX, posY, posZ = Spring.Pos2BuildPos(selBuildQueueDefID, buildPosX, buildPosY, buildPosZ, buildPosFacing or Spring.GetBuildFacing()) - local buildFacingPos = buildPosFacing or Spring.GetBuildFacing() + local posX, posY, posZ = SpringShared.Pos2BuildPos(selBuildQueueDefID, buildPosX, buildPosY, buildPosZ, buildPosFacing or SpringUnsynced.GetBuildFacing()) + local buildFacingPos = buildPosFacing or SpringUnsynced.GetBuildFacing() local buildDataPos = { selBuildQueueDefID, posX, posY, posZ, buildFacingPos } local hasConflicts = false - local cx, cy, cz = Spring.GetTeamStartPosition(myTeamID) + local cx, cy, cz = SpringShared.GetTeamStartPosition(myTeamID) if cx ~= -100 then - local cbx, cby, cbz = Spring.Pos2BuildPos(startDefID, cx, cy, cz) + local cbx, cby, cbz = SpringShared.Pos2BuildPos(startDefID, cx, cy, cz) if DoBuildingsClash(buildDataPos, { startDefID, cbx, cby, cbz, 1 }) then hasConflicts = true end @@ -693,7 +693,7 @@ function widget:Update(dt) end end end - if not hasConflicts and Spring.TestBuildOrder(selBuildQueueDefID, posX, posY, posZ, buildFacingPos) == 0 then + if not hasConflicts and SpringShared.TestBuildOrder(selBuildQueueDefID, posX, posY, posZ, buildFacingPos) == 0 then hasConflicts = true end if not hasConflicts then @@ -724,7 +724,7 @@ function widget:Update(dt) return end - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if not shift and buildModeState.startPosition then buildModeState.startPosition = nil @@ -747,7 +747,7 @@ function widget:Update(dt) buildModeState.endPosition = endPosition buildModeState.buildAroundTarget = buildAroundTarget - local buildFacing = Spring.GetBuildFacing() + local buildFacing = SpringUnsynced.GetBuildFacing() local mode = determineBuildMode(modKeys, buildAroundTarget, buildModeState.startPosition) buildModeState.mode = mode @@ -761,7 +761,7 @@ function widget:Update(dt) end function widget:MousePress(mx, my, button) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end @@ -772,7 +772,7 @@ function widget:MousePress(mx, my, button) if not preGamestartPlayer then return end - local _, _, meta, shift = Spring.GetModKeyState() + local _, _, meta, shift = SpringUnsynced.GetModKeyState() if button == 3 and selBuildQueueDefID then setPreGamestartDefID(nil) @@ -796,11 +796,11 @@ function widget:MousePress(mx, my, button) return false end - local alt, ctrl = Spring.GetModKeyState() + local alt, ctrl = SpringUnsynced.GetModKeyState() if button == 1 and shift and ctrl then local buildAroundTarget = getGhostBuildingUnderCursor(mx, my) if buildAroundTarget then - local buildFacing = Spring.GetBuildFacing() + local buildFacing = SpringUnsynced.GetBuildFacing() local aroundPositions = BUILD_POSITION_FUNCTIONS[BUILD_MODE.AROUND](selBuildQueueDefID, buildFacing, buildAroundTarget) if #aroundPositions > 0 then @@ -812,7 +812,7 @@ function widget:MousePress(mx, my, button) local buildPosY = buildPos.y local buildPosZ = buildPos.z local buildPosFacing = buildPos.facing - local posX, posY, posZ = Spring.Pos2BuildPos(selBuildQueueDefID, buildPosX, buildPosY, buildPosZ, buildPosFacing or buildFacing) + local posX, posY, posZ = SpringShared.Pos2BuildPos(selBuildQueueDefID, buildPosX, buildPosY, buildPosZ, buildPosFacing or buildFacing) local buildFacingPos = buildPosFacing or buildFacing local buildDataPos = { selBuildQueueDefID, posX, posY, posZ, buildFacingPos } @@ -845,15 +845,15 @@ function widget:MousePress(mx, my, button) local hasConflicts = false - local cx, cy, cz = Spring.GetTeamStartPosition(myTeamID) + local cx, cy, cz = SpringShared.GetTeamStartPosition(myTeamID) if cx ~= -100 then - local cbx, cby, cbz = Spring.Pos2BuildPos(startDefID, cx, cy, cz) + local cbx, cby, cbz = SpringShared.Pos2BuildPos(startDefID, cx, cy, cz) if DoBuildingsClash(buildDataPos, { startDefID, cbx, cby, cbz, 1 }) then hasConflicts = true end end - if not hasConflicts and Spring.TestBuildOrder(selBuildQueueDefID, posX, posY, posZ, buildFacingPos) == 0 then + if not hasConflicts and SpringShared.TestBuildOrder(selBuildQueueDefID, posX, posY, posZ, buildFacingPos) == 0 then hasConflicts = true end @@ -897,15 +897,15 @@ function widget:MousePress(mx, my, button) return end - local buildFacing = Spring.GetBuildFacing() + local buildFacing = SpringUnsynced.GetBuildFacing() local posX = pos.x or pos[1] local posY = pos.y or pos[2] local posZ = pos.z or pos[3] - local bx, by, bz = Spring.Pos2BuildPos(selBuildQueueDefID, posX, posY, posZ, buildFacing) + local bx, by, bz = SpringShared.Pos2BuildPos(selBuildQueueDefID, posX, posY, posZ, buildFacing) local buildData = { selBuildQueueDefID, bx, by, bz, buildFacing } - local cx, cy, cz = Spring.GetTeamStartPosition(myTeamID) + local cx, cy, cz = SpringShared.GetTeamStartPosition(myTeamID) - local alt, ctrl = Spring.GetModKeyState() + local alt, ctrl = SpringUnsynced.GetModKeyState() local isMex = UnitDefs[selBuildQueueDefID] and UnitDefs[selBuildQueueDefID].extractsMetal > 0 if shift and not buildModeState.startPosition and not (isMex and not isMetalMap) then @@ -916,19 +916,19 @@ function widget:MousePress(mx, my, button) end if (meta or not shift) and cx ~= -100 then - local cbx, cby, cbz = Spring.Pos2BuildPos(startDefID, cx, cy, cz) + local cbx, cby, cbz = SpringShared.Pos2BuildPos(startDefID, cx, cy, cz) if DoBuildingsClash(buildData, { startDefID, cbx, cby, cbz, 1 }) then return true end end - if Spring.TestBuildOrder(selBuildQueueDefID, bx, by, bz, buildFacing) ~= 0 then + if SpringShared.TestBuildOrder(selBuildQueueDefID, bx, by, bz, buildFacing) ~= 0 then local hasConflicts = false - local cx, cy, cz = Spring.GetTeamStartPosition(myTeamID) + local cx, cy, cz = SpringShared.GetTeamStartPosition(myTeamID) if cx ~= -100 then - local cbx, cby, cbz = Spring.Pos2BuildPos(startDefID, cx, cy, cz) + local cbx, cby, cbz = SpringShared.Pos2BuildPos(startDefID, cx, cy, cz) if DoBuildingsClash(buildData, { startDefID, cbx, cby, cbz, 1 }) then hasConflicts = true end @@ -984,7 +984,7 @@ function widget:MousePress(mx, my, button) if not pos then return end - local cbx, cby, cbz = Spring.Pos2BuildPos(startDefID, pos[1], pos[2], pos[3]) + local cbx, cby, cbz = SpringShared.Pos2BuildPos(startDefID, pos[1], pos[2], pos[3]) if DoBuildingsClash({ startDefID, cbx, cby, cbz, 1 }, buildQueue[1]) then return true @@ -1060,17 +1060,17 @@ function widget:DrawWorld() local x, y, _ = spGetMouseState() local _, pos = spTraceScreenRay(x, y, true, false, false, isUnderwater(selBuildQueueDefID)) if pos then - local buildFacing = Spring.GetBuildFacing() - local bx, by, bz = Spring.Pos2BuildPos(selBuildQueueDefID, pos[1], pos[2], pos[3], buildFacing) + local buildFacing = SpringUnsynced.GetBuildFacing() + local bx, by, bz = SpringShared.Pos2BuildPos(selBuildQueueDefID, pos[1], pos[2], pos[3], buildFacing) selBuildData = { selBuildQueueDefID, bx, by, bz, buildFacing } end end - if startDefID ~= Spring.GetTeamRulesParam(myTeamID, "startUnit") then - startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit") + if startDefID ~= SpringShared.GetTeamRulesParam(myTeamID, "startUnit") then + startDefID = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") end - local sx, sy, sz = Spring.GetTeamStartPosition(myTeamID) -- Returns 0, 0, 0 when none chosen (was -100, -100, -100 previously) + local sx, sy, sz = SpringShared.GetTeamStartPosition(myTeamID) -- Returns 0, 0, 0 when none chosen (was -100, -100, -100 previously) --should startposition not match 0,0,0 and no commander is placed, then there is a green circle on the map till one is placed --TODO: be based on the map, if position is changed from default(?) local startChosen = (sx ~= 0) or (sy ~= 0) or (sz ~= 0) @@ -1100,9 +1100,9 @@ function widget:DrawWorld() selBuildQueueDefID = handleSelectedBuildingConversion(selBuildQueueDefID, previousFactionSide, currentFactionSide, selBuildData) end elseif previousFactionSide and currentFactionSide and previousFactionSide == currentFactionSide then - Spring.Log(widget:GetInfo().name, LOG.DEBUG, string.format("Sides determined but are the same (%s), no conversion needed.", currentFactionSide)) + SpringShared.Log(widget:GetInfo().name, LOG.DEBUG, string.format("Sides determined but are the same (%s), no conversion needed.", currentFactionSide)) else - Spring.Log(widget:GetInfo().name, LOG.WARNING, string.format("Could not determine sides for conversion: prevDefID=%s (name: %s), currentDefID=%s (name: %s). Names might be unhandled by SubLogic.getSideFromUnitName, or SubLogic itself might be incomplete from a non-critical load error.", tostring(prevStartDefID), tostring(prevDefName), tostring(startDefID), tostring(currentDefName))) + SpringShared.Log(widget:GetInfo().name, LOG.WARNING, string.format("Could not determine sides for conversion: prevDefID=%s (name: %s), currentDefID=%s (name: %s). Names might be unhandled by SubLogic.getSideFromUnitName, or SubLogic itself might be incomplete from a non-critical load error.", tostring(prevStartDefID), tostring(prevDefName), tostring(startDefID), tostring(currentDefName))) end prevStartDefID = startDefID end @@ -1169,7 +1169,7 @@ function widget:DrawWorld() gl.LineStipple(false) local function convertBuildPosToPreviewData(buildPos, buildFacing) - local posX, posY, posZ = Spring.Pos2BuildPos(selBuildQueueDefID, buildPos.x, buildPos.y, buildPos.z, buildPos.facing or buildFacing) + local posX, posY, posZ = SpringShared.Pos2BuildPos(selBuildQueueDefID, buildPos.x, buildPos.y, buildPos.z, buildPos.facing or buildFacing) local buildFacingPos = buildPos.facing or buildFacing return { selBuildQueueDefID, posX, posY, posZ, buildFacingPos } end @@ -1178,7 +1178,7 @@ function widget:DrawWorld() if cx == -100 then return false end - local cbx, cby, cbz = Spring.Pos2BuildPos(startDefID, cx, cy, cz) + local cbx, cby, cbz = SpringShared.Pos2BuildPos(startDefID, cx, cy, cz) return DoBuildingsClash(previewBuildData, { startDefID, cbx, cby, cbz, 1 }) end @@ -1193,7 +1193,7 @@ function widget:DrawWorld() end local function isBuildAroundModeActive() - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if not (shift and ctrl) then return false, nil end @@ -1212,7 +1212,7 @@ function widget:DrawWorld() elseif selBuildQueueDefID then local buildAroundActive, buildAroundTarget = isBuildAroundModeActive() if buildAroundActive then - local buildFacing = Spring.GetBuildFacing() + local buildFacing = SpringUnsynced.GetBuildFacing() previewPositions = BUILD_POSITION_FUNCTIONS[BUILD_MODE.AROUND](selBuildQueueDefID, buildFacing, buildAroundTarget) if #previewPositions > 0 then showPreview = true @@ -1222,8 +1222,8 @@ function widget:DrawWorld() end if showPreview then - local buildFacing = Spring.GetBuildFacing() - local cx, cy, cz = Spring.GetTeamStartPosition(myTeamID) + local buildFacing = SpringUnsynced.GetBuildFacing() + local cx, cy, cz = SpringShared.GetTeamStartPosition(myTeamID) local isMex = UnitDefs[selBuildQueueDefID] and UnitDefs[selBuildQueueDefID].extractsMetal > 0 local previewSpawnStatus = {} @@ -1257,7 +1257,7 @@ function widget:DrawWorld() local validPreviewCount = 0 for _, previewBuildData in ipairs(validPreviewPositions) do local posX, posY, posZ, buildFacingPos = previewBuildData[2], previewBuildData[3], previewBuildData[4], previewBuildData[5] - local isValid = Spring.TestBuildOrder(selBuildQueueDefID, posX, posY, posZ, buildFacingPos) ~= 0 + local isValid = SpringShared.TestBuildOrder(selBuildQueueDefID, posX, posY, posZ, buildFacingPos) ~= 0 local clashesWithCommander = checkCommanderClash(previewBuildData, cx, cy, cz) local mexValid = checkMexValidity(posX, posZ, isMex) @@ -1309,7 +1309,7 @@ function widget:DrawWorld() for _, buildPos in ipairs(filteredPreviewPositions) do local previewBuildData = convertBuildPosToPreviewData(buildPos, buildFacing) local posX, posY, posZ, buildFacingPos = previewBuildData[2], previewBuildData[3], previewBuildData[4], previewBuildData[5] - local isValid = Spring.TestBuildOrder(selBuildQueueDefID, posX, posY, posZ, buildFacingPos) ~= 0 + local isValid = SpringShared.TestBuildOrder(selBuildQueueDefID, posX, posY, posZ, buildFacingPos) ~= 0 local clashesWithCommander = checkCommanderClash(previewBuildData, cx, cy, cz) if clashesWithCommander then @@ -1397,44 +1397,44 @@ function widget:GameFrame(n) end if startDefID then local buildTime = t / UnitDefs[startDefID].buildSpeed - Spring.SendCommands("luarules initialQueueTime " .. buildTime) + SpringUnsynced.SendCommands("luarules initialQueueTime " .. buildTime) end local tasker -- Search for our starting unit - local units = Spring.GetTeamUnits(spGetMyTeamID()) + local units = SpringShared.GetTeamUnits(spGetMyTeamID()) for u = 1, #units do local uID = units[u] if GetUnitCanCompleteQueue(uID) then tasker = uID - if Spring.GetUnitRulesParam(uID, "startingOwner") == Spring.GetMyPlayerID() then + if SpringShared.GetUnitRulesParam(uID, "startingOwner") == Spring.GetMyPlayerID() then -- we found our com even if cooping, assigning queue to this particular unit break end end end if tasker then - local quickStartOption = Spring.GetModOptions().quick_start + local quickStartOption = SpringShared.GetModOptions().quick_start local quickStartEnabled = quickStartOption ~= "disabled" if quickStartEnabled and #buildQueue > 0 then --we have to temporary Echo data like this because there are reports of builds that should be spawned in quickstart not being spawned. --Widget data isn't caught in replays so we have to echo this for now. 1/12/26 - Spring.Echo(string.format("=== Build Queue for Commander (unitID: %d) ===", tasker)) + SpringShared.Echo(string.format("=== Build Queue for Commander (unitID: %d) ===", tasker)) for b = 1, #buildQueue do local buildData = buildQueue[b] local unitDefID = buildData[1] local unitDefName = unitDefID > 0 and UnitDefs[unitDefID] and UnitDefs[unitDefID].name or "MOVE_COMMAND" local x, y, z = buildData[2], buildData[3], buildData[4] local facing = buildData[5] or 0 - Spring.Echo(string.format(" [%d] %s at (%.1f, %.1f, %.1f) facing: %d", b, unitDefName, x, y, z, facing)) + SpringShared.Echo(string.format(" [%d] %s at (%.1f, %.1f, %.1f) facing: %d", b, unitDefName, x, y, z, facing)) end - Spring.Echo(string.format("=== Total queue items: %d ===", #buildQueue)) + SpringShared.Echo(string.format("=== Total queue items: %d ===", #buildQueue)) end for b = 1, #buildQueue do local buildData = buildQueue[b] - Spring.GiveOrderToUnit(tasker, -buildData[1], { buildData[2], buildData[3], buildData[4], buildData[5] }, { "shift" }) + SpringSynced.GiveOrderToUnit(tasker, -buildData[1], { buildData[2], buildData[3], buildData[4], buildData[5] }, { "shift" }) end buildQueue = {} end @@ -1444,9 +1444,9 @@ function widget:GameStart() preGamestartPlayer = false -- Ensure startDefID is current for GameStart logic, though DrawWorld might have already updated prevStartDefID - local currentStartDefID_GS = Spring.GetTeamRulesParam(myTeamID, "startUnit") + local currentStartDefID_GS = SpringShared.GetTeamRulesParam(myTeamID, "startUnit") if startDefID ~= currentStartDefID_GS then - Spring.Log("gui_pregame_build", LOG.DEBUG, string.format("GameStart: startDefID (%s) differs from current rules param (%s). Updating.", tostring(startDefID), tostring(currentStartDefID_GS))) + SpringShared.Log("gui_pregame_build", LOG.DEBUG, string.format("GameStart: startDefID (%s) differs from current rules param (%s). Updating.", tostring(startDefID), tostring(currentStartDefID_GS))) startDefID = currentStartDefID_GS end @@ -1462,7 +1462,7 @@ function widget:GameStart() elseif previousFactionSide and currentFactionSide and previousFactionSide == currentFactionSide then -- Sides are the same, no conversion needed. else - Spring.Log("gui_pregame_build", LOG.WARNING, string.format("Could not determine sides for conversion in GameStart: prevDefID=%s, currentDefID=%s", tostring(prevStartDefID), tostring(startDefID))) + SpringShared.Log("gui_pregame_build", LOG.WARNING, string.format("Could not determine sides for conversion in GameStart: prevDefID=%s, currentDefID=%s", tostring(prevStartDefID), tostring(startDefID))) end prevStartDefID = startDefID end @@ -1497,12 +1497,12 @@ end function widget:GetConfigData() return { buildQueue = buildQueue, - gameID = Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID"), + gameID = Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID"), } end function widget:SetConfigData(data) - if data.buildQueue and spGetGameFrame() == 0 and data.gameID and data.gameID == (Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID")) then + if data.buildQueue and spGetGameFrame() == 0 and data.gameID and data.gameID == (Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID")) then buildQueue = data.buildQueue end end diff --git a/luaui/Widgets/gui_pregameui.lua b/luaui/Widgets/gui_pregameui.lua index c33a593c733..35eaac1a670 100644 --- a/luaui/Widgets/gui_pregameui.lua +++ b/luaui/Widgets/gui_pregameui.lua @@ -17,20 +17,20 @@ local mathFloor = math.floor local mathMax = math.max -- Localized Spring API for performance -local spGetGroundHeight = Spring.GetGroundHeight -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spGetGroundHeight = SpringShared.GetGroundHeight +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry -local draftMode = Spring.GetModOptions().draft_mode +local draftMode = SpringShared.GetModOptions().draft_mode local vsx, vsy = spGetViewGeometry() local uiScale = (0.7 + (vsx * vsy / 6500000)) local myPlayerID = Spring.GetMyPlayerID() -local myPlayerName, _, mySpec, myTeamID = Spring.GetPlayerInfo(myPlayerID, false) +local myPlayerName, _, mySpec, myTeamID = SpringShared.GetPlayerInfo(myPlayerID, false) myPlayerName = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(myPlayerID)) or myPlayerName local isFFA = Spring.Utilities.Gametype.IsFFA() -local isReplay = Spring.IsReplay() +local isReplay = SpringUnsynced.IsReplay() local readyButtonColor = { 0.05, 0.28, 0 } local unreadyButtonColor = { 0.28, 0.05, 0 } @@ -99,7 +99,7 @@ local numPlayers = Spring.Utilities.GetPlayerCount() local shapeOpacity = 0.6 local unitshapes = {} local teamStartPositions = {} -local teamList = Spring.GetTeamList() +local teamList = SpringShared.GetTeamList() local uiElementRect = { 0, 0, 0, 0 } local uiLockRect = { 0, 0, 0, 0 } @@ -178,16 +178,16 @@ end local ihavejoined = false function widget:GameSetup(state, ready, playerStates) - local spec, fullview = Spring.GetSpectatingState() + local spec, fullview = SpringUnsynced.GetSpectatingState() -- sends a "I arrived" message -- NOTE: Spring.GetGameRulesParam("player_" .. Spring.GetMyPlayerID() .. "_joined") seems to be always nil! - if not spec and not ihavejoined and Spring.GetGameRulesParam("player_" .. Spring.GetMyPlayerID() .. "_joined") == nil then - Spring.SendLuaRulesMsg("joined_game") + if not spec and not ihavejoined and SpringShared.GetGameRulesParam("player_" .. Spring.GetMyPlayerID() .. "_joined") == nil then + SpringUnsynced.SendLuaRulesMsg("joined_game") ihavejoined = true end -- check when the 3.2.1 countdown starts - if not gameStarting and ((Spring.GetPlayerTraffic(SYSTEM_ID, NETMSG_STARTPLAYING) or 0) > 0) then + if not gameStarting and ((SpringUnsynced.GetPlayerTraffic(SYSTEM_ID, NETMSG_STARTPLAYING) or 0) > 0) then gameStarting = true -- ugly but effective (can also detect by parsing state string) end @@ -201,8 +201,8 @@ function widget:GameSetup(state, ready, playerStates) end -- starts game after a specified amount of time after all players have joined - if Spring.GetGameRulesParam("all_players_joined") == 1 and not gameStarting and auto_ready then - auto_ready_timer = auto_ready_timer - Spring.GetLastUpdateSeconds() + if SpringShared.GetGameRulesParam("all_players_joined") == 1 and not gameStarting and auto_ready then + auto_ready_timer = auto_ready_timer - SpringUnsynced.GetLastUpdateSeconds() end if auto_ready_timer <= 0 and auto_ready == true then return true, true @@ -210,11 +210,11 @@ function widget:GameSetup(state, ready, playerStates) -- only return true, true once ALL players are ready ready = true - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for _, playerID in pairs(playerList) do - local _, _, spectator_flag = Spring.GetPlayerInfo(playerID, false) + local _, _, spectator_flag = SpringShared.GetPlayerInfo(playerID, false) if spectator_flag == false then - local is_player_ready = Spring.GetGameRulesParam("player_" .. playerID .. "_readyState") + local is_player_ready = SpringShared.GetGameRulesParam("player_" .. playerID .. "_readyState") --spEcho(#playerList, playerID, is_player_ready) if is_player_ready == 0 or is_player_ready == 4 then ready = false @@ -243,10 +243,10 @@ function widget:MousePress(sx, sy) elseif startPointChosen then pressedReady = true readied = true - Spring.SendLuaRulesMsg("ready_to_start_game") + SpringUnsynced.SendLuaRulesMsg("ready_to_start_game") -- also default lock player in place locked = true - Spring.SendLuaRulesMsg("locking_in_place") + SpringUnsynced.SendLuaRulesMsg("locking_in_place") else spEcho(Spring.I18N("ui.initialSpawn.choosePoint")) end @@ -261,16 +261,16 @@ function widget:MousePress(sx, sy) else spEcho(Spring.I18N("ui.substitutePlayers.offerWithdrawn")) end - Spring.SendLuaRulesMsg(offeredAsSub and "\144" or "\145") + SpringUnsynced.SendLuaRulesMsg(offeredAsSub and "\144" or "\145") end -- lock position text showing else if locked then locked = false - Spring.SendLuaRulesMsg("unlocking_in_place") + SpringUnsynced.SendLuaRulesMsg("unlocking_in_place") else locked = true - Spring.SendLuaRulesMsg("locking_in_place") + SpringUnsynced.SendLuaRulesMsg("locking_in_place") end end @@ -288,7 +288,7 @@ end local function checkStartPointChosen() if not mySpec then - local x, y, z = Spring.GetTeamStartPosition(myTeamID) + local x, y, z = SpringShared.GetTeamStartPosition(myTeamID) if x ~= nil and x > 0 and z ~= nil and z > 0 then startPointChosen = true end @@ -309,7 +309,7 @@ function widget:Initialize() return end - if Spring.GetGameFrame() > 0 or isReplay then + if SpringShared.GetGameFrame() > 0 or isReplay then widgetHandler:RemoveWidget() return end @@ -367,7 +367,7 @@ function widget:DrawScreen() buttonDrawn = false -- display autoready timer - if Spring.GetGameRulesParam("all_players_joined") == 1 and not gameStarting and auto_ready then + if SpringShared.GetGameRulesParam("all_players_joined") == 1 and not gameStarting and auto_ready then local colorString = auto_ready_timer % 0.75 <= 0.375 and "\255\233\233\233" or "\255\255\255\255" local text = colorString .. Spring.I18N("ui.initialSpawn.startCountdown", { time = mathMax(1, mathFloor(auto_ready_timer)) }) font:Begin() @@ -390,7 +390,7 @@ function widget:DrawScreen() end if gameStarting then - timer = timer + Spring.GetLastUpdateSeconds() + timer = timer + SpringUnsynced.GetLastUpdateSeconds() local colorString = timer % 0.75 <= 0.375 and "\255\233\233\233" or "\255\255\255\255" local text = colorString .. Spring.I18N("ui.initialSpawn.startCountdown", { time = mathMax(1, 3 - mathFloor(timer)) }) font:Begin() @@ -399,12 +399,12 @@ function widget:DrawScreen() elseif showbutton == true then - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() local numPlayers = #playerList local numPlayersReady = 0 if numPlayers > 3 then for _, playerID in pairs(playerList) do - local readystate = Spring.GetGameRulesParam("player_" .. tostring(playerID) .. "_readyState") + local readystate = SpringShared.GetGameRulesParam("player_" .. tostring(playerID) .. "_readyState") if readystate == -1 or readystate == 1 or readystate == 2 then numPlayersReady = numPlayersReady + 1 end @@ -418,7 +418,7 @@ function widget:DrawScreen() end -- draw ready button and text - local x, y = Spring.GetMouseState() + local x, y = SpringUnsynced.GetMouseState() local colorString if x > buttonRect[1] and x < buttonRect[3] and y > buttonRect[2] and y < buttonRect[4] then gl.CallList(buttonHoverList) @@ -429,7 +429,7 @@ function widget:DrawScreen() end else gl.CallList(buttonList) - timer2 = timer2 + Spring.GetLastUpdateSeconds() + timer2 = timer2 + SpringUnsynced.GetLastUpdateSeconds() if mySpec then colorString = offeredAsSub and "\255\255\255\225" or "\255\222\222\222" else @@ -483,10 +483,10 @@ function widget:DrawWorld() if WG["map_startbox"] and WG["map_startbox"].GetEffectiveStartPosition then tsx, tsy, tsz = WG["map_startbox"].GetEffectiveStartPosition(teamID) else - tsx, tsy, tsz = Spring.GetTeamStartPosition(teamID) + tsx, tsy, tsz = SpringShared.GetTeamStartPosition(teamID) end if tsx and tsx > 0 then - local startUnitDefID = Spring.GetTeamRulesParam(teamID, "startUnit") + local startUnitDefID = SpringShared.GetTeamRulesParam(teamID, "startUnit") if startUnitDefID then id = startUnitDefID .. "_" .. tsx .. "_" .. spGetGroundHeight(tsx, tsz) .. "_" .. tsz if teamStartPositions[teamID] ~= id then diff --git a/luaui/Widgets/gui_pregameui_draft.lua b/luaui/Widgets/gui_pregameui_draft.lua index 509a82c1a30..268819bb1c9 100644 --- a/luaui/Widgets/gui_pregameui_draft.lua +++ b/luaui/Widgets/gui_pregameui_draft.lua @@ -19,11 +19,11 @@ local mathRandom = math.random local tableInsert = table.insert -- Localized Spring API for performance -local spGetGroundHeight = Spring.GetGroundHeight -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spGetGroundHeight = SpringShared.GetGroundHeight +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry -local fontfile = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") +local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") local vsx, vsy = spGetViewGeometry() local fontfileScale = (0.5 + (vsx * vsy / 6200000)) local fontfileSize = 50 @@ -34,9 +34,9 @@ local font = gl.LoadFont(fontfile, fontfileSize * fontfileScale, fontfileOutline local uiScale = (0.7 + (vsx * vsy / 6500000)) local myPlayerID = Spring.GetMyPlayerID() local myAllyTeamID = Spring.GetMyAllyTeamID() -local _, _, mySpec, myTeamID = Spring.GetPlayerInfo(myPlayerID, false) +local _, _, mySpec, myTeamID = SpringShared.GetPlayerInfo(myPlayerID, false) local isFFA = Spring.Utilities.Gametype.IsFFA() -local isReplay = Spring.IsReplay() +local isReplay = SpringUnsynced.IsReplay() local readyButtonColor = { 0.05, 0.28, 0 } local unreadyButtonColor = { 0.28, 0.05, 0 } @@ -129,7 +129,7 @@ local numPlayers = Spring.Utilities.GetPlayerCount() local shapeOpacity = 0.6 local unitshapes = {} local teamStartPositions = {} -local teamList = Spring.GetTeamList() +local teamList = SpringShared.GetTeamList() local uiElementRect = { 0, 0, 0, 0 } local uiLockRect = { 0, 0, 0, 0 } @@ -138,7 +138,7 @@ local lockRect = { 0, 0, 0, 0 } local blinkButton = false -- DraftOrder mod start -local draftMode = Spring.GetModOptions().draft_mode +local draftMode = SpringShared.GetModOptions().draft_mode local turnTimeOut = 8 -- This controls timeout for random/skill mode placement turns, default: 8s local turnTimeOutBigTeam = 5 -- When allyTeam has 9 or more players on it: 5s local bigTeamAmountOfPlayers = 8 -- How many players for it to be considered big team? @@ -166,8 +166,8 @@ local TeamPlacementUI = nil local TeamPlacementUIshown = false local devUItestMode = false -- flip to true to test UI with fake players -- a lot of code copied and slightly modified from advplayerlist... -local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode -local anonymousTeamColor = { Spring.GetConfigInt("anonymousColorR", 255) / 255, Spring.GetConfigInt("anonymousColorG", 0) / 255, Spring.GetConfigInt("anonymousColorB", 0) / 255 } +local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode +local anonymousTeamColor = { SpringUnsynced.GetConfigInt("anonymousColorR", 255) / 255, SpringUnsynced.GetConfigInt("anonymousColorG", 0) / 255, SpringUnsynced.GetConfigInt("anonymousColorB", 0) / 255 } local imgDir = LUAUI_DIRNAME .. "Images/advplayerslist/" local imageDirectory = ":lc:" .. imgDir local pics = { @@ -236,9 +236,9 @@ local function DrawHourglass(posX, posY) end local function SetSidePics() - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for _, playerID in pairs(playerList) do - playerReadyState[playerID] = Spring.GetGameRulesParam("player_" .. tostring(playerID) .. "_readyState") + playerReadyState[playerID] = SpringShared.GetGameRulesParam("player_" .. tostring(playerID) .. "_readyState") end end @@ -295,7 +295,7 @@ local function colourNames(teamID, blink) if blink then mult = 0.66 end - nameColourR, nameColourG, nameColourB = Spring.GetTeamColor(teamID) + nameColourR, nameColourG, nameColourB = SpringUnsynced.GetTeamColor(teamID) end if anonymousMode ~= "disabled" and teamID ~= myTeamID then nameColourR, nameColourG, nameColourB = anonymousTeamColor[1], anonymousTeamColor[2], anonymousTeamColor[3] @@ -334,7 +334,7 @@ local function findPlayerName(playerID) if player.name ~= nil then return player.name else -- try to cache missing player name - tname = select(1, Spring.GetPlayerInfo(playerID, false)) + tname = select(1, SpringShared.GetPlayerInfo(playerID, false)) tname = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerID)) or tname if tname ~= nil then player.name = tname @@ -344,7 +344,7 @@ local function findPlayerName(playerID) end end end - tname = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerID)) or Spring.GetPlayerInfo(playerID, false) + tname = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerID)) or SpringShared.GetPlayerInfo(playerID, false) if not tname then tname = "unconnected" -- show "unconnected" instead of nil if we don't know the name end @@ -368,7 +368,7 @@ end local function checkStartPointChosen() if not mySpec and not startPointChosen then - local x, y, z = Spring.GetTeamStartPosition(myTeamID) + local x, y, z = SpringShared.GetTeamStartPosition(myTeamID) if x ~= nil and x > 0 and z ~= nil and z > 0 then startPointChosen = true end @@ -440,10 +440,10 @@ local function PlayChooseStartLocSound() end local function getHumanCountWithinAllyTeam(allyTeamID) - local myTeamList = Spring.GetTeamList(allyTeamID) + local myTeamList = SpringShared.GetTeamList(allyTeamID) local count = 0 for _, teamID in ipairs(myTeamList) do - local _, _, _, isAiTeam = Spring.GetTeamInfo(teamID, false) + local _, _, _, isAiTeam = SpringShared.GetTeamInfo(teamID, false) if not isAiTeam then count = count + 1 end @@ -484,7 +484,7 @@ local function DrawTeamPlacement() -- added because you can't place until your turn has come up or passed if current_playerID > -1 then local tname = findPlayerName(current_playerID) - local tTeamID = select(4, Spring.GetPlayerInfo(current_playerID, false)) + local tTeamID = select(4, SpringShared.GetPlayerInfo(current_playerID, false)) local text = colourNames(tTeamID, false) .. tname font:Print(DMDefaultColorString .. Spring.I18N("ui.draftOrderMod.waitingFor", { name = text }), vsx * 0.5, vsy * 0.23, 22.0 * uiScale, "co") end @@ -493,7 +493,7 @@ local function DrawTeamPlacement() end if current_playerID > -1 and next_playerID > -1 then local tname = findPlayerName(next_playerID) - local tTeamID = select(4, Spring.GetPlayerInfo(next_playerID, false)) + local tTeamID = select(4, SpringShared.GetPlayerInfo(next_playerID, false)) local text = colourNames(tTeamID, false) .. tname font:Print(DMDefaultColorString .. Spring.I18N("ui.draftOrderMod.nextIsPlayer", { name = text }), vsx * 0.5, vsy * 0.205, 15.0 * uiScale, "co") end @@ -547,7 +547,7 @@ local function DrawTeamPlacement() end -- local playerName = findPlayerName(playerID) - local _, active, _, playerTeamID, _, ping, _, _, rank, _, customtable = Spring.GetPlayerInfo(playerID, true) + local _, active, _, playerTeamID, _, ping, _, _, rank, _, customtable = SpringShared.GetPlayerInfo(playerID, true) local playerRank, playerSkill, playerSigma = 0, 0, 8.33 if type(customtable) == "table" then local tsMu = customtable.skill @@ -653,12 +653,12 @@ local function drawButton() -- Calculate blink state (expensive operation - only do when needed) local blinkButton = false if showLockButton then - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() local numPlayers = #playerList local numPlayersReady = 0 if numPlayers > 3 and not cantPlaceNow then for _, playerID in pairs(playerList) do - local readystate = Spring.GetGameRulesParam("player_" .. tostring(playerID) .. "_readyState") + local readystate = SpringShared.GetGameRulesParam("player_" .. tostring(playerID) .. "_readyState") if readystate == -1 or readystate == 1 or readystate == 2 then numPlayersReady = numPlayersReady + 1 end @@ -730,7 +730,7 @@ local function drawButton() end -- Check mouse hover and render appropriate display list - local x, y = Spring.GetMouseState() + local x, y = SpringUnsynced.GetMouseState() local colorString if x > buttonRect[1] and x < buttonRect[3] and y > buttonRect[2] and y < buttonRect[4] and not cantPlaceNow then glCallList(buttonHoverList) @@ -741,7 +741,7 @@ local function drawButton() end else glCallList(buttonList) - timer2 = timer2 + Spring.GetLastUpdateSeconds() + timer2 = timer2 + SpringUnsynced.GetLastUpdateSeconds() if mySpec then colorString = offeredAsSub and "\255\255\255\225" or "\255\222\222\222" else @@ -792,7 +792,7 @@ local function progressQueueLocally(shift) -- only for dev UI testing of DOM myTurn = true PlayChooseStartLocSound() elseif next_playerID == myPlayerID then - Spring.PlaySoundFile("beep6", 1, "ui") + SpringUnsynced.PlaySoundFile("beep6", 1, "ui") elseif myTurn then myTurn = false end @@ -827,16 +827,16 @@ end local ihavejoined = false function widget:GameSetup(state, ready, playerStates) - local spec, fullview = Spring.GetSpectatingState() + local spec, fullview = SpringUnsynced.GetSpectatingState() -- sends a "I arrived" message -- NOTE: Spring.GetGameRulesParam("player_" .. Spring.GetMyPlayerID() .. "_joined") seems to be always nil! - if not spec and not ihavejoined and Spring.GetGameRulesParam("player_" .. Spring.GetMyPlayerID() .. "_joined") == nil then - Spring.SendLuaRulesMsg("joined_game") + if not spec and not ihavejoined and SpringShared.GetGameRulesParam("player_" .. Spring.GetMyPlayerID() .. "_joined") == nil then + SpringUnsynced.SendLuaRulesMsg("joined_game") ihavejoined = true end -- check when the 3.2.1 countdown starts - if not gameStarting and ((Spring.GetPlayerTraffic(SYSTEM_ID, NETMSG_STARTPLAYING) or 0) > 0) then + if not gameStarting and ((SpringUnsynced.GetPlayerTraffic(SYSTEM_ID, NETMSG_STARTPLAYING) or 0) > 0) then gameStarting = true -- ugly but effective (can also detect by parsing state string) end @@ -851,8 +851,8 @@ function widget:GameSetup(state, ready, playerStates) if not auto_ready_disable then -- starts game after a specified amount of time after all players have joined - if Spring.GetGameRulesParam("all_players_joined") == 1 and not gameStarting and auto_ready then - auto_ready_timer = auto_ready_timer - Spring.GetLastUpdateSeconds() + if SpringShared.GetGameRulesParam("all_players_joined") == 1 and not gameStarting and auto_ready then + auto_ready_timer = auto_ready_timer - SpringUnsynced.GetLastUpdateSeconds() end if auto_ready_timer <= 0 and auto_ready == true then return true, true @@ -861,11 +861,11 @@ function widget:GameSetup(state, ready, playerStates) -- only return true, true once ALL players are ready ready = true - local playerList = Spring.GetPlayerList() + local playerList = SpringShared.GetPlayerList() for _, playerID in pairs(playerList) do - local _, _, spectator_flag = Spring.GetPlayerInfo(playerID, false) + local _, _, spectator_flag = SpringShared.GetPlayerInfo(playerID, false) if spectator_flag == false then - local is_player_ready = Spring.GetGameRulesParam("player_" .. playerID .. "_readyState") + local is_player_ready = SpringShared.GetGameRulesParam("player_" .. playerID .. "_readyState") --spEcho(#playerList, playerID, is_player_ready) if is_player_ready == 0 or is_player_ready == 4 then ready = false @@ -901,10 +901,10 @@ function widget:MousePress(sx, sy) elseif startPointChosen then pressedReady = true readied = true - Spring.SendLuaRulesMsg("ready_to_start_game") + SpringUnsynced.SendLuaRulesMsg("ready_to_start_game") -- also default lock player in place locked = true - Spring.SendLuaRulesMsg("locking_in_place") + SpringUnsynced.SendLuaRulesMsg("locking_in_place") else spEcho(Spring.I18N("ui.initialSpawn.choosePoint")) end @@ -919,16 +919,16 @@ function widget:MousePress(sx, sy) else spEcho(Spring.I18N("ui.substitutePlayers.offerWithdrawn")) end - Spring.SendLuaRulesMsg(offeredAsSub and "\144" or "\145") + SpringUnsynced.SendLuaRulesMsg(offeredAsSub and "\144" or "\145") end -- lock position text showing else if locked then locked = false - Spring.SendLuaRulesMsg("unlocking_in_place") + SpringUnsynced.SendLuaRulesMsg("unlocking_in_place") else locked = true - Spring.SendLuaRulesMsg("locking_in_place") + SpringUnsynced.SendLuaRulesMsg("locking_in_place") end end @@ -958,7 +958,7 @@ function widget:Initialize() return end - if Spring.GetGameFrame() > 0 or isReplay then + if SpringShared.GetGameFrame() > 0 or isReplay then widgetHandler:RemoveWidget() return end @@ -985,7 +985,7 @@ function widget:Initialize() if (Game.startPosType == 2) and (draftMode ~= nil or draftMode ~= "disabled") then local biggestNumberOfPlayers = 1 - local allyTeams = Spring.GetAllyTeamList() + local allyTeams = SpringShared.GetAllyTeamList() for i = 1, #allyTeams do local allyCount = getHumanCountWithinAllyTeam(allyTeams[i]) if allyCount > biggestNumberOfPlayers then @@ -1000,7 +1000,7 @@ function widget:Initialize() end end - local xn, zn, xp, zp = Spring.GetAllyTeamStartBox(myAllyTeamID) + local xn, zn, xp, zp = SpringShared.GetAllyTeamStartBox(myAllyTeamID) if xn and (xn ~= 0 or zn ~= 0 or xp ~= msx or zp ~= msz) then hasStartbox = true end @@ -1040,7 +1040,7 @@ function widget:DrawScreen() end -- display autoready timer - if Spring.GetGameRulesParam("all_players_joined") == 1 and not gameStarting and auto_ready and not auto_ready_disable then + if SpringShared.GetGameRulesParam("all_players_joined") == 1 and not gameStarting and auto_ready and not auto_ready_disable then local colorString = auto_ready_timer % 0.75 <= 0.375 and "\255\233\233\233" or "\255\255\255\255" local text = colorString .. Spring.I18N("ui.initialSpawn.startCountdown", { time = mathMax(1, mathFloor(auto_ready_timer)) }) font:Begin() @@ -1072,12 +1072,12 @@ function widget:DrawScreen() -- non-UI part if draftMode ~= "fair" then if myTurn and currentTurnTimeout and os.clock() >= currentTurnTimeout and not startPointChosen then - Spring.SendLuaRulesMsg("skip_my_turn") + SpringUnsynced.SendLuaRulesMsg("skip_my_turn") myTurn = false end if voteSkipTurnTimeout and os.clock() >= voteSkipTurnTimeout then - Spring.SendLuaRulesMsg("vote_skip_turn") + SpringUnsynced.SendLuaRulesMsg("vote_skip_turn") voteSkipTurnTimeout = nil end @@ -1109,26 +1109,26 @@ function widget:DrawScreen() font:End() end if fairTimeout and os.clock() >= fairTimeout and not ihavejoined_fair then - Spring.SendLuaRulesMsg("i_have_joined_fair") + SpringUnsynced.SendLuaRulesMsg("i_have_joined_fair") ihavejoined_fair = true end if voteConTimeout and os.clock() >= voteConTimeout and ihavejoined_fair then -- TODO do we draw UI or spEcho that Player X have voted to forcestart draft (skip waiting for unconnected allies)? if not myAllyTeamJoined then - Spring.SendLuaRulesMsg("vote_wait_too_long") + SpringUnsynced.SendLuaRulesMsg("vote_wait_too_long") end voteConTimeout = nil end if reloadedDraftMode and os.clock() >= reloadedDraftMode then reloadedDraftMode = nil - Spring.SendLuaRulesMsg("send_me_the_info_again") + SpringUnsynced.SendLuaRulesMsg("send_me_the_info_again") draftModeInited() end end -- DOM end if gameStarting then - timer = timer + Spring.GetLastUpdateSeconds() + timer = timer + SpringUnsynced.GetLastUpdateSeconds() local colorString = timer % 0.75 <= 0.375 and "\255\233\233\233" or "\255\255\255\255" local text = colorString .. Spring.I18N("ui.initialSpawn.startCountdown", { time = mathMax(1, 3 - mathFloor(timer)) }) font:Begin() @@ -1168,10 +1168,10 @@ function widget:DrawWorld() if WG["map_startbox"] and WG["map_startbox"].GetEffectiveStartPosition then tsx, tsy, tsz = WG["map_startbox"].GetEffectiveStartPosition(teamID) else - tsx, tsy, tsz = Spring.GetTeamStartPosition(teamID) + tsx, tsy, tsz = SpringShared.GetTeamStartPosition(teamID) end if tsx and tsx > 0 then - local startUnitDefID = Spring.GetTeamRulesParam(teamID, "startUnit") + local startUnitDefID = SpringShared.GetTeamRulesParam(teamID, "startUnit") if startUnitDefID then id = startUnitDefID .. "_" .. tsx .. "_" .. spGetGroundHeight(tsx, tsz) .. "_" .. tsz if teamStartPositions[teamID] ~= id then @@ -1227,7 +1227,7 @@ function widget:RecvLuaMsg(msg, playerID) end for i = 3, #words do local playerid = tonumber(words[i]) - tname = select(1, Spring.GetPlayerInfo(playerid, false)) + tname = select(1, SpringShared.GetPlayerInfo(playerid, false)) tname = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerid)) or tname tableInsert(myTeamPlayersOrder, { id = playerid, name = tname }) end @@ -1267,7 +1267,7 @@ function widget:RecvLuaMsg(msg, playerID) myTurn = true PlayChooseStartLocSound() elseif next_playerID == myPlayerID then - Spring.PlaySoundFile("beep6", 1, "ui") + SpringUnsynced.PlaySoundFile("beep6", 1, "ui") elseif myTurn then myTurn = false end diff --git a/luaui/Widgets/gui_projectile_target_aoe.lua b/luaui/Widgets/gui_projectile_target_aoe.lua index c3069c9d667..7625e3d002e 100644 --- a/luaui/Widgets/gui_projectile_target_aoe.lua +++ b/luaui/Widgets/gui_projectile_target_aoe.lua @@ -27,20 +27,20 @@ local rad = math.rad local osClock = os.clock -local spGetProjectilesInRectangle = Spring.GetProjectilesInRectangle -local spGetProjectileDefID = Spring.GetProjectileDefID -local spGetProjectileTarget = Spring.GetProjectileTarget -local spGetProjectilePosition = Spring.GetProjectilePosition -local spGetGroundHeight = Spring.GetGroundHeight +local spGetProjectilesInRectangle = SpringShared.GetProjectilesInRectangle +local spGetProjectileDefID = SpringShared.GetProjectileDefID +local spGetProjectileTarget = SpringShared.GetProjectileTarget +local spGetProjectilePosition = SpringShared.GetProjectilePosition +local spGetGroundHeight = SpringShared.GetGroundHeight local spGetMyAllyTeamID = Spring.GetMyAllyTeamID -local spGetProjectileTeamID = Spring.GetProjectileTeamID -local spGetTeamInfo = Spring.GetTeamInfo -local spGetUnitPosition = Spring.GetUnitPosition -local spGetViewGeometry = Spring.GetViewGeometry -local spIsGUIHidden = Spring.IsGUIHidden -local spGetSpectatingState = Spring.GetSpectatingState +local spGetProjectileTeamID = SpringShared.GetProjectileTeamID +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spIsGUIHidden = SpringUnsynced.IsGUIHidden +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local spGetMyTeamID = Spring.GetMyTeamID -local spIsSphereInView = Spring.IsSphereInView +local spIsSphereInView = SpringUnsynced.IsSphereInView local mapSizeX = Game.mapSizeX local mapSizeZ = Game.mapSizeZ diff --git a/luaui/Widgets/gui_prospector.lua b/luaui/Widgets/gui_prospector.lua index 7038c796a21..aed2f002f00 100644 --- a/luaui/Widgets/gui_prospector.lua +++ b/luaui/Widgets/gui_prospector.lua @@ -25,12 +25,12 @@ local textSize = 16 -- speedups ------------------------------------------------ -local GetActiveCommand = Spring.GetActiveCommand -local GetMouseState = Spring.GetMouseState -local TraceScreenRay = Spring.TraceScreenRay -local GetGroundInfo = Spring.GetGroundInfo -local GetGameFrame = Spring.GetGameFrame -local GetMapDrawMode = Spring.GetMapDrawMode +local GetActiveCommand = SpringUnsynced.GetActiveCommand +local GetMouseState = SpringUnsynced.GetMouseState +local TraceScreenRay = SpringUnsynced.TraceScreenRay +local GetGroundInfo = SpringShared.GetGroundInfo +local GetGameFrame = SpringShared.GetGameFrame +local GetMapDrawMode = SpringUnsynced.GetMapDrawMode local glColor = gl.Color local glRect = gl.Rect @@ -49,7 +49,7 @@ local strFormat = string.format -- vars ------------------------------------------------ -local vsx, vsy = Spring.GetViewGeometry() +local vsx, vsy = SpringUnsynced.GetViewGeometry() --unitDefID = {extractsMetal, extractSquare, oddX, oddZ} local mexDefInfos = {} local defaultDefID diff --git a/luaui/Widgets/gui_rank_icons_gl4.lua b/luaui/Widgets/gui_rank_icons_gl4.lua index 558165195d8..22d4337f7c4 100644 --- a/luaui/Widgets/gui_rank_icons_gl4.lua +++ b/luaui/Widgets/gui_rank_icons_gl4.lua @@ -13,11 +13,11 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spEcho = Spring.Echo -local spGetUnitTeam = Spring.GetUnitTeam -local spGetAllUnits = Spring.GetAllUnits -local spGetSpectatingState = Spring.GetSpectatingState +local spGetUnitDefID = SpringShared.GetUnitDefID +local spEcho = SpringShared.Echo +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetAllUnits = SpringShared.GetAllUnits +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local iconsize = 1 local iconoffset = 24 @@ -81,9 +81,9 @@ local function makeAtlas() end local GetUnitDefID = spGetUnitDefID -local GetUnitExperience = Spring.GetUnitExperience +local GetUnitExperience = SpringShared.GetUnitExperience local GetAllUnits = spGetAllUnits -local IsUnitAllied = Spring.IsUnitAllied +local IsUnitAllied = SpringUnsynced.IsUnitAllied local GetUnitTeam = spGetUnitTeam local glDepthTest = gl.DepthTest @@ -94,9 +94,9 @@ local glTexture = gl.Texture local GL_GREATER = GL.GREATER local ignoreTeams = {} -for _, teamID in ipairs(Spring.GetTeamList()) do - if select(4, Spring.GetTeamInfo(teamID, false)) then -- is AI? - local luaAI = Spring.GetTeamLuaAI(teamID) +for _, teamID in ipairs(SpringShared.GetTeamList()) do + if select(4, SpringShared.GetTeamInfo(teamID, false)) then -- is AI? + local luaAI = SpringShared.GetTeamLuaAI(teamID) if luaAI and luaAI ~= "" and (string.find(luaAI, "Scavengers") or string.find(luaAI, "Raptors")) then ignoreTeams[teamID] = true end @@ -106,7 +106,7 @@ end local unitIconMult = {} for unitDefID, unitDef in pairs(UnitDefs) do if not unitDef.customParams.drone then - unitIconMult[unitDefID] = math.clamp((Spring.GetUnitDefDimensions(unitDefID).radius / 40) + math.min(unitDef.power / 400, 2), 1.25, 1.4) + unitIconMult[unitDefID] = math.clamp((SpringShared.GetUnitDefDimensions(unitDefID).radius / 40) + math.min(unitDef.power / 400, 2), 1.25, 1.4) end end @@ -140,13 +140,13 @@ local function AddPrimitiveAtUnit(unitID, unitDefID, noUpload, reason, rank, fla if debugmode then Spring.Debug.TraceEcho("add", unitID, reason) end - if Spring.ValidUnitID(unitID) ~= true or Spring.GetUnitIsDead(unitID) == true then + if SpringShared.ValidUnitID(unitID) ~= true or SpringShared.GetUnitIsDead(unitID) == true then if debugmode then spEcho("Warning: Rank Icons GL4 attempted to add an invalid unitID:", unitID) end return nil end - local gf = (flash and Spring.GetGameFrame()) or 0 + local gf = (flash and SpringShared.GetGameFrame()) or 0 unitDefID = unitDefID or spGetUnitDefID(unitID) --if unitDefID == nil or unitDefIDtoDecalInfo[unitDefID] == nil then return end -- these cant have plates @@ -371,7 +371,7 @@ function widget:VisibleUnitsChanged(extVisibleUnits, extNumVisibleUnits) end function widget:DrawWorld() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if doRefresh then diff --git a/luaui/Widgets/gui_raptorStatsPanel.lua b/luaui/Widgets/gui_raptorStatsPanel.lua index a76a8f9519d..ac8bc6503be 100644 --- a/luaui/Widgets/gui_raptorStatsPanel.lua +++ b/luaui/Widgets/gui_raptorStatsPanel.lua @@ -23,7 +23,7 @@ local mathFloor = math.floor local mathMin = math.min -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local config = VFS.Include("LuaRules/Configs/raptor_spawn_defs.lua") @@ -38,11 +38,11 @@ if not Spring.Utilities.Gametype.IsRaptors() then return false end -if not Spring.GetGameRulesParam("raptorDifficulty") then +if not SpringShared.GetGameRulesParam("raptorDifficulty") then return false end -local GetGameSeconds = Spring.GetGameSeconds +local GetGameSeconds = SpringShared.GetGameSeconds local displayList local panelTexture = ":n:LuaUI/Images/raptorpanel.tga" @@ -67,7 +67,7 @@ local gameInfo local waveSpeed = 0.1 local waveCount = 0 local waveTime -local bossToastTimer = Spring.GetTimer() +local bossToastTimer = SpringUnsynced.GetTimer() local enabled local gotScore local scoreCount = 0 @@ -79,8 +79,8 @@ local guiPanel --// a displayList local updatePanel local hasRaptorEvent = false -local difficultyOption = Spring.GetModOptions().raptor_difficulty -local nBosses = Spring.GetModOptions().raptor_queen_count +local difficultyOption = SpringShared.GetModOptions().raptor_difficulty +local nBosses = SpringShared.GetModOptions().raptor_queen_count local rules = { "raptorQueenTime", @@ -185,11 +185,11 @@ local function CreatePanelDisplayList() if gameInfo.raptorQueenAnger < 100 then local gain = 0 - if Spring.GetGameRulesParam("RaptorQueenAngerGain_Base") then - font:Print(textColor .. Spring.I18N("ui.raptors.queenAngerBase", { value = math.round(Spring.GetGameRulesParam("RaptorQueenAngerGain_Base"), 3) }), panelMarginX + 5, PanelRow(3), panelFontSize, "") - font:Print(textColor .. Spring.I18N("ui.raptors.queenAngerAggression", { value = math.round(Spring.GetGameRulesParam("RaptorQueenAngerGain_Aggression"), 3) }), panelMarginX + 5, PanelRow(4), panelFontSize, "") + if SpringShared.GetGameRulesParam("RaptorQueenAngerGain_Base") then + font:Print(textColor .. Spring.I18N("ui.raptors.queenAngerBase", { value = math.round(SpringShared.GetGameRulesParam("RaptorQueenAngerGain_Base"), 3) }), panelMarginX + 5, PanelRow(3), panelFontSize, "") + font:Print(textColor .. Spring.I18N("ui.raptors.queenAngerAggression", { value = math.round(SpringShared.GetGameRulesParam("RaptorQueenAngerGain_Aggression"), 3) }), panelMarginX + 5, PanelRow(4), panelFontSize, "") --font:Print(textColor .. Spring.I18N('ui.raptors.queenAngerEco', { value = math.round(Spring.GetGameRulesParam("RaptorQueenAngerGain_Eco"), 3) }), panelMarginX+5, PanelRow(5), panelFontSize, "") - gain = math.round(Spring.GetGameRulesParam("RaptorQueenAngerGain_Base"), 3) + math.round(Spring.GetGameRulesParam("RaptorQueenAngerGain_Aggression"), 3) + math.round(Spring.GetGameRulesParam("RaptorQueenAngerGain_Eco"), 3) + gain = math.round(SpringShared.GetGameRulesParam("RaptorQueenAngerGain_Base"), 3) + math.round(SpringShared.GetGameRulesParam("RaptorQueenAngerGain_Aggression"), 3) + math.round(SpringShared.GetGameRulesParam("RaptorQueenAngerGain_Eco"), 3) end --font:Print(textColor .. Spring.I18N('ui.raptors.queenAngerWithGain', { anger = gameInfo.raptorQueenAnger, gain = math.round(gain, 3) }), panelMarginX, PanelRow(1), panelFontSize, "") font:Print(textColor .. Spring.I18N("ui.raptors.queenAngerWithTech", { anger = mathFloor(0.5 + gameInfo.raptorQueenAnger), techAnger = gameInfo.raptorTechAnger }), panelMarginX, PanelRow(1), panelFontSize, "") @@ -224,7 +224,7 @@ local function CreatePanelDisplayList() font:Print(textColor .. Spring.I18N("ui.raptors.raptorKillCount", { count = gameInfo.raptorKills }), panelMarginX, PanelRow(6), panelFontSize, "") local endless = "" - if Spring.GetModOptions().raptor_endless then + if SpringShared.GetModOptions().raptor_endless then endless = " (" .. Spring.I18N("ui.raptors.difficulty.endless") .. ")" end local difficultyCaption = Spring.I18N("ui.raptors.difficulty." .. difficultyOption) @@ -294,9 +294,9 @@ local function Draw() end if showMarqueeMessage then - local t = Spring.GetTimer() + local t = SpringUnsynced.GetTimer() - local waveY = viewSizeY - Spring.DiffTimers(t, waveTime) * waveSpeed * viewSizeY + local waveY = viewSizeY - SpringUnsynced.DiffTimers(t, waveTime) * waveSpeed * viewSizeY if waveY > 0 then if refreshMarqueeMessage or not marqueeMessage then marqueeMessage = getMarqueeMessage(messageArgs) @@ -314,7 +314,7 @@ local function Draw() end elseif #resistancesTable > 0 then marqueeMessage = getResistancesMessage() - waveTime = Spring.GetTimer() + waveTime = SpringUnsynced.GetTimer() showMarqueeMessage = true end end @@ -325,7 +325,7 @@ local function UpdateRules() end for _, rule in ipairs(rules) do - gameInfo[rule] = Spring.GetGameRulesParam(rule) or 0 + gameInfo[rule] = SpringShared.GetGameRulesParam(rule) or 0 end gameInfo.raptorCounts = getRaptorCounts("Count") gameInfo.raptorKills = getRaptorCounts("Kills") @@ -334,13 +334,13 @@ local function UpdateRules() end function RaptorEvent(raptorEventArgs) - if raptorEventArgs.type == "firstWave" or (raptorEventArgs.type == "queen" and Spring.DiffTimers(Spring.GetTimer(), bossToastTimer) > 10) then + if raptorEventArgs.type == "firstWave" or (raptorEventArgs.type == "queen" and SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), bossToastTimer) > 10) then showMarqueeMessage = true refreshMarqueeMessage = true messageArgs = raptorEventArgs - waveTime = Spring.GetTimer() + waveTime = SpringUnsynced.GetTimer() if raptorEventArgs.type == "queen" then - bossToastTimer = Spring.GetTimer() + bossToastTimer = SpringUnsynced.GetTimer() end end @@ -359,7 +359,7 @@ function RaptorEvent(raptorEventArgs) showMarqueeMessage = true refreshMarqueeMessage = true messageArgs = raptorEventArgs - waveTime = Spring.GetTimer() + waveTime = SpringUnsynced.GetTimer() end end @@ -389,7 +389,7 @@ end function widget:Shutdown() if hasRaptorEvent then - Spring.SendCommands({ "luarules HasRaptorEvent 0" }) + SpringUnsynced.SendCommands({ "luarules HasRaptorEvent 0" }) end if guiPanel then @@ -404,7 +404,7 @@ end function widget:GameFrame(n) if not hasRaptorEvent and n > 1 then - Spring.SendCommands({ "luarules HasRaptorEvent 1" }) + SpringUnsynced.SendCommands({ "luarules HasRaptorEvent 1" }) hasRaptorEvent = true end if n % 30 < 1 then diff --git a/luaui/Widgets/gui_reclaim_field_highlight.lua b/luaui/Widgets/gui_reclaim_field_highlight.lua index 6f42ca4d631..18888085764 100644 --- a/luaui/Widgets/gui_reclaim_field_highlight.lua +++ b/luaui/Widgets/gui_reclaim_field_highlight.lua @@ -89,8 +89,8 @@ local alwaysShowFieldsMaxThreshold = 4000 -- Maximum metal value threshold local alwaysShowFieldsThreshold = 500 -- Current threshold (auto-calculated based on map metal) local totalMapMetal = 0 -- Total metal available on the map (calculated after clustering) -local gameStarted = Spring.GetGameFrame() > 0 -local lastCheckFrame = Spring.GetGameFrame() - 999 +local gameStarted = SpringShared.GetGameFrame() > 0 +local lastCheckFrame = SpringShared.GetGameFrame() - 999 local lastCheckFrameClock = os.clock() - 99 local lastProcessedFrame = -1 @@ -133,21 +133,21 @@ local glText = gl.Text local glTranslate = gl.Translate local glVertex = gl.Vertex -local spGetCameraPosition = Spring.GetCameraPosition -local spGetFeaturePosition = Spring.GetFeaturePosition -local spWorldToScreenCoords = Spring.WorldToScreenCoords -local spGetFeatureResources = Spring.GetFeatureResources -local spGetFeatureVelocity = Spring.GetFeatureVelocity -local spGetFeatureRadius = Spring.GetFeatureRadius -local spValidFeatureID = Spring.ValidFeatureID -local spGetGroundHeight = Spring.GetGroundHeight -local spIsGUIHidden = Spring.IsGUIHidden -local spTraceScreenRay = Spring.TraceScreenRay -local spGetActiveCommand = Spring.GetActiveCommand -local spGetMapDrawMode = Spring.GetMapDrawMode -local spGetUnitDefID = Spring.GetUnitDefID -local spGetCameraVectors = Spring.GetCameraVectors -local spGetGameFrame = Spring.GetGameFrame +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spGetFeaturePosition = SpringShared.GetFeaturePosition +local spWorldToScreenCoords = SpringUnsynced.WorldToScreenCoords +local spGetFeatureResources = SpringShared.GetFeatureResources +local spGetFeatureVelocity = SpringShared.GetFeatureVelocity +local spGetFeatureRadius = SpringShared.GetFeatureRadius +local spValidFeatureID = SpringShared.ValidFeatureID +local spGetGroundHeight = SpringShared.GetGroundHeight +local spIsGUIHidden = SpringUnsynced.IsGUIHidden +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetMapDrawMode = SpringUnsynced.GetMapDrawMode +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetCameraVectors = SpringUnsynced.GetCameraVectors +local spGetGameFrame = SpringShared.GetGameFrame -- TIMING INSTRUMENTATION (set to true to enable periodic timing echo) local debugTiming = false @@ -207,7 +207,7 @@ local function IsInCameraView(x, y, z, radius, currentDrawCount) cachedCamFwdX, cachedCamFwdY, cachedCamFwdZ = newCamForward[1], newCamForward[2], newCamForward[3] -- Pre-compute frustum cone cosine (avoids trig per-call) - local vsx, vsy = Spring.GetViewGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() local aspect = vsx / vsy local vertFOV = rad(45) local horizFOV = 2 * atan(tan(vertFOV * 0.5) * aspect) @@ -2778,7 +2778,7 @@ end -- Widget call-ins function widget:Initialize() - gameStarted = Spring.GetGameFrame() > 0 + gameStarted = SpringShared.GetGameFrame() > 0 screenx, screeny = widgetHandler:GetViewSizes() -- Initialize camera scale early to avoid thick lines on first draw @@ -2898,13 +2898,13 @@ function widget:Initialize() opticsObject = Optics.new() cachedKnownFeaturesCount = 0 -- Reset cached count - for _, featureID in ipairs(Spring.GetAllFeatures()) do + for _, featureID in ipairs(SpringShared.GetAllFeatures()) do widget:FeatureCreated(featureID) end camUpVector = spGetCameraVectors().up - widget:SelectionChanged(Spring.GetSelectedUnits()) + widget:SelectionChanged(SpringUnsynced.GetSelectedUnits()) end function widget:Shutdown() @@ -3272,7 +3272,7 @@ function widget:DrawWorldPreUnit() timingCount = timingCount + 1 if debugTiming and timingCount >= timingInterval then local div = timingCount - Spring.Echo(string.format("[ReclaimField TIMING] per-call avg (ms): UpdateReclaim=%.3f DrawWorldText=%.3f DrawPreUnit=%.3f | Update()=%.3f | clusters=%d features=%d", timingAccum.updateReclaim / div * 1000, timingAccum.drawWorldText / div * 1000, timingAccum.drawPreUnit / div * 1000, timingAccum.updateFunc / div * 1000, #featureClusters, cachedKnownFeaturesCount)) + SpringShared.Echo(string.format("[ReclaimField TIMING] per-call avg (ms): UpdateReclaim=%.3f DrawWorldText=%.3f DrawPreUnit=%.3f | Update()=%.3f | clusters=%d features=%d", timingAccum.updateReclaim / div * 1000, timingAccum.drawWorldText / div * 1000, timingAccum.drawPreUnit / div * 1000, timingAccum.updateFunc / div * 1000, #featureClusters, cachedKnownFeaturesCount)) for k in pairs(timingAccum) do timingAccum[k] = 0 end diff --git a/luaui/Widgets/gui_reclaiminfo.lua b/luaui/Widgets/gui_reclaiminfo.lua index 26971691ca9..bf8e40ea11f 100644 --- a/luaui/Widgets/gui_reclaiminfo.lua +++ b/luaui/Widgets/gui_reclaiminfo.lua @@ -30,17 +30,17 @@ local mathFloor = math.floor local mathSqrt = math.sqrt -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spTraceScreenRay = Spring.TraceScreenRay -local spGetActiveCommand = Spring.GetActiveCommand -local spGetMouseState = Spring.GetMouseState -local spGetMouseCursor = Spring.GetMouseCursor -local spGetFeaturesInCylinder = Spring.GetFeaturesInCylinder -local spGetFeatureResources = Spring.GetFeatureResources -local spGetUnitHealth = Spring.GetUnitHealth -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetMiniMapGeometry = Spring.GetMiniMapGeometry -local spGetGroundHeight = Spring.GetGroundHeight +local spGetUnitDefID = SpringShared.GetUnitDefID +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetMouseCursor = SpringUnsynced.GetMouseCursor +local spGetFeaturesInCylinder = SpringShared.GetFeaturesInCylinder +local spGetFeatureResources = SpringShared.GetFeatureResources +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetMiniMapGeometry = SpringUnsynced.GetMiniMapGeometry +local spGetGroundHeight = SpringShared.GetGroundHeight local spI18N = Spring.I18N local start = false --reclaim area cylinder drawing has been started @@ -86,7 +86,7 @@ function widget:Initialize() end function widget:ViewResize() - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() font = WG["fonts"].getFont(1, 1.5) form = mathFloor(vsx / 87) end diff --git a/luaui/Widgets/gui_rejoinprogress.lua b/luaui/Widgets/gui_rejoinprogress.lua index e0f75dd0b4d..3e3f529cdcd 100644 --- a/luaui/Widgets/gui_rejoinprogress.lua +++ b/luaui/Widgets/gui_rejoinprogress.lua @@ -16,7 +16,7 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local showRejoinUI = false local CATCH_UP_THRESHOLD = 11 * Game.gameSpeed -- only show the window if behind this much @@ -24,7 +24,7 @@ local UPDATE_RATE_F = 5 -- frames local UPDATE_RATE_S = UPDATE_RATE_F / Game.gameSpeed local t = UPDATE_RATE_S -local ui_scale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local ui_scale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) local vsx, vsy = gl.GetViewSizes() local widgetScale = 1 local noiseBackgroundTexture = ":g:LuaUI/Images/rgbnoise.png" @@ -33,7 +33,7 @@ local barGlowCenterTexture = ":l:LuaUI/Images/barglow-center.png" local barGlowEdgeTexture = ":l:LuaUI/Images/barglow-edge.png" local rejoinArea = {} local gameStarted = (spGetGameFrame() > 0) -local isReplay = Spring.IsReplay() +local isReplay = SpringUnsynced.IsReplay() local RectRound, TexturedRectRound, UiElement, font2 local dlistRejoin, dlistRejoinGuishader, serverFrame local posY = 0.22 @@ -151,12 +151,12 @@ function widget:Update(dt) if t <= 0 then t = t + UPDATE_RATE_S - if Spring.IsGameOver() then -- not sure if widget:GameOver() even works so I do this here as well + if SpringShared.IsGameOver() then -- not sure if widget:GameOver() even works so I do this here as well widgetHandler:RemoveWidget() return end - local speedFactor, _, isPaused = Spring.GetGameSpeed() + local speedFactor, _, isPaused = SpringUnsynced.GetGameSpeed() -- update/estimate serverFrame (because widget:GameProgress(n) only happens every 150 frames) if gameStarted and not isPaused then diff --git a/luaui/Widgets/gui_replaybuttons.lua b/luaui/Widgets/gui_replaybuttons.lua index fc27c4f6967..7f1411f77dc 100644 --- a/luaui/Widgets/gui_replaybuttons.lua +++ b/luaui/Widgets/gui_replaybuttons.lua @@ -18,14 +18,14 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spGetMouseState = Spring.GetMouseState -local spGetViewGeometry = Spring.GetViewGeometry +local spGetGameFrame = SpringShared.GetGameFrame +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local vsx, vsy = spGetViewGeometry() -local ui_opacity = Spring.GetConfigFloat("ui_opacity", 0.7) -local ui_scale = Spring.GetConfigFloat("ui_scale", 1) +local ui_opacity = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7) +local ui_scale = SpringUnsynced.GetConfigFloat("ui_scale", 1) local buttonWidth = 0.037 local buttonHeight = 0.033 @@ -80,7 +80,7 @@ local function clicked_button(b) end local function setReplaySpeed(speed) - Spring.SendCommands("setspeed " .. speed) + SpringUnsynced.SendCommands("setspeed " .. speed) end local function draw_buttons(b) @@ -113,7 +113,7 @@ end function widget:Initialize() widget:ViewResize() - if not Spring.IsReplay() then + if not SpringUnsynced.IsReplay() then widgetHandler:RemoveWidget() return end @@ -197,10 +197,10 @@ function widget:MousePress(x, y, button) if cb == "playpauseskip" then if spGetGameFrame() > 1 then isPaused = not isPaused - Spring.SendCommands("pause " .. (isPaused and "1" or "0")) + SpringUnsynced.SendCommands("pause " .. (isPaused and "1" or "0")) buttons[i].text = (isPaused and " >>" or " ||") else - Spring.SendCommands("skip 1") + SpringUnsynced.SendCommands("skip 1") buttons[i].text = " ||" end sceduleUpdate = true @@ -214,7 +214,7 @@ end function widget:Update(dt) prevIsActive = isActive - isActive = #Spring.GetSelectedUnits() == 0 + isActive = #SpringUnsynced.GetSelectedUnits() == 0 end function widget:GameStart() diff --git a/luaui/Widgets/gui_resurrection_halos_gl4.lua b/luaui/Widgets/gui_resurrection_halos_gl4.lua index 83585ff15e0..f7d0d12313d 100644 --- a/luaui/Widgets/gui_resurrection_halos_gl4.lua +++ b/luaui/Widgets/gui_resurrection_halos_gl4.lua @@ -63,12 +63,12 @@ local function initGL4() end function widget:VisibleUnitAdded(unitID, unitDefID, unitTeam) - local rezRulesParam = Spring.GetUnitRulesParam(unitID, "resurrected") + local rezRulesParam = SpringShared.GetUnitRulesParam(unitID, "resurrected") if unitConf[unitDefID] == nil or not rezRulesParam or rezRulesParam == 0 then return end - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() pushElementInstance( resurrectionHalosVBO, -- push into this Instance VBO Table { @@ -101,7 +101,7 @@ end function widget:VisibleUnitsChanged(extVisibleUnits, extNumVisibleUnits) InstanceVBOTable.clearInstanceTable(resurrectionHalosVBO) for unitID, unitDefID in pairs(extVisibleUnits) do - widget:VisibleUnitAdded(unitID, unitDefID, Spring.GetUnitTeam(unitID)) + widget:VisibleUnitAdded(unitID, unitDefID, SpringShared.GetUnitTeam(unitID)) end end @@ -122,7 +122,7 @@ function widget:DrawWorld() if chobbyInterface then return end - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end diff --git a/luaui/Widgets/gui_savegame.lua b/luaui/Widgets/gui_savegame.lua index b641be29ad8..f5bad35c9ec 100644 --- a/luaui/Widgets/gui_savegame.lua +++ b/luaui/Widgets/gui_savegame.lua @@ -16,7 +16,7 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local SAVE_DIR = "Saves" local SAVE_DIR_LENGTH = string.len(SAVE_DIR) + 2 @@ -76,7 +76,7 @@ local function GetSave(path) ret = saveData end) if not success then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "Error getting save " .. path .. ": " .. err) + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "Error getting save " .. path .. ": " .. err) else local engineSaveFilename = GetSaveWithExtension(string.sub(path, 1, -5)) if not engineSaveFilename then @@ -123,7 +123,7 @@ local function SaveGame(filename, description, requireOverwrite) WG.Analytics.SendRepeatEvent("game_start:savegame", filename) end local success, err = pcall(function() - Spring.CreateDir(SAVE_DIR) + SpringUnsynced.CreateDir(SAVE_DIR) filename = (filename and trim(filename)) or ("save" .. string.format("%03d", FindFirstEmptySaveSlot())) path = SAVE_DIR .. "/" .. filename .. ".lua" local saveData = {} @@ -134,10 +134,10 @@ local function SaveGame(filename, description, requireOverwrite) saveData.gameVersion = Game.gameVersion saveData.engineVersion = Engine.version saveData.map = Game.mapName - saveData.gameID = (Spring.GetGameRulesParam("save_gameID") or (Game.gameID and Game.gameID or Spring.GetGameRulesParam("GameID"))) + saveData.gameID = (SpringShared.GetGameRulesParam("save_gameID") or (Game.gameID and Game.gameID or SpringShared.GetGameRulesParam("GameID"))) saveData.gameframe = spGetGameFrame() - saveData.totalGameframe = spGetGameFrame() + (Spring.GetGameRulesParam("totalSaveGameFrame") or 0) - saveData.playerName = Spring.GetPlayerInfo(Spring.GetMyPlayerID(), false) + saveData.totalGameframe = spGetGameFrame() + (SpringShared.GetGameRulesParam("totalSaveGameFrame") or 0) + saveData.playerName = SpringShared.GetPlayerInfo(Spring.GetMyPlayerID(), false) table.save(saveData, path) -- TODO: back up existing save? @@ -145,28 +145,28 @@ local function SaveGame(filename, description, requireOverwrite) --end if requireOverwrite then - Spring.SendCommands(SAVE_TYPE .. filename .. " -y") + SpringUnsynced.SendCommands(SAVE_TYPE .. filename .. " -y") else - Spring.SendCommands(SAVE_TYPE .. filename) + SpringUnsynced.SendCommands(SAVE_TYPE .. filename) end - Spring.Log(widget:GetInfo().name, LOG.INFO, "Saved game to " .. path) + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "Saved game to " .. path) --DisposeWindow() end) if not success then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "Error saving game: " .. err) + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "Error saving game: " .. err) end end local function LoadGameByFilename(filename) local saveData = GetSave(SAVE_DIR .. "/" .. filename .. ".lua") if saveData then - if Spring.GetMenuName and Spring.SendLuaMenuMsg and Spring.GetMenuName() then - Spring.SendLuaMenuMsg(LOAD_GAME_STRING .. filename) + if SpringUnsynced.GetMenuName and SpringUnsynced.SendLuaMenuMsg and SpringUnsynced.GetMenuName() then + SpringUnsynced.SendLuaMenuMsg(LOAD_GAME_STRING .. filename) else local ext = GetSaveExtension(SAVE_DIR .. "/" .. filename) if not ext then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "Error loading game: cannot find save file.") + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "Error loading game: cannot find save file.") return end local success, err = pcall(function() @@ -184,14 +184,14 @@ local function LoadGameByFilename(filename) ]] script = script:gsub("__FILE__", filename .. ext) script = script:gsub("__PLAYERNAME__", saveData.playerName) - Spring.Reload(script) + SpringUnsynced.Reload(script) end) if not success then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "Error loading game: " .. err) + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "Error loading game: " .. err) end end else - Spring.Log(widget:GetInfo().name, LOG.ERROR, "Save game " .. filename .. " not found") + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "Save game " .. filename .. " not found") end if saveFilenameEdit then saveFilenameEdit:SetText(filename) @@ -200,7 +200,7 @@ end local function DeleteSave(filename) if not filename then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "No filename specified for save deletion") + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "No filename specified for save deletion") end local success, err = pcall(function() local pathNoExtension = SAVE_DIR .. "/" .. filename @@ -211,17 +211,17 @@ local function DeleteSave(filename) end end) if not success then - Spring.Log(widget:GetInfo().name, LOG.ERROR, "Error deleting save " .. filename .. ": " .. err) + SpringShared.Log(widget:GetInfo().name, LOG.ERROR, "Error deleting save " .. filename .. ": " .. err) end end local function savegameCmd(_, _, params) - Spring.Echo("Trying to save:", params[1]) + SpringShared.Echo("Trying to save:", params[1]) local savefilename = params[1] SaveGame(savefilename, savefilename, true) - if Spring.GetMenuName and string.find(string.lower(Spring.GetMenuName()), "chobby") ~= nil then - Spring.SendLuaMenuMsg("gameSaved") + if SpringUnsynced.GetMenuName and string.find(string.lower(SpringUnsynced.GetMenuName()), "chobby") ~= nil then + SpringUnsynced.SendLuaMenuMsg("gameSaved") end end diff --git a/luaui/Widgets/gui_scavStatsPanel.lua b/luaui/Widgets/gui_scavStatsPanel.lua index 22779343a70..f321600cbad 100644 --- a/luaui/Widgets/gui_scavStatsPanel.lua +++ b/luaui/Widgets/gui_scavStatsPanel.lua @@ -23,7 +23,7 @@ local mathFloor = math.floor local mathMin = math.min -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local config = VFS.Include("LuaRules/Configs/scav_spawn_defs.lua") @@ -38,11 +38,11 @@ if not Spring.Utilities.Gametype.IsScavengers() then return false end -if not Spring.GetGameRulesParam("scavDifficulty") then +if not SpringShared.GetGameRulesParam("scavDifficulty") then return false end -local GetGameSeconds = Spring.GetGameSeconds +local GetGameSeconds = SpringShared.GetGameSeconds local displayList local panelTexture = ":n:LuaUI/Images/scavpanel.png" @@ -67,7 +67,7 @@ local gameInfo local waveSpeed = 0.1 local waveCount = 0 local waveTime -local bossToastTimer = Spring.GetTimer() +local bossToastTimer = SpringUnsynced.GetTimer() local enabled local gotScore local scoreCount = 0 @@ -79,8 +79,8 @@ local guiPanel --// a displayList local updatePanel local hasScavEvent = false -local difficultyOption = Spring.GetModOptions().scav_difficulty -local nBosses = Spring.GetModOptions().scav_boss_count +local difficultyOption = SpringShared.GetModOptions().scav_difficulty +local nBosses = SpringShared.GetModOptions().scav_boss_count local rules = { "scavBossTime", @@ -143,11 +143,11 @@ local function CreatePanelDisplayList() if gameInfo.scavBossAnger < 100 then local gain = 0 - if Spring.GetGameRulesParam("ScavBossAngerGain_Base") then - font:Print(textColor .. Spring.I18N("ui.scavs.bossAngerBase", { value = math.round(Spring.GetGameRulesParam("ScavBossAngerGain_Base"), 3) }), panelMarginX + 5, PanelRow(3), panelFontSize, "") - font:Print(textColor .. Spring.I18N("ui.scavs.bossAngerAggression", { value = math.round(Spring.GetGameRulesParam("ScavBossAngerGain_Aggression"), 3) }), panelMarginX + 5, PanelRow(4), panelFontSize, "") + if SpringShared.GetGameRulesParam("ScavBossAngerGain_Base") then + font:Print(textColor .. Spring.I18N("ui.scavs.bossAngerBase", { value = math.round(SpringShared.GetGameRulesParam("ScavBossAngerGain_Base"), 3) }), panelMarginX + 5, PanelRow(3), panelFontSize, "") + font:Print(textColor .. Spring.I18N("ui.scavs.bossAngerAggression", { value = math.round(SpringShared.GetGameRulesParam("ScavBossAngerGain_Aggression"), 3) }), panelMarginX + 5, PanelRow(4), panelFontSize, "") --font:Print(textColor .. Spring.I18N('ui.scavs.bossAngerEco', { value = math.round(Spring.GetGameRulesParam("ScavBossAngerGain_Eco"), 3) }), panelMarginX+5, PanelRow(5), panelFontSize, "") - gain = math.round(Spring.GetGameRulesParam("ScavBossAngerGain_Base"), 3) + math.round(Spring.GetGameRulesParam("ScavBossAngerGain_Aggression"), 3) + math.round(Spring.GetGameRulesParam("ScavBossAngerGain_Eco"), 3) + gain = math.round(SpringShared.GetGameRulesParam("ScavBossAngerGain_Base"), 3) + math.round(SpringShared.GetGameRulesParam("ScavBossAngerGain_Aggression"), 3) + math.round(SpringShared.GetGameRulesParam("ScavBossAngerGain_Eco"), 3) end --font:Print(textColor .. Spring.I18N('ui.scavs.bossAngerWithGain', { anger = gameInfo.scavBossAnger, gain = math.round(gain, 3) }), panelMarginX, PanelRow(1), panelFontSize, "") font:Print(textColor .. Spring.I18N("ui.scavs.bossAngerWithTech", { anger = mathFloor(0.5 + gameInfo.scavBossAnger), techAnger = gameInfo.scavTechAnger }), panelMarginX, PanelRow(1), panelFontSize, "") @@ -185,7 +185,7 @@ local function CreatePanelDisplayList() -- font:Print(textColor .. Spring.I18N('ui.scavs.scavKillCount', { count = gameInfo.scavKills }), panelMarginX, PanelRow(6), panelFontSize, "") local endless = "" - if Spring.GetModOptions().scav_endless then + if SpringShared.GetModOptions().scav_endless then endless = " (" .. Spring.I18N("ui.scavs.difficulty.endless") .. ")" end local difficultyCaption = Spring.I18N("ui.scavs.difficulty." .. difficultyOption) @@ -264,9 +264,9 @@ local function Draw() end if showMarqueeMessage then - local t = Spring.GetTimer() + local t = SpringUnsynced.GetTimer() - local waveY = viewSizeY - Spring.DiffTimers(t, waveTime) * waveSpeed * viewSizeY + local waveY = viewSizeY - SpringUnsynced.DiffTimers(t, waveTime) * waveSpeed * viewSizeY if waveY > 0 then if refreshMarqueeMessage or not marqueeMessage then marqueeMessage = getMarqueeMessage(messageArgs) @@ -284,7 +284,7 @@ local function Draw() end elseif #resistancesTable > 0 then marqueeMessage = getResistancesMessage() - waveTime = Spring.GetTimer() + waveTime = SpringUnsynced.GetTimer() showMarqueeMessage = true end end @@ -295,7 +295,7 @@ local function UpdateRules() end for _, rule in ipairs(rules) do - gameInfo[rule] = Spring.GetGameRulesParam(rule) or 0 + gameInfo[rule] = SpringShared.GetGameRulesParam(rule) or 0 end gameInfo.scavCounts = getScavCounts("Count") gameInfo.scavKills = getScavCounts("Kills") @@ -304,13 +304,13 @@ local function UpdateRules() end function ScavEvent(scavEventArgs) - if scavEventArgs.type == "firstWave" or (scavEventArgs.type == "boss" and Spring.DiffTimers(Spring.GetTimer(), bossToastTimer) > 10) then + if scavEventArgs.type == "firstWave" or (scavEventArgs.type == "boss" and SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), bossToastTimer) > 10) then showMarqueeMessage = true refreshMarqueeMessage = true messageArgs = scavEventArgs - waveTime = Spring.GetTimer() + waveTime = SpringUnsynced.GetTimer() if scavEventArgs.type == "boss" then - bossToastTimer = Spring.GetTimer() + bossToastTimer = SpringUnsynced.GetTimer() end end @@ -329,7 +329,7 @@ function ScavEvent(scavEventArgs) showMarqueeMessage = true refreshMarqueeMessage = true messageArgs = scavEventArgs - waveTime = Spring.GetTimer() + waveTime = SpringUnsynced.GetTimer() end end @@ -359,7 +359,7 @@ end function widget:Shutdown() if hasScavEvent then - Spring.SendCommands({ "luarules HasScavEvent 0" }) + SpringUnsynced.SendCommands({ "luarules HasScavEvent 0" }) end if guiPanel then @@ -374,7 +374,7 @@ end function widget:GameFrame(n) if not hasScavEvent and n > 1 then - Spring.SendCommands({ "luarules HasScavEvent 1" }) + SpringUnsynced.SendCommands({ "luarules HasScavEvent 1" }) hasScavEvent = true end if n % 30 < 1 then diff --git a/luaui/Widgets/gui_scavenger_info.lua b/luaui/Widgets/gui_scavenger_info.lua index 5a422d5217a..28384444fe5 100644 --- a/luaui/Widgets/gui_scavenger_info.lua +++ b/luaui/Widgets/gui_scavenger_info.lua @@ -23,7 +23,7 @@ local mathFloor = math.floor local mathMax = math.max -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local show = true -- gets disabled when it has been loaded before @@ -203,9 +203,9 @@ function widget:DrawScreen() end showOnceMore = false - local x, y, pressed = Spring.GetMouseState() + local x, y, pressed = SpringUnsynced.GetMouseState() if math_isInRect(x, y, screenX, screenY - screenHeight, screenX + screenWidth, screenY) or math_isInRect(x, y, titleRect[1], titleRect[2], titleRect[3], titleRect[4]) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end elseif dlistcreated and WG["guishader"] then @@ -253,7 +253,7 @@ function widget:MouseRelease(x, y, button) end function mouseEvent(x, y, button, release) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end @@ -297,7 +297,7 @@ function widget:Initialize() end widget:ViewResize() else - Spring.Echo("Text: couldn't load the text file") + SpringShared.Echo("Text: couldn't load the text file") widgetHandler:RemoveWidget() end end diff --git a/luaui/Widgets/gui_screen_mode_info.lua b/luaui/Widgets/gui_screen_mode_info.lua index b86f177483b..16ac2174218 100644 --- a/luaui/Widgets/gui_screen_mode_info.lua +++ b/luaui/Widgets/gui_screen_mode_info.lua @@ -14,11 +14,11 @@ end local keyConfig = VFS.Include("luaui/configs/keyboard_layouts.lua") -local spGetActionHotkeys = Spring.GetActionHotKeys -local spGetCameraState = Spring.GetCameraState -local spGetMapDrawMode = Spring.GetMapDrawMode -local spGetConfigString = Spring.GetConfigString -local spGetViewGeometry = Spring.GetViewGeometry +local spGetActionHotkeys = SpringUnsynced.GetActionHotKeys +local spGetCameraState = SpringUnsynced.GetCameraState +local spGetMapDrawMode = SpringUnsynced.GetMapDrawMode +local spGetConfigString = SpringUnsynced.GetConfigString +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local i18n = Spring.I18N local glPopMatrix = gl.PopMatrix diff --git a/luaui/Widgets/gui_scrolldown_toggleoverview.lua b/luaui/Widgets/gui_scrolldown_toggleoverview.lua index 27f34832e50..b499ded2a0f 100644 --- a/luaui/Widgets/gui_scrolldown_toggleoverview.lua +++ b/luaui/Widgets/gui_scrolldown_toggleoverview.lua @@ -17,29 +17,29 @@ function widget:GetInfo() end function widget:MouseWheel(up) - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if alt or ctrl or meta or shift then return end - local camState = Spring.GetCameraState() + local camState = SpringUnsynced.GetCameraState() local isOverview = camState.name == "ov" - if Spring.GetConfigInt("ScrollWheelSpeed", 1) > 0 then + if SpringUnsynced.GetConfigInt("ScrollWheelSpeed", 1) > 0 then up = not up end if up then if isOverview then - Spring.SendCommands({ "toggleoverview" }) + SpringUnsynced.SendCommands({ "toggleoverview" }) end return true end if not isOverview then - Spring.SendCommands({ "toggleoverview" }) + SpringUnsynced.SendCommands({ "toggleoverview" }) end return true diff --git a/luaui/Widgets/gui_selectedunits_gl4.lua b/luaui/Widgets/gui_selectedunits_gl4.lua index e17e1dc0ee1..3aca9b6a071 100644 --- a/luaui/Widgets/gui_selectedunits_gl4.lua +++ b/luaui/Widgets/gui_selectedunits_gl4.lua @@ -13,9 +13,9 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetSelectedUnits = Spring.GetSelectedUnits -local spEcho = Spring.Echo -local spGetUnitTeam = Spring.GetUnitTeam +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spEcho = SpringShared.Echo +local spGetUnitTeam = SpringShared.GetUnitTeam -- Configurable Parts: local texture = "luaui/images/solid.png" @@ -30,7 +30,7 @@ local mouseoverHighlight = true local selectionVBOGround = nil local selectionVBOAir = nil -local mapHasWater = (Spring.GetGroundExtremes() < 0) +local mapHasWater = (SpringShared.GetGroundExtremes() < 0) local selectShader = nil local luaShaderDir = "LuaUI/Include/" @@ -81,17 +81,17 @@ end local unitBufferUniformCache = { 0 } local function AddPrimitiveAtUnit(unitID) - if Spring.ValidUnitID(unitID) ~= true or Spring.GetUnitIsDead(unitID) == true or Spring.IsGUIHidden() then + if SpringShared.ValidUnitID(unitID) ~= true or SpringShared.GetUnitIsDead(unitID) == true or SpringUnsynced.IsGUIHidden() then return end - local gf = Spring.GetGameFrame() - local _, _, isPaused = Spring.GetGameSpeed() + local gf = SpringShared.GetGameFrame() + local _, _, isPaused = SpringUnsynced.GetGameSpeed() if isPaused then gf = gf - 10 end if not unitUnitDefID[unitID] then - unitUnitDefID[unitID] = Spring.GetUnitDefID(unitID) + unitUnitDefID[unitID] = SpringShared.GetUnitDefID(unitID) end local unitDefID = unitUnitDefID[unitID] if unitDefID == nil then @@ -221,7 +221,7 @@ local function RemovePrimitive(unitID) if selectionVBO and selectionVBO.instanceIDtoIndex[unitID] then if selectionHighlight then unitBufferUniformCache[1] = 0 - if Spring.ValidUnitID(unitID) then + if SpringShared.ValidUnitID(unitID) then gl.SetUnitBufferUniforms(unitID, unitBufferUniformCache, 6) end end @@ -239,13 +239,13 @@ local cleanedForHiddenUI = false local function ClearLastMouseOver() if lastMouseOverUnitID then - if Spring.ValidUnitID(lastMouseOverUnitID) then + if SpringShared.ValidUnitID(lastMouseOverUnitID) then gl.SetUnitBufferUniforms(lastMouseOverUnitID, { selUnits[lastMouseOverUnitID] and 1 or 0 }, 6) end lastMouseOverUnitID = nil end if lastMouseOverFeatureID then - if Spring.ValidFeatureID(lastMouseOverFeatureID) then + if SpringShared.ValidFeatureID(lastMouseOverFeatureID) then gl.SetFeatureBufferUniforms(lastMouseOverFeatureID, { 0 }, 6) end lastMouseOverFeatureID = nil @@ -254,7 +254,7 @@ end function widget:Update(dt) -- Handle UI visibility: clear selections when hidden, resync on show - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then if not cleanedForHiddenUI then ClearLastMouseOver() for unitID, _ in pairs(selUnits) do @@ -302,13 +302,13 @@ function widget:Update(dt) -- +0.5 means ally also selected unit -- +2 means its mouseovered if mouseoverHighlight then - local mx, my, p1, mmb, _, mouseOffScreen, cameraPanMode = Spring.GetMouseState() + local mx, my, p1, mmb, _, mouseOffScreen, cameraPanMode = SpringUnsynced.GetMouseState() if mouseOffScreen or cameraPanMode or mmb or p1 then ClearLastMouseOver() else - local result, data = Spring.TraceScreenRay(mx, my) + local result, data = SpringUnsynced.TraceScreenRay(mx, my) --spEcho(result, (type(data) == 'table') or data, lastMouseOverUnitID, lastMouseOverFeatureID) - if result == "unit" and not Spring.IsGUIHidden() then + if result == "unit" and not SpringUnsynced.IsGUIHidden() then local unitID = data if lastMouseOverUnitID ~= unitID then ClearLastMouseOver() @@ -316,7 +316,7 @@ function widget:Update(dt) gl.SetUnitBufferUniforms(unitID, { newUniform }, 6) lastMouseOverUnitID = unitID end - elseif result == "feature" and not Spring.IsGUIHidden() then + elseif result == "feature" and not SpringUnsynced.IsGUIHidden() then local featureID = data if lastMouseOverFeatureID ~= featureID then ClearLastMouseOver() @@ -416,12 +416,12 @@ function widget:Initialize() return selectimouseoverHighlightonHighlight end - Spring.LoadCmdColorsConfig("unitBox 0 1 0 0") + SpringUnsynced.LoadCmdColorsConfig("unitBox 0 1 0 0") end function widget:Shutdown() if not (WG.teamplatter or WG.highlightselunits) then - Spring.LoadCmdColorsConfig("unitBox 0 1 0 1") + SpringUnsynced.LoadCmdColorsConfig("unitBox 0 1 0 1") end WG.selectedunits = nil end diff --git a/luaui/Widgets/gui_selectionbox.lua b/luaui/Widgets/gui_selectionbox.lua index a425f239258..4ae4232fdf8 100644 --- a/luaui/Widgets/gui_selectionbox.lua +++ b/luaui/Widgets/gui_selectionbox.lua @@ -31,23 +31,23 @@ function widget:ViewResize(vsx, vsy) end function widget:Initialize() - widget:ViewResize(Spring.GetViewGeometry()) + widget:ViewResize(SpringUnsynced.GetViewGeometry()) -- Disable engine's selection box rendering completely by setting line width to 0 -- and making the color transparent - Spring.LoadCmdColorsConfig("mouseBoxLineWidth 0") + SpringUnsynced.LoadCmdColorsConfig("mouseBoxLineWidth 0") end function widget:Shutdown() -- Restore engine's default selection box - Spring.LoadCmdColorsConfig("mouseBoxLineWidth 1.5") + SpringUnsynced.LoadCmdColorsConfig("mouseBoxLineWidth 1.5") end function widget:DrawScreen() -- This blurs the UI elements obscured by other UI elements (only unit stats so far!) - local x1, y1, x2, y2 = Spring.GetSelectionBox() + local x1, y1, x2, y2 = SpringUnsynced.GetSelectionBox() if y2 then -- Get modifier key states - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() gl.PushMatrix() @@ -112,7 +112,7 @@ function widget:MousePress(x, y, button) end -- Check if click is on minimap - local mmX, mmY, mmW, mmH, minimized, maximized = Spring.GetMiniMapGeometry() + local mmX, mmY, mmW, mmH, minimized, maximized = SpringUnsynced.GetMiniMapGeometry() if not mmX or minimized or maximized then return false end @@ -140,7 +140,7 @@ end function widget:Update() -- Check if mouse is pressed and on minimap - local mx, my, leftPressed = Spring.GetMouseState() + local mx, my, leftPressed = SpringUnsynced.GetMouseState() if leftPressed then -- Don't track selection if minimap left-click-move is enabled @@ -151,8 +151,8 @@ function widget:Update() return end - local mmX, mmY, mmW, mmH, minimized, maximized = Spring.GetMiniMapGeometry() - local vsx, vsy = Spring.GetViewGeometry() + local mmX, mmY, mmW, mmH, minimized, maximized = SpringUnsynced.GetMiniMapGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() if mmX and not minimized and not maximized then -- mmY is the bottom edge of the minimap (distance from screen bottom) -- Top edge is at mmY + mmH @@ -225,7 +225,7 @@ function widget:DrawInMiniMap(minimapWidth, minimapHeight) end -- Get modifier key states - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() -- Validate that both start and end are within minimap bounds local x1, y1 = minimapSelectionStart.x, minimapSelectionStart.y diff --git a/luaui/Widgets/gui_selfd_icons.lua b/luaui/Widgets/gui_selfd_icons.lua index a1238cd87d0..258be94e08f 100644 --- a/luaui/Widgets/gui_selfd_icons.lua +++ b/luaui/Widgets/gui_selfd_icons.lua @@ -13,8 +13,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spGetSpectatingState = Spring.GetSpectatingState +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local ignoreUnitDefs = {} local unitConf = {} @@ -40,14 +40,14 @@ local drawLists = {} local glDrawListAtUnit = gl.DrawListAtUnit local glDepthTest = gl.DepthTest local spGetUnitDefID = spGetUnitDefID -local spIsUnitInView = Spring.IsUnitInView -local spGetUnitSelfDTime = Spring.GetUnitSelfDTime -local spGetAllUnits = Spring.GetAllUnits -local spGetUnitCommands = Spring.GetUnitCommands -local spIsUnitAllied = Spring.IsUnitAllied -local spGetCameraDirection = Spring.GetCameraDirection -local spIsGUIHidden = Spring.IsGUIHidden -local spGetUnitTransporter = Spring.GetUnitTransporter +local spIsUnitInView = SpringUnsynced.IsUnitInView +local spGetUnitSelfDTime = SpringShared.GetUnitSelfDTime +local spGetAllUnits = SpringShared.GetAllUnits +local spGetUnitCommands = SpringShared.GetUnitCommands +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spGetCameraDirection = SpringUnsynced.GetCameraDirection +local spIsGUIHidden = SpringUnsynced.IsGUIHidden +local spGetUnitTransporter = SpringShared.GetUnitTransporter local spec = spGetSpectatingState() diff --git a/luaui/Widgets/gui_sensor_ranges_jammer.lua b/luaui/Widgets/gui_sensor_ranges_jammer.lua index 866377c3de5..d45009daf2d 100644 --- a/luaui/Widgets/gui_sensor_ranges_jammer.lua +++ b/luaui/Widgets/gui_sensor_ranges_jammer.lua @@ -13,9 +13,9 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry ------- Configurables: ------------------- local debugmode = false @@ -30,7 +30,7 @@ local rangecorrectionelmos = debugmode and -16 or 16 -- how much smaller they ar --------- End configurables ------ local minJammerDistance = 63 -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() ------- GL4 NOTES ----- -- TODO: 2025.07.02: @@ -169,10 +169,10 @@ if debugmode then end -- Functions shortcuts -local spGetSpectatingState = Spring.GetSpectatingState -local spIsUnitAllied = Spring.IsUnitAllied -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitIsActive = Spring.GetUnitIsActive +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitIsActive = SpringShared.GetUnitIsActive local GL_NOTEQUAL = GL.NOTEQUAL local GL_LINE_LOOP = GL.LINE_LOOP local GL_KEEP = 0x1E00 --GL.KEEP @@ -223,7 +223,7 @@ function widget:PlayerChanged() end function widget:Initialize() - if not gl.CreateShader or Spring.GetModOptions().disable_fogofwar then -- no shader support, so just remove the widget itself, especially for headless + if not gl.CreateShader or SpringShared.GetModOptions().disable_fogofwar then -- no shader support, so just remove the widget itself, especially for headless widgetHandler:RemoveWidget() return end @@ -261,7 +261,7 @@ function widget:VisibleUnitAdded(unitID, unitDefID, unitTeam, reason, noupload) return end -- display mode for specs - if Spring.GetUnitIsBeingBuilt(unitID) then + if SpringShared.GetUnitIsBeingBuilt(unitID) then return end @@ -313,7 +313,7 @@ function widget:GameFrame(n) local active = spGetUnitIsActive(unitID) if active ~= oldActive then unitList[unitID] = active - widget:VisibleUnitAdded(unitID, Spring.GetUnitDefID(unitID), spGetUnitTeam(unitID)) + widget:VisibleUnitAdded(unitID, SpringShared.GetUnitDefID(unitID), spGetUnitTeam(unitID)) end end end @@ -321,7 +321,7 @@ end function widget:DrawWorld() --if spec and fullview then return end - if Spring.IsGUIHidden() or (circleInstanceVBO.usedElements == 0) or (opacity <= 0.01) then + if SpringUnsynced.IsGUIHidden() or (circleInstanceVBO.usedElements == 0) or (opacity <= 0.01) then return end diff --git a/luaui/Widgets/gui_sensor_ranges_los.lua b/luaui/Widgets/gui_sensor_ranges_los.lua index dd52081e62f..837f7bff366 100644 --- a/luaui/Widgets/gui_sensor_ranges_los.lua +++ b/luaui/Widgets/gui_sensor_ranges_los.lua @@ -13,8 +13,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry ------- Configurables: ------------------- local debugmode = false @@ -30,7 +30,7 @@ local rangecorrectionelmos = debugmode and -16 or 16 -- how much smaller they ar --------- End configurables ------ local minSightDistance = 100 -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() ------- GL4 NOTES ----- -- TODO: draw ally ranges in diff color! @@ -189,9 +189,9 @@ if debugmode then end -- Functions shortcuts -local spGetSpectatingState = Spring.GetSpectatingState -local spIsUnitAllied = Spring.IsUnitAllied -local spGetUnitTeam = Spring.GetUnitTeam +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spGetUnitTeam = SpringShared.GetUnitTeam local GL_NOTEQUAL = GL.NOTEQUAL local GL_LINE_LOOP = GL.LINE_LOOP local GL_KEEP = 0x1E00 --GL.KEEP @@ -241,7 +241,7 @@ function widget:PlayerChanged() end function widget:Initialize() - if not gl.CreateShader or Spring.GetModOptions().disable_fogofwar then -- no shader support, so just remove the widget itself, especially for headless + if not gl.CreateShader or SpringShared.GetModOptions().disable_fogofwar then -- no shader support, so just remove the widget itself, especially for headless widgetHandler:RemoveWidget() return end @@ -285,13 +285,13 @@ function widget:VisibleUnitAdded(unitID, unitDefID, unitTeam, reason, noupload) return end -- display mode for specs - if Spring.GetUnitIsBeingBuilt(unitID) then + if SpringShared.GetUnitIsBeingBuilt(unitID) then return end instanceCache[1] = unitRange[unitDefID] if reason == "UnitFinished" then - instanceCache[2] = Spring.GetGameFrame() + instanceCache[2] = SpringShared.GetGameFrame() else instanceCache[2] = 0 -- start from full size end @@ -317,7 +317,7 @@ end function widget:DrawWorld() --if spec and fullview then return end - if Spring.IsGUIHidden() or (circleInstanceVBO.usedElements == 0) or (opacity <= 0.01) then + if SpringUnsynced.IsGUIHidden() or (circleInstanceVBO.usedElements == 0) or (opacity <= 0.01) then return end diff --git a/luaui/Widgets/gui_sensor_ranges_radar.lua b/luaui/Widgets/gui_sensor_ranges_radar.lua index f5f90e6e34c..1a0f6118222 100644 --- a/luaui/Widgets/gui_sensor_ranges_radar.lua +++ b/luaui/Widgets/gui_sensor_ranges_radar.lua @@ -13,9 +13,9 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry ------- Configurables: ------------------- local debugmode = false @@ -30,7 +30,7 @@ local rangecorrectionelmos = debugmode and -16 or 16 -- how much smaller they ar --------- End configurables ------ local minRadarDistance = 500 -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() ------- GL4 NOTES ----- -- TODO: 2025.07.02: @@ -169,10 +169,10 @@ if debugmode then end -- Functions shortcuts -local spGetSpectatingState = Spring.GetSpectatingState -local spIsUnitAllied = Spring.IsUnitAllied -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitIsActive = Spring.GetUnitIsActive +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitIsActive = SpringShared.GetUnitIsActive local GL_NOTEQUAL = GL.NOTEQUAL local GL_LINE_LOOP = GL.LINE_LOOP local GL_KEEP = 0x1E00 --GL.KEEP @@ -223,7 +223,7 @@ function widget:PlayerChanged() end function widget:Initialize() - if not gl.CreateShader or Spring.GetModOptions().disable_fogofwar then -- no shader support, so just remove the widget itself, especially for headless + if not gl.CreateShader or SpringShared.GetModOptions().disable_fogofwar then -- no shader support, so just remove the widget itself, especially for headless widgetHandler:RemoveWidget() return end @@ -261,7 +261,7 @@ function widget:VisibleUnitAdded(unitID, unitDefID, unitTeam, reason, noupload) return end -- display mode for specs - if Spring.GetUnitIsBeingBuilt(unitID) then + if SpringShared.GetUnitIsBeingBuilt(unitID) then return end @@ -313,7 +313,7 @@ function widget:GameFrame(n) local active = spGetUnitIsActive(unitID) if active ~= oldActive then unitList[unitID] = active - widget:VisibleUnitAdded(unitID, Spring.GetUnitDefID(unitID), spGetUnitTeam(unitID)) + widget:VisibleUnitAdded(unitID, SpringShared.GetUnitDefID(unitID), spGetUnitTeam(unitID)) end end end @@ -321,7 +321,7 @@ end function widget:DrawWorld() --if spec and fullview then return end - if Spring.IsGUIHidden() or (circleInstanceVBO.usedElements == 0) or (opacity <= 0.01) then + if SpringUnsynced.IsGUIHidden() or (circleInstanceVBO.usedElements == 0) or (opacity <= 0.01) then return end diff --git a/luaui/Widgets/gui_sensor_ranges_radar_preview.lua b/luaui/Widgets/gui_sensor_ranges_radar_preview.lua index b17417527c3..fc878cbdd4b 100644 --- a/luaui/Widgets/gui_sensor_ranges_radar_preview.lua +++ b/luaui/Widgets/gui_sensor_ranges_radar_preview.lua @@ -16,8 +16,8 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spEcho = Spring.Echo +local spGetUnitDefID = SpringShared.GetUnitDefID +local spEcho = SpringShared.Echo ------- GL4 NOTES ----- -- There is regular radar and advanced radar, assumed to have identical ranges! @@ -33,7 +33,7 @@ local radarYOffset = 50 -- amount added to vertical height of overlay to more cl -- Globals local mousepos = { 0, 0, 0 } -local spGetActiveCommand = Spring.GetActiveCommand +local spGetActiveCommand = SpringUnsynced.GetActiveCommand local LuaShader = gl.LuaShader local InstanceVBOTable = gl.InstanceVBOTable @@ -146,7 +146,7 @@ function widget:DrawWorld() end -- not build command end - if Spring.IsGUIHidden() or (WG["topbar"] and WG["topbar"].showingQuit()) then + if SpringUnsynced.IsGUIHidden() or (WG["topbar"] and WG["topbar"].showingQuit()) then return end @@ -155,10 +155,10 @@ function widget:DrawWorld() return end if selectedRadarUnitID then - mousepos = { Spring.GetUnitPosition(selectedRadarUnitID) } + mousepos = { SpringShared.GetUnitPosition(selectedRadarUnitID) } else - local mx, my, lp, mp, rp, offscreen = Spring.GetMouseState() - local _, coords = Spring.TraceScreenRay(mx, my, true) + local mx, my, lp, mp, rp, offscreen = SpringUnsynced.GetMouseState() + local _, coords = SpringUnsynced.TraceScreenRay(mx, my, true) if coords then mousepos = { coords[1], coords[2], coords[3] } end diff --git a/luaui/Widgets/gui_sensor_ranges_sonar.lua b/luaui/Widgets/gui_sensor_ranges_sonar.lua index 66ef39bbdb8..9699335b45d 100644 --- a/luaui/Widgets/gui_sensor_ranges_sonar.lua +++ b/luaui/Widgets/gui_sensor_ranges_sonar.lua @@ -13,9 +13,9 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spGetGameFrame = SpringShared.GetGameFrame +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry ------- Configurables: ------------------- local debugmode = false @@ -30,7 +30,7 @@ local rangecorrectionelmos = debugmode and -16 or 16 -- how much smaller they ar --------- End configurables ------ local minSonarDistance = 250 -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() ------- GL4 NOTES ----- -- TODO: 2025.07.02: @@ -170,11 +170,11 @@ if debugmode then end -- Functions shortcuts -local spGetSpectatingState = Spring.GetSpectatingState -local spGetUnitDefID = Spring.GetUnitDefID -local spIsUnitAllied = Spring.IsUnitAllied -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitIsActive = Spring.GetUnitIsActive +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetUnitDefID = SpringShared.GetUnitDefID +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitIsActive = SpringShared.GetUnitIsActive local GL_NOTEQUAL = GL.NOTEQUAL local GL_LINE_LOOP = GL.LINE_LOOP local GL_KEEP = 0x1E00 --GL.KEEP @@ -229,11 +229,11 @@ function widget:PlayerChanged() end function widget:Initialize() - if Spring.GetGroundExtremes() > 50 then + if SpringShared.GetGroundExtremes() > 50 then widgetHandler:RemoveWidget() return end - if not gl.CreateShader or Spring.GetModOptions().disable_fogofwar then -- no shader support, so just remove the widget itself, especially for headless + if not gl.CreateShader or SpringShared.GetModOptions().disable_fogofwar then -- no shader support, so just remove the widget itself, especially for headless widgetHandler:RemoveWidget() return end @@ -271,7 +271,7 @@ function widget:VisibleUnitAdded(unitID, unitDefID, unitTeam, reason, noupload) return end -- display mode for specs - if Spring.GetUnitIsBeingBuilt(unitID) then + if SpringShared.GetUnitIsBeingBuilt(unitID) then return end @@ -331,7 +331,7 @@ end function widget:DrawWorld() --if spec and fullview then return end - if Spring.IsGUIHidden() or (circleInstanceVBO.usedElements == 0) or (opacity <= 0.01) then + if SpringUnsynced.IsGUIHidden() or (circleInstanceVBO.usedElements == 0) or (opacity <= 0.01) then return end diff --git a/luaui/Widgets/gui_show_orders.lua b/luaui/Widgets/gui_show_orders.lua index 618ef063f13..6a296dc666c 100644 --- a/luaui/Widgets/gui_show_orders.lua +++ b/luaui/Widgets/gui_show_orders.lua @@ -31,7 +31,7 @@ end ----------------------------------------------------- -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local vsx, vsy = spGetViewGeometry() local widgetScale = vsy / 2000 @@ -62,7 +62,7 @@ local maxScale = 1.0 -- Maximum scale factor (1.0 = 100% of original size) -- Globals ----------------------------------------------------- local isFactory = {} -local GaiaTeamID = Spring.GetGaiaTeamID() -- set to -1 to include Gaia units +local GaiaTeamID = SpringShared.GetGaiaTeamID() -- set to -1 to include Gaia units local font, chobbyInterface @@ -141,20 +141,20 @@ end ----------------------------------------------------- local floor = math.floor -local spGetModKeyState = Spring.GetModKeyState -local spDrawUnitCommands = Spring.DrawUnitCommands -local spGetFactoryCommands = Spring.GetFactoryCommands -local spGetSpecState = Spring.GetSpectatingState -local spGetTeamList = Spring.GetTeamList -local spGetTeamUnits = Spring.GetTeamUnits +local spGetModKeyState = SpringUnsynced.GetModKeyState +local spDrawUnitCommands = SpringUnsynced.DrawUnitCommands +local spGetFactoryCommands = SpringShared.GetFactoryCommands +local spGetSpecState = SpringUnsynced.GetSpectatingState +local spGetTeamList = SpringShared.GetTeamList +local spGetTeamUnits = SpringShared.GetTeamUnits local spGetMyAllyTeamID = Spring.GetMyAllyTeamID -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spWorldToScreenCoords = Spring.WorldToScreenCoords -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local spGetUnitStates = Spring.GetUnitStates -local spGetCameraPosition = Spring.GetCameraPosition -local spGetTeamInfo = Spring.GetTeamInfo +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spWorldToScreenCoords = SpringUnsynced.WorldToScreenCoords +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local spGetUnitStates = SpringShared.GetUnitStates +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spGetTeamInfo = SpringShared.GetTeamInfo local glColor = gl.Color local glTexture = gl.Texture diff --git a/luaui/Widgets/gui_spec_next_alive_player.lua b/luaui/Widgets/gui_spec_next_alive_player.lua index 4ad3e220b33..305a21884e7 100644 --- a/luaui/Widgets/gui_spec_next_alive_player.lua +++ b/luaui/Widgets/gui_spec_next_alive_player.lua @@ -13,38 +13,38 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local processTeamDiedFrame, processTeamDiedTeamID local function switchToTeam(teamID) - local oldMapDrawMode = Spring.GetMapDrawMode() - Spring.SelectUnitArray({}) - Spring.SendCommands("specteam " .. teamID) - local newMapDrawMode = Spring.GetMapDrawMode() + local oldMapDrawMode = SpringUnsynced.GetMapDrawMode() + SpringUnsynced.SelectUnitArray({}) + SpringUnsynced.SendCommands("specteam " .. teamID) + local newMapDrawMode = SpringUnsynced.GetMapDrawMode() if oldMapDrawMode == "los" and oldMapDrawMode ~= newMapDrawMode then - Spring.SendCommands("togglelos") + SpringUnsynced.SendCommands("togglelos") end end local function processTeamDied(teamID) - local _, _, isDead = Spring.GetTeamInfo(teamID, false) + local _, _, isDead = SpringShared.GetTeamInfo(teamID, false) if isDead and spGetMyTeamID() == teamID then local myAllyTeamID = Spring.GetMyAllyTeamID() -- first try alive team mates - local teamList = Spring.GetTeamList(myAllyTeamID) + local teamList = SpringShared.GetTeamList(myAllyTeamID) for _, teamListID in ipairs(teamList) do - local _, _, isDead = Spring.GetTeamInfo(teamListID, false) + local _, _, isDead = SpringShared.GetTeamInfo(teamListID, false) if not isDead then switchToTeam(teamListID) return end end - teamList = Spring.GetTeamList() + teamList = SpringShared.GetTeamList() for _, teamListID in ipairs(teamList) do - local _, _, isDead, _, _, allyTeamID = Spring.GetTeamInfo(teamListID, false) + local _, _, isDead, _, _, allyTeamID = SpringShared.GetTeamInfo(teamListID, false) if not isDead and allyTeamID ~= myAllyTeamID then switchToTeam(teamListID) return @@ -64,7 +64,7 @@ end function widget:PlayerChanged(playerID) local spec = spGetSpectatingState() - local _, _, _, teamID = Spring.GetPlayerInfo(playerID, false) -- player can be spec here and team not be dead still + local _, _, _, teamID = SpringShared.GetPlayerInfo(playerID, false) -- player can be spec here and team not be dead still if spec and teamID and spGetMyTeamID() == teamID then processTeamDiedFrame = spGetGameFrame() + 1 processTeamDiedTeamID = teamID diff --git a/luaui/Widgets/gui_spectate_selected.lua b/luaui/Widgets/gui_spectate_selected.lua index b57ce354f94..61ee5fb5533 100644 --- a/luaui/Widgets/gui_spectate_selected.lua +++ b/luaui/Widgets/gui_spectate_selected.lua @@ -15,9 +15,9 @@ end -- Localized Spring API for performance local spGetMyTeamID = Spring.GetMyTeamID -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState -local spGetUnitTeam = Spring.GetUnitTeam +local spGetUnitTeam = SpringShared.GetUnitTeam local spec, fullview = spGetSpectatingState() local myTeamID = spGetMyTeamID() @@ -46,11 +46,11 @@ function widget:Update(dt) sec = sec + dt if sec > 1.5 and switchToTeam ~= nil then -- added a delay cause doing too quick changes is perf costly, happens when you area drag lots of mixed team units - local oldMapDrawMode = Spring.GetMapDrawMode() - Spring.SendCommands("specteam " .. switchToTeam) - local newMapDrawMode = Spring.GetMapDrawMode() + local oldMapDrawMode = SpringUnsynced.GetMapDrawMode() + SpringUnsynced.SendCommands("specteam " .. switchToTeam) + local newMapDrawMode = SpringUnsynced.GetMapDrawMode() if oldMapDrawMode == "los" and oldMapDrawMode ~= newMapDrawMode then - Spring.SendCommands("togglelos") + SpringUnsynced.SendCommands("togglelos") end myTeamID = switchToTeam diff --git a/luaui/Widgets/gui_spectatingstats.lua b/luaui/Widgets/gui_spectatingstats.lua index 86069fac796..da63aeb5f3d 100644 --- a/luaui/Widgets/gui_spectatingstats.lua +++ b/luaui/Widgets/gui_spectatingstats.lua @@ -13,12 +13,12 @@ function widget:GetInfo() end local lastupdate = os.clock() - 10 -local allyTeamList = Spring.GetAllyTeamList() +local allyTeamList = SpringShared.GetAllyTeamList() local numAllyTeams = #allyTeamList - 1 local allyTeamName = {} local textcolor = "\255\200\200\200" -local spGetUnitDefID = Spring.GetUnitDefID +local spGetUnitDefID = SpringShared.GetUnitDefID local isSinglePlayer = Spring.Utilities.Gametype.IsSinglePlayer() local ColorString = Spring.Utilities.Color.ToString @@ -59,13 +59,13 @@ for unitDefID, unitDef in pairs(UnitDefs) do end function widget:Initialize() - if not Spring.GetSpectatingState() and not isSinglePlayer then + if not SpringUnsynced.GetSpectatingState() and not isSinglePlayer then widgetHandler:RemoveWidget() end end local function GetAllyTeamStats(allyTeamID) - local teamlist = Spring.GetTeamList(allyTeamID) + local teamlist = SpringShared.GetTeamList(allyTeamID) local unitCount = 0 local armyCount = 0 local armyDps = 0 @@ -74,12 +74,12 @@ local function GetAllyTeamStats(allyTeamID) local builders = 0 local buildspeed = 0 if not allyTeamName[allyTeamID] then - local _, playerID, _, isAiTeam = Spring.GetTeamInfo(teamlist[1], false) - local name = (WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerID) or Spring.GetPlayerInfo(playerID, false) - allyTeamName[allyTeamID] = ColorString(Spring.GetTeamColor(teamlist[1])) .. name + local _, playerID, _, isAiTeam = SpringShared.GetTeamInfo(teamlist[1], false) + local name = (WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerID) or SpringShared.GetPlayerInfo(playerID, false) + allyTeamName[allyTeamID] = ColorString(SpringUnsynced.GetTeamColor(teamlist[1])) .. name end for i, teamID in ipairs(teamlist) do - local units = Spring.GetTeamUnits(teamID) + local units = SpringShared.GetTeamUnits(teamID) unitCount = unitCount + #units for _, unitID in ipairs(units) do local unitDefID = spGetUnitDefID(unitID) @@ -106,7 +106,7 @@ function widget:DrawScreen() if i <= numAllyTeams then local unitCount, armyCount, armyDps, defenseCount, defenseDps, builders, buildspeed = GetAllyTeamStats(allyTeamID) local text = string.format(allyTeamName[allyTeamID] .. textcolor .. ": %d units, %d army (%d DPS), defenses %d (%d DPS), builders %d (%d bp)", unitCount, armyCount, armyDps, defenseCount, defenseDps, builders, buildspeed) - Spring.Echo(text) + SpringShared.Echo(text) end end end diff --git a/luaui/Widgets/gui_spectator_hud.lua b/luaui/Widgets/gui_spectator_hud.lua index 296b5230901..b0b53bede95 100644 --- a/luaui/Widgets/gui_spectator_hud.lua +++ b/luaui/Widgets/gui_spectator_hud.lua @@ -65,15 +65,15 @@ local mathabs = math.abs local glColor = gl.Color local glRect = gl.Rect -local gaiaID = Spring.GetGaiaTeamID() -local gaiaAllyID = select(6, Spring.GetTeamInfo(gaiaID, false)) +local gaiaID = SpringShared.GetGaiaTeamID() +local gaiaAllyID = select(6, SpringShared.GetTeamInfo(gaiaID, false)) local widgetEnabled = nil local ecostatsHidden = false local haveFullView = false -local ui_scale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local ui_scale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) local scaleMultiplier = nil local widgetDimensions = {} @@ -269,7 +269,7 @@ local unitDefsToTrack = {} local function checkAndUpdateHaveFullView() local haveFullViewOld = haveFullView - haveFullView = select(2, Spring.GetSpectatingState()) + haveFullView = select(2, SpringUnsynced.GetSpectatingState()) return haveFullView ~= haveFullViewOld end @@ -442,7 +442,7 @@ local function buildUnitCache() update = function(unitID, value) local reclaimMetal = 0 local reclaimEnergy = 0 - local metalMake, metalUse, energyMake, energyUse = Spring.GetUnitResources(unitID) + local metalMake, metalUse, energyMake, energyUse = SpringShared.GetUnitResources(unitID) if metalMake then if value[1] then reclaimMetal = metalMake - value[1] @@ -462,7 +462,7 @@ local function buildUnitCache() unitCache.energyConverters = { add = nil, update = function(unitID, value) - local metalMake, metalUse, energyMake, energyUse = Spring.GetUnitResources(unitID) + local metalMake, metalUse, energyMake, energyUse = SpringShared.GetUnitResources(unitID) if metalMake then return metalMake end @@ -500,9 +500,9 @@ local function buildUnitCache() unitCache.utilityUnits = unitCache.armyUnits unitCache.economyBuildings = unitCache.armyUnits - for _, allyID in ipairs(Spring.GetAllyTeamList()) do + for _, allyID in ipairs(SpringShared.GetAllyTeamList()) do if allyID ~= gaiaAllyID then - local teamList = Spring.GetTeamList(allyID) + local teamList = SpringShared.GetTeamList(allyID) for _, teamID in ipairs(teamList) do unitCache[teamID] = {} cachedTotals[teamID] = {} @@ -520,11 +520,11 @@ local function buildUnitCache() cachedTotals[teamID].utilityUnits = 0 unitCache[teamID].economyBuildings = {} cachedTotals[teamID].economyBuildings = 0 - local unitIDs = Spring.GetTeamUnits(teamID) + local unitIDs = SpringShared.GetTeamUnits(teamID) for i = 1, #unitIDs do local unitID = unitIDs[i] - if not Spring.GetUnitIsBeingBuilt(unitID) then - local unitDefID = Spring.GetUnitDefID(unitID) + if not SpringShared.GetUnitIsBeingBuilt(unitID) then + local unitDefID = SpringShared.GetUnitDefID(unitID) addToUnitCache(teamID, unitID, unitDefID) end end @@ -535,18 +535,18 @@ end local function buildPlayerData() playerData = {} - for _, allyID in ipairs(Spring.GetAllyTeamList()) do + for _, allyID in ipairs(SpringShared.GetAllyTeamList()) do if allyID ~= gaiaAllyID then - local teamList = Spring.GetTeamList(allyID) + local teamList = SpringShared.GetTeamList(allyID) for _, teamID in ipairs(teamList) do local playerName = nil - local playerID = Spring.GetPlayerList(teamID, false) + local playerID = SpringShared.GetPlayerList(teamID, false) if playerID and playerID[1] then -- it's a player - playerName = select(1, Spring.GetPlayerInfo(playerID[1], false)) + playerName = select(1, SpringShared.GetPlayerInfo(playerID[1], false)) playerName = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(playerID[1])) or playerName else - local aiName = Spring.GetGameRulesParam("ainame_" .. teamID) + local aiName = SpringShared.GetGameRulesParam("ainame_" .. teamID) if aiName then -- it's AI playerName = aiName @@ -559,7 +559,7 @@ local function buildPlayerData() playerData[teamID] = {} playerData[teamID].name = playerName - local teamColor = { Spring.GetTeamColor(teamID) } + local teamColor = { SpringUnsynced.GetTeamColor(teamID) } playerData[teamID].color = teamColor end end @@ -637,13 +637,13 @@ local function buildAllyTeamTable() allyTeamTable = {} local allyTeamIndex = 1 - for _, allyID in ipairs(Spring.GetAllyTeamList()) do + for _, allyID in ipairs(SpringShared.GetAllyTeamList()) do if allyID ~= gaiaAllyID then allyTeamTable[allyTeamIndex] = {} - local teamList = Spring.GetTeamList(allyID) + local teamList = SpringShared.GetTeamList(allyID) if teamList and teamList[1] then - local colorCaptain = (playerData[teamList[1]] and playerData[teamList[1]].color) or { Spring.GetTeamColor(teamList[1]) } + local colorCaptain = (playerData[teamList[1]] and playerData[teamList[1]].color) or { SpringUnsynced.GetTeamColor(teamList[1]) } allyTeamTable[allyTeamIndex].color = colorCaptain allyTeamTable[allyTeamIndex].colorBar = makeDarkerColor(colorCaptain, constants.darkerBarsFactor) allyTeamTable[allyTeamIndex].colorLine = makeDarkerColor(colorCaptain, constants.darkerLinesFactor) @@ -667,7 +667,7 @@ end local function getAmountOfAllyTeams() local amountOfAllyTeams = 0 - for _, allyID in ipairs(Spring.GetAllyTeamList()) do + for _, allyID in ipairs(SpringShared.GetAllyTeamList()) do if allyID ~= gaiaAllyID then amountOfAllyTeams = amountOfAllyTeams + 1 end @@ -891,27 +891,27 @@ local function getOneStat(statKey, teamID) local result = 0 if statKey == metricKeys.metalIncome then - result = select(4, Spring.GetTeamResources(teamID, "metal")) or 0 + result = select(4, SpringShared.GetTeamResources(teamID, "metal")) or 0 elseif statKey == metricKeys.energyConversionMetalIncome then for unitID, _ in pairs(unitCache[teamID].energyConverters) do result = result + unitCache.energyConverters.update(unitID, 0) end elseif statKey == metricKeys.energyIncome then - result = select(4, Spring.GetTeamResources(teamID, "energy")) or 0 + result = select(4, SpringShared.GetTeamResources(teamID, "energy")) or 0 elseif statKey == metricKeys.buildPower then result = cachedTotals[teamID].buildPower elseif statKey == metricKeys.metalProduced then --local metalUsed, metalProduced, metalExcessed, metalReceived, metalSent - local _, metalProduced, _, _, _ = Spring.GetTeamResourceStats(teamID, "m") + local _, metalProduced, _, _, _ = SpringShared.GetTeamResourceStats(teamID, "m") result = metalProduced elseif statKey == metricKeys.energyProduced then - local _, energyProduced, _, _, _ = Spring.GetTeamResourceStats(teamID, "e") + local _, energyProduced, _, _, _ = SpringShared.GetTeamResourceStats(teamID, "e") result = energyProduced elseif statKey == metricKeys.metalExcess then - local _, _, metalExcess, _, _ = Spring.GetTeamResourceStats(teamID, "m") + local _, _, metalExcess, _, _ = SpringShared.GetTeamResourceStats(teamID, "m") result = metalExcess elseif statKey == metricKeys.energyExcess then - local _, _, energyExcess, _, _ = Spring.GetTeamResourceStats(teamID, "e") + local _, _, energyExcess, _, _ = SpringShared.GetTeamResourceStats(teamID, "e") result = energyExcess elseif statKey == metricKeys.armyValue then result = cachedTotals[teamID].armyUnits @@ -922,24 +922,24 @@ local function getOneStat(statKey, teamID) elseif statKey == metricKeys.economyValue then result = cachedTotals[teamID].economyBuildings elseif statKey == metricKeys.damageDealt then - local historyMax = Spring.GetTeamStatsHistory(teamID) - local statsHistory = Spring.GetTeamStatsHistory(teamID, historyMax) + local historyMax = SpringShared.GetTeamStatsHistory(teamID) + local statsHistory = SpringShared.GetTeamStatsHistory(teamID, historyMax) local damageDealt = 0 if statsHistory and #statsHistory > 0 then damageDealt = statsHistory[1].damageDealt end result = damageDealt elseif statKey == metricKeys.damageReceived then - local historyMax = Spring.GetTeamStatsHistory(teamID) - local statsHistory = Spring.GetTeamStatsHistory(teamID, historyMax) + local historyMax = SpringShared.GetTeamStatsHistory(teamID) + local statsHistory = SpringShared.GetTeamStatsHistory(teamID, historyMax) local damageReceived = 0 if statsHistory and #statsHistory > 0 then damageReceived = statsHistory[1].damageReceived end result = damageReceived elseif statKey == metricKeys.damageEfficiency then - local historyMax = Spring.GetTeamStatsHistory(teamID) - local statsHistory = Spring.GetTeamStatsHistory(teamID, historyMax) + local historyMax = SpringShared.GetTeamStatsHistory(teamID) + local statsHistory = SpringShared.GetTeamStatsHistory(teamID, historyMax) local damageDealt = 0 local damageReceived = 0 if statsHistory and #statsHistory > 0 then @@ -1083,7 +1083,7 @@ local function drawBars() local indexLeft = teamOrder and teamOrder[1] or 1 local indexRight = teamOrder and teamOrder[2] or 2 - local mouseX, mouseY = Spring.GetMouseState() + local mouseX, mouseY = SpringUnsynced.GetMouseState() local mouseOnBar = false if (mouseX > barDimensions.left) and (mouseX < barDimensions.right) and (mouseY > widgetDimensions.bottom) and (mouseY < widgetDimensions.top) then mouseOnBar = true @@ -1641,7 +1641,7 @@ end local function init() font = WG["fonts"].getFont() - viewScreenWidth, viewScreenHeight = Spring.GetViewGeometry() + viewScreenWidth, viewScreenHeight = SpringUnsynced.GetViewGeometry() buildMetricsEnabled() @@ -1794,7 +1794,7 @@ function widget:UnitGiven(unitID, unitDefID, newTeam, oldTeam) end -- only track units that have been completely built - if Spring.GetUnitIsBeingBuilt(unitID) then + if SpringShared.GetUnitIsBeingBuilt(unitID) then return end @@ -1813,7 +1813,7 @@ function widget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerD end -- unit might've been a nanoframe - if Spring.GetUnitIsBeingBuilt(unitID) then + if SpringShared.GetUnitIsBeingBuilt(unitID) then return end @@ -1846,12 +1846,12 @@ function widget:GameFrame(frameNum) if (frameNum > 0) and not teamOrder then -- collect player start positions local teamStartAverages = {} - for _, allyID in ipairs(Spring.GetAllyTeamList()) do + for _, allyID in ipairs(SpringShared.GetAllyTeamList()) do if allyID ~= gaiaAllyID then local accumulator = { x = 0, z = 0 } - local teamList = Spring.GetTeamList(allyID) + local teamList = SpringShared.GetTeamList(allyID) for _, teamID in ipairs(teamList) do - local x, _, z = Spring.GetTeamStartPosition(teamID) + local x, _, z = SpringShared.GetTeamStartPosition(teamID) accumulator.x = accumulator.x + x accumulator.z = accumulator.z + z end @@ -1860,7 +1860,7 @@ function widget:GameFrame(frameNum) end end - local _, rotY, _ = Spring.GetCameraRotation() + local _, rotY, _ = SpringUnsynced.GetCameraRotation() -- sort averages and create team order (from left to right) table.sort(teamStartAverages, function(left, right) diff --git a/luaui/Widgets/gui_team_platter.lua b/luaui/Widgets/gui_team_platter.lua index a33e51821be..3e9f583cb14 100644 --- a/luaui/Widgets/gui_team_platter.lua +++ b/luaui/Widgets/gui_team_platter.lua @@ -43,10 +43,10 @@ local GL_POINTS = GL.POINTS local hasBadCulling = ((Platform.gpuVendor == "AMD" and Platform.osFamily == "Linux") == true) -local spGetUnitTeam = Spring.GetUnitTeam +local spGetUnitTeam = SpringShared.GetUnitTeam local myTeamID = Spring.GetMyTeamID() -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() local unitScale = {} local unitCanFly = {} @@ -70,7 +70,7 @@ end local function AddPrimitiveAtUnit(unitID, unitDefID, unitTeamID, noUpload) if (not skipOwnTeam or unitTeamID ~= myTeamID) and unitTeamID ~= gaiaTeamID and not unitDecoration[unitDefID] then - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() local numVertices = 64 -- default to circle local cornersize = 0 @@ -125,7 +125,7 @@ end local drawFrame = 0 function widget:DrawWorldPreUnit() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end drawFrame = drawFrame + 1 diff --git a/luaui/Widgets/gui_teamstats.lua b/luaui/Widgets/gui_teamstats.lua index e087487a7b0..e933aac49f7 100644 --- a/luaui/Widgets/gui_teamstats.lua +++ b/luaui/Widgets/gui_teamstats.lua @@ -19,9 +19,9 @@ local mathMax = math.max local mathMin = math.min -- Localized Spring API for performance -local spGetMouseState = Spring.GetMouseState -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local vsx, vsy = spGetViewGeometry() @@ -87,21 +87,21 @@ local guiData = { } guiData.mainPanel.relSizes.x.length = (guiData.mainPanel.relSizes.x.max - guiData.mainPanel.relSizes.x.min) * 0.92 -local ui_opacity = Spring.GetConfigFloat("ui_opacity", 0.7) +local ui_opacity = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7) local glColor = gl.Color local glCreateList = gl.CreateList local glCallList = gl.CallList local glDeleteList = gl.DeleteList -local GetGaiaTeamID = Spring.GetGaiaTeamID -local GetAllyTeamList = Spring.GetAllyTeamList -local GetTeamList = Spring.GetTeamList -local GetTeamStatsHistory = Spring.GetTeamStatsHistory -local GetTeamInfo = Spring.GetTeamInfo -local GetPlayerInfo = Spring.GetPlayerInfo +local GetGaiaTeamID = SpringShared.GetGaiaTeamID +local GetAllyTeamList = SpringShared.GetAllyTeamList +local GetTeamList = SpringShared.GetTeamList +local GetTeamStatsHistory = SpringShared.GetTeamStatsHistory +local GetTeamInfo = SpringShared.GetTeamInfo +local GetPlayerInfo = SpringShared.GetPlayerInfo local GetMouseState = spGetMouseState -local GetGameFrame = Spring.GetGameFrame +local GetGameFrame = SpringShared.GetGameFrame local min = mathMin local max = mathMax local clamp = math.clamp @@ -117,12 +117,12 @@ local RectRound, UiElement, elementCorner local font, font2, backgroundGuishader, gameStarted, bgpadding, gameover -local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode -local anonymousTeamColor = { Spring.GetConfigInt("anonymousColorR", 255) / 255, Spring.GetConfigInt("anonymousColorG", 0) / 255, Spring.GetConfigInt("anonymousColorB", 0) / 255 } +local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode +local anonymousTeamColor = { SpringUnsynced.GetConfigInt("anonymousColorR", 255) / 255, SpringUnsynced.GetConfigInt("anonymousColorG", 0) / 255, SpringUnsynced.GetConfigInt("anonymousColorB", 0) / 255 } local isSpec = spGetSpectatingState() -local playerScale = math.clamp(25 / #Spring.GetTeamList(), 0.3, 1) +local playerScale = math.clamp(25 / #SpringShared.GetTeamList(), 0.3, 1) function aboveRectangle(mousePos, boxData) local included = true @@ -252,7 +252,7 @@ function widget:Initialize() refreshHeaders() guiData.mainPanel.visible = false widget:ViewResize() - local _, _, paused = Spring.GetGameSpeed() + local _, _, paused = SpringUnsynced.GetGameSpeed() if paused then widget:GameFrame(GetGameFrame(), true) end @@ -343,16 +343,16 @@ function widget:GameFrame(n, forceupdate) end history.time = nil local teamColor - if not isSpec and anonymousMode ~= "disabled" and teamID ~= Spring.GetLocalTeamID() then + if not isSpec and anonymousMode ~= "disabled" and teamID ~= SpringUnsynced.GetLocalTeamID() then teamColor = { anonymousTeamColor[1], anonymousTeamColor[2], anonymousTeamColor[3] } else - teamColor = { Spring.GetTeamColor(teamID) } + teamColor = { SpringUnsynced.GetTeamColor(teamID) } end local _, leader, isDead = GetTeamInfo(teamID, false) local playerName, isActive = GetPlayerInfo(leader, false) playerName = (WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(leader) or playerName - if Spring.GetGameRulesParam("ainame_" .. teamID) then - playerName = Spring.GetGameRulesParam("ainame_" .. teamID) + if SpringShared.GetGameRulesParam("ainame_" .. teamID) then + playerName = SpringShared.GetGameRulesParam("ainame_" .. teamID) end if gameStarted ~= nil then if not playerName then @@ -439,7 +439,7 @@ function widget:GameOver() if replaceEndStats then guiData.mainPanel.visible = true widget:GameFrame(GetGameFrame(), true) - Spring.SendCommands("endgraph 0") + SpringUnsynced.SendCommands("endgraph 0") end end @@ -473,7 +473,7 @@ function mouseEvent(mx, my, button, release) local newSort = header[column] if newSort then if playSounds then - Spring.PlaySoundFile(buttonclick, 0.6, "ui") + SpringUnsynced.PlaySoundFile(buttonclick, 0.6, "ui") end if sortVar == newSort then sortAscending = not sortAscending @@ -574,7 +574,7 @@ function widget:DrawScreen() local mx, my = spGetMouseState() local x1, y1, x2, y2 = mathFloor(guiData.mainPanel.absSizes.x.min), mathFloor(guiData.mainPanel.absSizes.y.min), mathFloor(guiData.mainPanel.absSizes.x.max), mathFloor(guiData.mainPanel.absSizes.y.max) if math_isInRect(mx, my, x1, y1, x2, y2) then - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") end end diff --git a/luaui/Widgets/gui_tooltip.lua b/luaui/Widgets/gui_tooltip.lua index e9a30c7a2c9..86c0ca48cc7 100644 --- a/luaui/Widgets/gui_tooltip.lua +++ b/luaui/Widgets/gui_tooltip.lua @@ -18,7 +18,7 @@ local mathFloor = math.floor local mathMax = math.max -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry +local spGetViewGeometry = SpringUnsynced.GetViewGeometry -- Localized gl functions for performance local glPushMatrix = gl.PushMatrix @@ -52,13 +52,13 @@ local vsx, vsy = spGetViewGeometry() local widgetScale = 1 local usedFontSize = cfgFontSize -local spGetMouseState = Spring.GetMouseState +local spGetMouseState = SpringUnsynced.GetMouseState local math_floor = mathFloor local math_ceil = mathCeil local math_isInRect = math.isInRect local string_lines = string.lines -local ui_scale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local ui_scale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) local tooltips = {} local cleanupGuishaderAreas = {} local font, font2 diff --git a/luaui/Widgets/gui_top_bar.lua b/luaui/Widgets/gui_top_bar.lua index f96d42ac8af..c6c50dcaa7d 100644 --- a/luaui/Widgets/gui_top_bar.lua +++ b/luaui/Widgets/gui_top_bar.lua @@ -27,18 +27,18 @@ local stringFormat = string.format -- Localized Spring API as table (avoids global lookups, saves local slots) local sp = { - GetGameFrame = Spring.GetGameFrame, - GetTeamRulesParam = Spring.GetTeamRulesParam, - GetTeamList = Spring.GetTeamList, - SetMouseCursor = Spring.SetMouseCursor, + GetGameFrame = SpringShared.GetGameFrame, + GetTeamRulesParam = SpringShared.GetTeamRulesParam, + GetTeamList = SpringShared.GetTeamList, + SetMouseCursor = SpringUnsynced.SetMouseCursor, GetMyAllyTeamID = Spring.GetMyAllyTeamID, - GetTeamUnitDefCount = Spring.GetTeamUnitDefCount, - GetSpectatingState = Spring.GetSpectatingState, - GetTeamResources = Spring.GetTeamResources, + GetTeamUnitDefCount = SpringShared.GetTeamUnitDefCount, + GetSpectatingState = SpringUnsynced.GetSpectatingState, + GetTeamResources = SpringShared.GetTeamResources, GetMyTeamID = Spring.GetMyTeamID, - GetMouseState = Spring.GetMouseState, - GetWind = Spring.GetWind, - GetGameSpeed = Spring.GetGameSpeed, + GetMouseState = SpringUnsynced.GetMouseState, + GetWind = SpringShared.GetWind, + GetGameSpeed = SpringUnsynced.GetGameSpeed, } -- Configuration (consolidated into table to save local slots) @@ -53,7 +53,7 @@ local cfg = { -- System local guishaderEnabled = false -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() local spec = sp.GetSpectatingState() local myAllyTeamID = sp.GetMyAllyTeamID() local myTeamID = sp.GetMyTeamID() @@ -86,7 +86,7 @@ local isMetalmap = false local avgWindValue, riskWindValue local currentWind = 0 local displayTidalSpeed = not Spring.Lava.isLavaMap -local tidalSpeed = Spring.GetTidal() -- for now assumed that it is not dynamically changed +local tidalSpeed = SpringShared.GetTidal() -- for now assumed that it is not dynamically changed local tidalWaveAnimationHeight = 10 local windRotation = 0 local minWind = Game.windMin @@ -141,10 +141,10 @@ local buttonsArea = {} -- UI State local orgHeight = 46 -local ui_scale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) -local ui_opacity = Spring.GetConfigFloat("ui_opacity", 0.7) +local ui_scale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) +local ui_opacity = SpringUnsynced.GetConfigFloat("ui_opacity", 0.7) local height = orgHeight * (1 + (ui_scale - 1) / 1.7) -local vsx, vsy = Spring.GetViewGeometry() +local vsx, vsy = SpringUnsynced.GetViewGeometry() local mx = -1 local my = -1 local widgetScale = (0.80 + (vsx * vsy / 6000000)) @@ -231,7 +231,7 @@ local function getPlayerLiveAllyCount() local nAllies = 0 for _, teamID in ipairs(myAllyTeamList) do if teamID ~= myTeamID then - local _, _, isDead, hasAI = Spring.GetTeamInfo(teamID, false) + local _, _, isDead, hasAI = SpringShared.GetTeamInfo(teamID, false) if not isDead and not hasAI then nAllies = nAllies + 1 end @@ -498,18 +498,18 @@ local function checkTidalRelevant() local mapMinHeight = 0 -- account for invertmap to the best of our abiltiy - if string.find(Spring.GetModOptions().debugcommands, "invertmap") then - if string.find(Spring.GetModOptions().debugcommands, "wet") then + if string.find(SpringShared.GetModOptions().debugcommands, "invertmap") then + if string.find(SpringShared.GetModOptions().debugcommands, "wet") then -- assume that they want water if keyword "wet" is involved, too violitile between initilization and subsequent post terraform checks return true --else -- mapMinHeight = 0 end else - mapMinHeight = select(3, Spring.GetGroundExtremes()) + mapMinHeight = select(3, SpringShared.GetGroundExtremes()) end - mapMinHeight = mapMinHeight - (Spring.GetModOptions().map_waterlevel or 0) + mapMinHeight = mapMinHeight - (SpringShared.GetModOptions().map_waterlevel or 0) return mapMinHeight <= -20 -- armtide/cortide can be built from 20 waterdepth (hardcoded here cause am too lazy to auto cycle trhough unitdefs and read it from there) end @@ -832,7 +832,7 @@ local function updateResbar(res) dlist.resbar[res][2] = glCreateList(function() -- Metalmaker Conversion slider if res == "energy" then - mmLevel = Spring.GetTeamRulesParam(myTeamID, "mmLevel") + mmLevel = SpringShared.GetTeamRulesParam(myTeamID, "mmLevel") local convValue = mmLevel if draggingConversionIndicatorValue then convValue = draggingConversionIndicatorValue / 100 @@ -1536,7 +1536,7 @@ local function drawQuitScreen() fadeProgress = 1 end - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") dlist.quit = glCreateList(function() if WG["guishader"] then @@ -1938,7 +1938,7 @@ local function adjustSliders(x, y) if shareValue > 1 then shareValue = 1 end - Spring.SetShareLevel(draggingShareIndicator, shareValue) + SpringUnsynced.SetShareLevel(draggingShareIndicator, shareValue) draggingShareIndicatorValue[draggingShareIndicator] = shareValue updateResbar(draggingShareIndicator) end @@ -1951,7 +1951,7 @@ local function adjustSliders(x, y) if convValue > 88 then convValue = 88 end - Spring.SendLuaRulesMsg(stringFormat(string.char(137) .. "%i", convValue)) + SpringUnsynced.SendLuaRulesMsg(stringFormat(string.char(137) .. "%i", convValue)) draggingConversionIndicatorValue = convValue updateResbar("energy") end @@ -1990,7 +1990,7 @@ local function hideWindows() if gameIsOver then -- Graphs window can only be open after game end -- Closing Graphs window if open, no way to tell if it was open or not - Spring.SendCommands("endgraph 0") + SpringUnsynced.SendCommands("endgraph 0") graphsWindowVisible = false end @@ -2011,13 +2011,13 @@ end local function applyButtonAction(button) if playSounds then - Spring.PlaySoundFile(leftclick, 0.8, "ui") + SpringUnsynced.PlaySoundFile(leftclick, 0.8, "ui") end local isvisible = false if button == "quit" or button == "resign" then if not gameIsOver and chobbyLoaded and button == "quit" then - Spring.SendLuaMenuMsg("showLobby") + SpringUnsynced.SendLuaMenuMsg("showLobby") else local oldShowQuitscreen if showQuitscreen then @@ -2043,7 +2043,7 @@ local function applyButtonAction(button) elseif button == "save" then if isSinglePlayer and cfg.allowSavegame and WG["savegame"] then local time = os.date("%Y%m%d_%H%M%S") - Spring.SendCommands("savegame " .. time) + SpringUnsynced.SendCommands("savegame " .. time) end elseif button == "scavengers" then toggleWindow("scavengerinfo") @@ -2057,7 +2057,7 @@ local function applyButtonAction(button) isvisible = graphsWindowVisible hideWindows() if gameIsOver and not isvisible then - Spring.SendCommands("endgraph 2") + SpringUnsynced.SendCommands("endgraph 2") graphsWindowVisible = true end end @@ -2095,7 +2095,7 @@ function widget:MousePress(x, y, button) if mathIsInRect(x, y, quitscreenArea[1], quitscreenArea[2], quitscreenArea[3], quitscreenArea[4]) then if (gameIsOver or not chobbyLoaded or not spec) and mathIsInRect(x, y, quitscreenStayArea[1], quitscreenStayArea[2], quitscreenStayArea[3], quitscreenStayArea[4]) then if playSounds then - Spring.PlaySoundFile(leftclick, 0.75, "ui") + SpringUnsynced.PlaySoundFile(leftclick, 0.75, "ui") end showQuitscreen = nil @@ -2105,13 +2105,13 @@ function widget:MousePress(x, y, button) end if (gameIsOver or not chobbyLoaded) and mathIsInRect(x, y, quitscreenQuitArea[1], quitscreenQuitArea[2], quitscreenQuitArea[3], quitscreenQuitArea[4]) then if playSounds then - Spring.PlaySoundFile(leftclick, 0.75, "ui") + SpringUnsynced.PlaySoundFile(leftclick, 0.75, "ui") end if not chobbyLoaded then - Spring.SendCommands("QuitForce") -- Exit the game completely + SpringUnsynced.SendCommands("QuitForce") -- Exit the game completely else - Spring.SendCommands("ReloadForce") -- Exit to the lobby + SpringUnsynced.SendCommands("ReloadForce") -- Exit to the lobby end showQuitscreen = nil @@ -2119,9 +2119,9 @@ function widget:MousePress(x, y, button) end if not spec and not gameIsOver and mathIsInRect(x, y, quitscreenResignArea[1], quitscreenResignArea[2], quitscreenResignArea[3], quitscreenResignArea[4]) then if playSounds then - Spring.PlaySoundFile(leftclick, 0.75, "ui") + SpringUnsynced.PlaySoundFile(leftclick, 0.75, "ui") end - Spring.SendCommands("spectator") + SpringUnsynced.SendCommands("spectator") showQuitscreen = nil if WG["guishader"] then WG["guishader"].setScreenBlur(false) @@ -2129,9 +2129,9 @@ function widget:MousePress(x, y, button) end if not spec and not gameIsOver and teamResign and mathIsInRect(x, y, quitscreenTeamResignArea[1], quitscreenTeamResignArea[2], quitscreenTeamResignArea[3], quitscreenTeamResignArea[4]) then if playSounds then - Spring.PlaySoundFile(leftclick, 0.75, "ui") + SpringUnsynced.PlaySoundFile(leftclick, 0.75, "ui") end - Spring.SendCommands("say !cv resign") + SpringUnsynced.SendCommands("say !cv resign") showQuitscreen = nil if WG["guishader"] then WG["guishader"].setScreenBlur(false) @@ -2163,7 +2163,7 @@ function widget:MousePress(x, y, button) if draggingShareIndicator or draggingConversionIndicator then if playSounds then - Spring.PlaySoundFile(resourceclick, 0.7, "ui") + SpringUnsynced.PlaySoundFile(resourceclick, 0.7, "ui") end return true end @@ -2208,7 +2208,7 @@ function widget:PlayerChanged() local prevSpec = spec spec = sp.GetSpectatingState() checkSelfStatus() - numTeamsInAllyTeam = #Spring.GetTeamList(myAllyTeamID) + numTeamsInAllyTeam = #SpringShared.GetTeamList(myAllyTeamID) if displayComCounter then countComs(true) end @@ -2227,7 +2227,7 @@ end function widget:UnitCreated(unitID, unitDefID, unitTeam) if isCommander[unitDefID] then - if select(6, Spring.GetTeamInfo(unitTeam, false)) == myAllyTeamID then + if select(6, SpringShared.GetTeamInfo(unitTeam, false)) == myAllyTeamID then allyComs = allyComs + 1 elseif spec then enemyComs = enemyComs + 1 @@ -2238,7 +2238,7 @@ end function widget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam, weaponDefID) if isCommander[unitDefID] then - if select(6, Spring.GetTeamInfo(unitTeam, false)) == myAllyTeamID then + if select(6, SpringShared.GetTeamInfo(unitTeam, false)) == myAllyTeamID then allyComs = allyComs - 1 elseif spec then enemyComs = enemyComs - 1 @@ -2253,22 +2253,22 @@ end function widget:Initialize() gameFrame = sp.GetGameFrame() - Spring.SendCommands("resbar 0") + SpringUnsynced.SendCommands("resbar 0") -- determine if we want to show comcounter - local allteams = Spring.GetTeamList() + local allteams = SpringShared.GetTeamList() local teamN = table.maxn(allteams) - 1 --remove gaia if teamN > 2 then displayComCounter = true end - if UnitDefs[Spring.GetTeamRulesParam(Spring.GetMyTeamID(), "startUnit")] then - textures.com = ":n:Icons/" .. UnitDefs[Spring.GetTeamRulesParam(Spring.GetMyTeamID(), "startUnit")].name .. ".png" + if UnitDefs[SpringShared.GetTeamRulesParam(Spring.GetMyTeamID(), "startUnit")] then + textures.com = ":n:Icons/" .. UnitDefs[SpringShared.GetTeamRulesParam(Spring.GetMyTeamID(), "startUnit")].name .. ".png" end for _, teamID in ipairs(myAllyTeamList) do - if select(4, Spring.GetTeamInfo(teamID, false)) then -- is AI? - local luaAI = Spring.GetTeamLuaAI(teamID) + if select(4, SpringShared.GetTeamInfo(teamID, false)) then -- is AI? + local luaAI = SpringShared.GetTeamLuaAI(teamID) if luaAI and luaAI ~= "" and (string.find(luaAI, "Scavengers") or string.find(luaAI, "Raptors")) then supressOverflowNotifs = true break @@ -2276,13 +2276,13 @@ function widget:Initialize() end end - if Spring.GetMenuName and string.find(string.lower(Spring.GetMenuName()), "chobby") then + if SpringUnsynced.GetMenuName and string.find(string.lower(SpringUnsynced.GetMenuName()), "chobby") then chobbyLoaded = true - Spring.SendLuaMenuMsg("disableLobbyButton") + SpringUnsynced.SendLuaMenuMsg("disableLobbyButton") end if not spec then - local teamList = Spring.GetTeamList(myAllyTeamID) or {} + local teamList = SpringShared.GetTeamList(myAllyTeamID) or {} isSingle = #teamList == 1 end diff --git a/luaui/Widgets/gui_transport_weight_limit.lua b/luaui/Widgets/gui_transport_weight_limit.lua index a3804eefdd9..4b637cd9f19 100644 --- a/luaui/Widgets/gui_transport_weight_limit.lua +++ b/luaui/Widgets/gui_transport_weight_limit.lua @@ -17,9 +17,9 @@ local mathSin = math.sin local mathCos = math.cos -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetSelectedUnitsCount = Spring.GetSelectedUnitsCount +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetSelectedUnitsCount = SpringUnsynced.GetSelectedUnitsCount ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- @@ -123,7 +123,7 @@ function widget:GameFrame(n) return end - if select(2, Spring.GetActiveCommand()) ~= CMD_LOAD_UNITS then + if select(2, SpringUnsynced.GetActiveCommand()) ~= CMD_LOAD_UNITS then if next(unitsToDraw) then unitsToDraw = {} end @@ -136,7 +136,7 @@ function widget:GameFrame(n) local transDefID = spGetUnitDefID(transID) if validTrans[transDefID] then - local transportedUnits = Spring.GetUnitIsTransporting(transID) + local transportedUnits = SpringShared.GetUnitIsTransporting(transID) local transCapacity = transDefs[transDefID][2] if not transportedUnits or #transportedUnits < transCapacity then activeTransportDefs[transDefID] = true @@ -153,14 +153,14 @@ function widget:GameFrame(n) unitsToDraw = {} - local visibleUnits = Spring.GetVisibleUnits() + local visibleUnits = SpringUnsynced.GetVisibleUnits() if not visibleUnits or not next(visibleUnits) then return end for _, unitID in ipairs(visibleUnits) do local passengerDefID = spGetUnitDefID(unitID) - if not cantBeTransported[passengerDefID] and not Spring.IsUnitIcon(unitID) then + if not cantBeTransported[passengerDefID] and not SpringUnsynced.IsUnitIcon(unitID) then local passengerFootprintX = unitXSize[passengerDefID] / springFootprintScale local canBePickedUp = false for transDefID, _ in pairs(activeTransportDefs) do @@ -175,7 +175,7 @@ function widget:GameFrame(n) end if canBePickedUp then - local x, y, z = Spring.GetUnitBasePosition(unitID) + local x, y, z = SpringShared.GetUnitBasePosition(unitID) if x then -- we have to scale up passengerFootprintX otherwise indicator would be under the unit instead of around it unitsToDraw[unitID] = { pos = { x, y, z }, size = (passengerFootprintX * indicatorSizeMultiplier) } @@ -192,8 +192,8 @@ function widget:Update() return end - local mx, my = Spring.GetMouseState() - local _, coords = Spring.TraceScreenRay(mx, my, true) + local mx, my = SpringUnsynced.GetMouseState() + local _, coords = SpringUnsynced.TraceScreenRay(mx, my, true) if type(coords) == "table" then cursorGround = coords diff --git a/luaui/Widgets/gui_turret_trans_range.lua b/luaui/Widgets/gui_turret_trans_range.lua index 911294bea79..b7b9748d0cf 100644 --- a/luaui/Widgets/gui_turret_trans_range.lua +++ b/luaui/Widgets/gui_turret_trans_range.lua @@ -27,8 +27,8 @@ local color --speedups -------------------------------------------------------------------------------- local CMD_UNLOAD_UNITS = CMD.UNLOAD_UNITS -local spGetActiveCmd = Spring.GetActiveCommand -local GetSelectedUnitsSorted = Spring.GetSelectedUnitsSorted +local spGetActiveCmd = SpringUnsynced.GetActiveCommand +local GetSelectedUnitsSorted = SpringUnsynced.GetSelectedUnitsSorted local glColor = gl.Color local glLineWidth = gl.LineWidth local glDrawGroundCircle = gl.DrawGroundCircle @@ -109,8 +109,8 @@ function widget:DrawWorldPreUnit() local turret = isTurret[ranges[1].unitDefID] color = turret and colors.turret or colors.tower --Spring.Echo(transportWithBuilding[unitId]) - local mouseX, mouseY = Spring.GetMouseState() - local desc, args = Spring.TraceScreenRay(mouseX, mouseY, true) + local mouseX, mouseY = SpringUnsynced.GetMouseState() + local desc, args = SpringUnsynced.TraceScreenRay(mouseX, mouseY, true) if desc == nil then return end diff --git a/luaui/Widgets/gui_unit_energy_icons.lua b/luaui/Widgets/gui_unit_energy_icons.lua index 4252a2f918d..9d931f0ba25 100644 --- a/luaui/Widgets/gui_unit_energy_icons.lua +++ b/luaui/Widgets/gui_unit_energy_icons.lua @@ -13,14 +13,14 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame -local spGetUnitTeam = Spring.GetUnitTeam -local spGetSpectatingState = Spring.GetSpectatingState +local spGetGameFrame = SpringShared.GetGameFrame +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local weaponEnergyCostFloor = 6 -local spGetTeamResources = Spring.GetTeamResources -local spGetUnitResources = Spring.GetUnitResources +local spGetTeamResources = SpringShared.GetTeamResources +local spGetUnitResources = SpringShared.GetUnitResources local spGetUnitTeam = spGetUnitTeam local teamEnergy = {} -- table of teamid to current energy amount @@ -141,9 +141,9 @@ function widget:VisibleUnitsChanged(extVisibleUnits, extNumVisibleUnits) fullview = select(2, spGetSpectatingState()) end if not fullview then - teamList = Spring.GetTeamList(Spring.GetMyAllyTeamID()) + teamList = SpringShared.GetTeamList(Spring.GetMyAllyTeamID()) else - teamList = Spring.GetTeamList() + teamList = SpringShared.GetTeamList() end UpdateTeamEnergy() @@ -185,8 +185,8 @@ local function updateStalling() and (not unitConf[unitDefID][4] or ((unitConf[unitDefID][4] and (unitEnergy or 999999)) < unitConf[unitDefID][3])) then - if not Spring.GetUnitIsBeingBuilt(unitID) and energyIconVBO.instanceIDtoIndex[unitID] == nil then -- not already being drawn - if Spring.ValidUnitID(unitID) and not Spring.GetUnitIsDead(unitID) then + if not SpringShared.GetUnitIsBeingBuilt(unitID) and energyIconVBO.instanceIDtoIndex[unitID] == nil then -- not already being drawn + if SpringShared.ValidUnitID(unitID) and not SpringShared.GetUnitIsDead(unitID) then pushElementInstance( energyIconVBO, -- push into this Instance VBO Table { @@ -234,7 +234,7 @@ function widget:GameFrame(n) end function widget:VisibleUnitAdded(unitID, unitDefID, unitTeam) -- remove the corresponding ground plate if it exists - if unitConf[unitDefID] and not Spring.GetUnitIsBeingBuilt(unitID) then + if unitConf[unitDefID] and not SpringShared.GetUnitIsBeingBuilt(unitID) then if teamUnits[unitTeam] == nil then teamUnits[unitTeam] = {} end @@ -262,12 +262,12 @@ function widget:DrawWorld() if chobbyInterface then return end - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if energyIconVBO.usedElements > 0 then - local disticon = Spring.GetConfigInt("UnitIconDistance", 200) * 27.5 -- iconLength = unitIconDist * unitIconDist * 750.0f; + local disticon = SpringUnsynced.GetConfigInt("UnitIconDistance", 200) * 27.5 -- iconLength = unitIconDist * unitIconDist * 750.0f; gl.DepthTest(true) gl.DepthMask(false) gl.Texture("LuaUI/Images/energy-red.png") diff --git a/luaui/Widgets/gui_unit_group_number.lua b/luaui/Widgets/gui_unit_group_number.lua index 70678527d3f..07a94821626 100644 --- a/luaui/Widgets/gui_unit_group_number.lua +++ b/luaui/Widgets/gui_unit_group_number.lua @@ -13,14 +13,14 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local hideBelowGameframe = 100 -local GetGroupUnits = Spring.GetGroupUnits -local spValidUnitID = Spring.ValidUnitID -local spGetUnitIsDead = Spring.GetUnitIsDead -local spIsGUIHidden = Spring.IsGUIHidden +local GetGroupUnits = SpringUnsynced.GetGroupUnits +local spValidUnitID = SpringShared.ValidUnitID +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spIsGUIHidden = SpringUnsynced.IsGUIHidden local gameFrame = 0 local maxNumGroups = 9 @@ -127,7 +127,7 @@ end local function AddPrimitiveAtUnit(unitID, noUpload, groupNumber, gf) if spValidUnitID(unitID) ~= true or spGetUnitIsDead(unitID) == true then if debugmode then - Spring.Echo("Warning: Unit Groups GL4 attempted to add an invalid unitID:", unitID) + SpringShared.Echo("Warning: Unit Groups GL4 attempted to add an invalid unitID:", unitID) end return nil end @@ -204,7 +204,7 @@ function widget:Initialize() initGL4() - gameFrame = Spring.GetGameFrame() + gameFrame = SpringShared.GetGameFrame() unitIDtoGroup = {} if gameFrame > 0 then diff --git a/luaui/Widgets/gui_unit_idlebuilder_icons.lua b/luaui/Widgets/gui_unit_idlebuilder_icons.lua index bd53ed6a652..3b3582cc96a 100644 --- a/luaui/Widgets/gui_unit_idlebuilder_icons.lua +++ b/luaui/Widgets/gui_unit_idlebuilder_icons.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local onlyOwnTeam = true @@ -26,14 +26,14 @@ local iconSequenceFrametime = 0.02 -- duration per frame local unitScope = {} -- table of teamid to table of stallable unitID : unitDefID local idleUnitList = {} -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spGetFactoryCommandCount = Spring.GetFactoryCommandCount -local spGetUnitTeam = Spring.GetUnitTeam -local spec = Spring.GetSpectatingState() +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spGetFactoryCommandCount = SpringShared.GetFactoryCommandCount +local spGetUnitTeam = SpringShared.GetUnitTeam +local spec = SpringUnsynced.GetSpectatingState() local myTeamID = Spring.GetMyTeamID() -local spValidUnitID = Spring.ValidUnitID -local spGetUnitIsDead = Spring.GetUnitIsDead -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt +local spValidUnitID = SpringShared.ValidUnitID +local spGetUnitIsDead = SpringShared.GetUnitIsDead +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt local unitConf = {} for unitDefID, unitDef in pairs(UnitDefs) do @@ -185,12 +185,12 @@ function widget:VisibleUnitRemoved(unitID) -- remove the corresponding ground pl end function widget:DrawWorld() - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if iconVBO.usedElements > 0 then - local disticon = Spring.GetConfigInt("UnitIconDistance", 200) * 27.5 -- iconLength = unitIconDist * unitIconDist * 750.0f; + local disticon = SpringUnsynced.GetConfigInt("UnitIconDistance", 200) * 27.5 -- iconLength = unitIconDist * unitIconDist * 750.0f; gl.DepthTest(true) gl.DepthMask(false) local clock = os.clock() * (1 * (iconSequenceFrametime * iconSequenceNum)) -- adjust speed relative to anim frame speed of 0.02sec per frame (59 frames in total) diff --git a/luaui/Widgets/gui_unit_stats.lua b/luaui/Widgets/gui_unit_stats.lua index 67db6a4b076..460d53224a3 100644 --- a/luaui/Widgets/gui_unit_stats.lua +++ b/luaui/Widgets/gui_unit_stats.lua @@ -20,9 +20,9 @@ local mathMax = math.max local tableInsert = table.insert -- Localized Spring API for performance -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetSelectedUnitsCount = Spring.GetSelectedUnitsCount -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetSelectedUnitsCount = SpringUnsynced.GetSelectedUnitsCount +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local texts = {} local damageStats = (VFS.FileExists("LuaUI/Config/BAR_damageStats.lua")) and VFS.Include("LuaUI/Config/BAR_damageStats.lua") @@ -112,7 +112,7 @@ local vsx, vsy = gl.GetViewSizes() local widgetScale = 1 local xOffset = (32 + (fontSize * 0.9)) * widgetScale local yOffset = -((32 - (fontSize * 0.9)) * widgetScale) -local ui_scale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local ui_scale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) ------------------------------------------------------------------------------------ -- Speedups @@ -142,20 +142,20 @@ local char = string.char local glColor = gl.Color local spGetMyTeamID = Spring.GetMyTeamID -local spGetTeamResources = Spring.GetTeamResources -local spGetTeamInfo = Spring.GetTeamInfo -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetTeamColor = Spring.GetTeamColor -local spIsUserWriting = Spring.IsUserWriting -local spGetModKeyState = Spring.GetModKeyState -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay - -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitExperience = Spring.GetUnitExperience -local spGetUnitSensorRadius = Spring.GetUnitSensorRadius -local spGetUnitWeaponState = Spring.GetUnitWeaponState +local spGetTeamResources = SpringShared.GetTeamResources +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetTeamColor = SpringUnsynced.GetTeamColor +local spIsUserWriting = SpringUnsynced.IsUserWriting +local spGetModKeyState = SpringUnsynced.GetModKeyState +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay + +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitExperience = SpringShared.GetUnitExperience +local spGetUnitSensorRadius = SpringShared.GetUnitSensorRadius +local spGetUnitWeaponState = SpringShared.GetUnitWeaponState local uDefs = UnitDefs local wDefs = WeaponDefs @@ -192,13 +192,13 @@ local cachedGuishaderX, cachedGuishaderY = nil, nil local spec = spGetSpectatingState() -local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode +local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode local anonymousName = "?????" local showStats = false -- TODO: Shield damages are overridden in the shields rework (now in main game) -local shieldsRework = not Spring.GetModOptions().experimentalshields:find("bounce") +local shieldsRework = not SpringShared.GetModOptions().experimentalshields:find("bounce") -- TODO: Localize, same as armorTypes -- TODO: Compose this list somewhere and reinclude it here @@ -354,8 +354,8 @@ local function GetTeamName(teamID) local leaderName = spGetPlayerInfo(teamLeader, false) leaderName = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(teamLeader)) or leaderName - if Spring.GetGameRulesParam("ainame_" .. teamID) then - leaderName = Spring.GetGameRulesParam("ainame_" .. teamID) + if SpringShared.GetGameRulesParam("ainame_" .. teamID) then + leaderName = SpringShared.GetGameRulesParam("ainame_" .. teamID) end if not spec and anonymousMode ~= "disabled" then @@ -422,7 +422,7 @@ function widget:Initialize() widgetHandler:AddAction("unit_stats", enableStats, nil, "p") widgetHandler:AddAction("unit_stats", disableStats, nil, "r") - spTraceScreenRay = Spring.TraceScreenRay -- fix for monkey-patching + spTraceScreenRay = SpringUnsynced.TraceScreenRay -- fix for monkey-patching end function widget:Shutdown() @@ -445,7 +445,7 @@ function init() end function widget:ViewResize(n_vsx, n_vsy) - vsx, vsy = Spring.GetViewGeometry() + vsx, vsy = SpringUnsynced.GetViewGeometry() widgetScale = (1 + ((vsy - 850) / 1800)) * (0.95 + (ui_scale - 1) / 2.5) bgpadding = WG.FlowUI.elementPadding @@ -494,8 +494,8 @@ local function computeContent(uDefID, uID, shiftBool) local isBuilding, buildProg, uExp if uID then - isBuilding, buildProg = Spring.GetUnitIsBeingBuilt(uID) - maxHP = select(2, Spring.GetUnitHealth(uID)) + isBuilding, buildProg = SpringShared.GetUnitIsBeingBuilt(uID) + maxHP = select(2, SpringShared.GetUnitHealth(uID)) uTeam = spGetUnitTeam(uID) losRadius = spGetUnitSensorRadius(uID, "los") or 0 airLosRadius = spGetUnitSensorRadius(uID, "airLos") or 0 @@ -505,7 +505,7 @@ local function computeContent(uDefID, uID, shiftBool) sonarJammingRadius = spGetUnitSensorRadius(uID, "sonarJammer") or 0 seismicRadius = spGetUnitSensorRadius(uID, "seismic") or 0 uExp = spGetUnitExperience(uID) - armoredMultiple = select(2, Spring.GetUnitArmored(uID)) + armoredMultiple = select(2, SpringShared.GetUnitArmored(uID)) end maxWidth = 0 @@ -565,10 +565,10 @@ local function computeContent(uDefID, uID, shiftBool) DrawText(texts.cost .. ":", format(metalColor .. "%d" .. white .. " / " .. energyColor .. "%d" .. white .. " / " .. buildColor .. "%d", uDef.metalCost, uDef.energyCost, uDef.buildTime)) if not (uDef.isBuilding or uDef.isFactory) then - if not uID or not Spring.GetUnitMoveTypeData(uID) then + if not uID or not SpringShared.GetUnitMoveTypeData(uID) then DrawText(texts.move .. ":", format("%.1f / %.1f / %.0f (" .. texts.speedaccelturn .. ")", uDef.speed, 900 * uDef.maxAcc, simSpeed * uDef.turnRate * (180 / 32767))) else - local mData = Spring.GetUnitMoveTypeData(uID) + local mData = SpringShared.GetUnitMoveTypeData(uID) local mSpeed = mData.maxSpeed or uDef.speed local mAccel = mData.accRate or uDef.maxAcc local mTurnRate = mData.baseTurnRate or uDef.turnRate @@ -908,7 +908,7 @@ local function computeContent(uDefID, uID, shiftBool) -- Cache dynamic data for future dirty checks if uID then - cachedBuildProg = select(2, Spring.GetUnitIsBeingBuilt(uID)) + cachedBuildProg = select(2, SpringShared.GetUnitIsBeingBuilt(uID)) cachedExp = spGetUnitExperience(uID) else cachedBuildProg = nil @@ -932,12 +932,12 @@ local function drawStats(uDefID, uID) end -- Dirty check for content caching - local gameFrame = Spring.GetGameFrame() + local gameFrame = SpringShared.GetGameFrame() local shiftBool = (shift ~= false) local contentDirty = (uDefID ~= cachedDefID) or (uID ~= cachedUnitID) or (shiftBool ~= cachedShift) if not contentDirty and uID and (gameFrame - lastComputeFrame >= COMPUTE_INTERVAL) then - local _, bp = Spring.GetUnitIsBeingBuilt(uID) + local _, bp = SpringShared.GetUnitIsBeingBuilt(uID) if bp ~= cachedBuildProg then contentDirty = true elseif spGetUnitExperience(uID) ~= cachedExp then @@ -1043,7 +1043,7 @@ function widget:DrawScreen() showUnitID = nil end local useHoverID = false - local _, activeID = Spring.GetActiveCommand() + local _, activeID = SpringUnsynced.GetActiveCommand() if not activeID then activeID = 0 end @@ -1057,7 +1057,7 @@ function widget:DrawScreen() uID = nil useHoverID = false end - if uID and not Spring.ValidUnitID(uID) then + if uID and not SpringShared.ValidUnitID(uID) then RemoveGuishader() return end diff --git a/luaui/Widgets/gui_unit_wait_icons.lua b/luaui/Widgets/gui_unit_wait_icons.lua index 909f3f5ebec..905dcecf789 100644 --- a/luaui/Widgets/gui_unit_wait_icons.lua +++ b/luaui/Widgets/gui_unit_wait_icons.lua @@ -22,16 +22,16 @@ local waitingUnits = {} local needsCheck = {} -- unitID → {frame = n+5, defID = …, team = …} local checkDelay = 5 local unitsPerFrame = 300 -local gf = Spring.GetGameFrame() +local gf = SpringShared.GetGameFrame() -local spGetUnitCommands = Spring.GetUnitCommands -local spGetFactoryCommands = Spring.GetFactoryCommands -local spec = Spring.GetSpectatingState() +local spGetUnitCommands = SpringShared.GetUnitCommands +local spGetFactoryCommands = SpringShared.GetFactoryCommands +local spec = SpringUnsynced.GetSpectatingState() local myTeamID = Spring.GetMyTeamID() -local spValidUnitID = Spring.ValidUnitID +local spValidUnitID = SpringShared.ValidUnitID -local spIsGUIHidden = Spring.IsGUIHidden -local spGetConfigInt = Spring.GetConfigInt +local spIsGUIHidden = SpringUnsynced.IsGUIHidden +local spGetConfigInt = SpringUnsynced.GetConfigInt local unitConf = {} for udid, unitDef in pairs(UnitDefs) do @@ -174,8 +174,8 @@ end function initUnits() waitingUnits = {} -- forget any previous “waiting” flags local unitDefID - for _, unitID in pairs(Spring.GetTeamUnits(myTeamID)) do - unitDefID = Spring.GetUnitDefID(unitID) + for _, unitID in pairs(SpringShared.GetTeamUnits(myTeamID)) do + unitDefID = SpringShared.GetUnitDefID(unitID) needsCheck[unitID] = { frame = gf + checkDelay, defID = unitDefID, diff --git a/luaui/Widgets/gui_unitgroups.lua b/luaui/Widgets/gui_unitgroups.lua index a1c5707e6d8..5858e49d4d8 100644 --- a/luaui/Widgets/gui_unitgroups.lua +++ b/luaui/Widgets/gui_unitgroups.lua @@ -17,8 +17,8 @@ local mathFloor = math.floor local mathMax = math.max -- Localized Spring API for performance -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local alwaysShow = true -- always show AT LEAST the label local alwaysShowLabel = true -- always show the label regardless @@ -39,10 +39,10 @@ local spec = spGetSpectatingState() local widgetSpaceMargin, backgroundPadding, elementCorner, RectRound, UiElement, UiUnit -local spGetGroupList = Spring.GetGroupList -local spGetGroupUnitsCounts = Spring.GetGroupUnitsCounts -local spGetGroupUnitsCount = Spring.GetGroupUnitsCount -local spGetMouseState = Spring.GetMouseState +local spGetGroupList = SpringUnsynced.GetGroupList +local spGetGroupUnitsCounts = SpringUnsynced.GetGroupUnitsCounts +local spGetGroupUnitsCount = SpringUnsynced.GetGroupUnitsCount +local spGetMouseState = SpringUnsynced.GetMouseState local floor = mathFloor local ceil = math.ceil local min = math.min @@ -53,7 +53,7 @@ local GL_SRC_ALPHA = GL.SRC_ALPHA local GL_ONE = GL.ONE local GL_ONE_MINUS_SRC_ALPHA = GL.ONE_MINUS_SRC_ALPHA -local uiScale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local uiScale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) local height = setHeight * uiScale local posX = 0 local posY = 0 @@ -64,7 +64,7 @@ local usedHeight = 0 local uiTexWidth = 1 local hovered = false local numGroups = 0 -local selectedUnits = Spring.GetSelectedUnits() or {} +local selectedUnits = SpringUnsynced.GetSelectedUnits() or {} local selectionHasChanged = true local selectedGroups = {} local doUpdate = true @@ -135,7 +135,7 @@ end function widget:PlayerChanged(playerID) spec = spGetSpectatingState() - if not showWhenSpec and Spring.GetGameFrame() > 1 and spec then + if not showWhenSpec and SpringShared.GetGameFrame() > 1 and spec then widgetHandler:RemoveWidget() return end @@ -514,7 +514,7 @@ function widget:Update(dt) if WG["tooltip"] then WG["tooltip"].ShowTooltip("unitgroups", tooltipAddition, nil, nil, Spring.I18N("ui.unitGroups.name")) end - Spring.SetMouseCursor("cursornormal") + SpringUnsynced.SetMouseCursor("cursornormal") if b then sec = sec + 0.4 end @@ -539,7 +539,7 @@ function widget:Update(dt) local groupUnitSelectedCount = {} for group, _ in pairs(existingGroups) do groupUnitSelectedCount[group] = 0 - local groupUnits = Spring.GetGroupUnits(group) + local groupUnits = SpringUnsynced.GetGroupUnits(group) groupUnitCount[group] = #groupUnits for i = 1, #groupUnits do if selectedUnitID[groupUnits[i]] then @@ -603,27 +603,27 @@ function widget:Update(dt) end function widget:MousePress(x, y, button) - if Spring.IsGUIHidden() then + if SpringUnsynced.IsGUIHidden() then return end if backgroundRect and math_isInRect(x, y, backgroundRect[1], backgroundRect[2], backgroundRect[3], backgroundRect[4]) then - local alt, ctrl, meta, shift = Spring.GetModKeyState() + local alt, ctrl, meta, shift = SpringUnsynced.GetModKeyState() if button == 1 or button == 3 then for i, v in pairs(groupButtons) do if math_isInRect(x, y, groupButtons[i][1], groupButtons[i][2], groupButtons[i][3], groupButtons[i][4]) then if shift then local units = selectedUnits - local groupUnits = Spring.GetGroupUnits(groupButtons[i][5]) + local groupUnits = SpringUnsynced.GetGroupUnits(groupButtons[i][5]) for i = 1, #groupUnits do units[#units + 1] = groupUnits[i] end selectedUnits = units selectionHasChanged = true - Spring.SelectUnitArray(units) + SpringUnsynced.SelectUnitArray(units) elseif ctrl then local units = selectedUnits - local groupUnits = Spring.GetGroupUnits(groupButtons[i][5]) + local groupUnits = SpringUnsynced.GetGroupUnits(groupButtons[i][5]) local keyGroupUnits = {} for i = 1, #groupUnits do keyGroupUnits[groupUnits[i]] = true @@ -636,17 +636,17 @@ function widget:MousePress(x, y, button) end selectedUnits = newUnits selectionHasChanged = true - Spring.SelectUnitArray(selectedUnits) + SpringUnsynced.SelectUnitArray(selectedUnits) else - selectedUnits = Spring.GetGroupUnits(groupButtons[i][5]) + selectedUnits = SpringUnsynced.GetGroupUnits(groupButtons[i][5]) selectionHasChanged = true - Spring.SelectUnitArray(selectedUnits) + SpringUnsynced.SelectUnitArray(selectedUnits) end if button == 3 then - Spring.SendCommands("viewselection") + SpringUnsynced.SendCommands("viewselection") end if playSounds then - Spring.PlaySoundFile((button == 3 and rightclick or leftclick), soundVolume, "ui") + SpringUnsynced.PlaySoundFile((button == 3 and rightclick or leftclick), soundVolume, "ui") end return true end diff --git a/luaui/Widgets/gui_vote_interface.lua b/luaui/Widgets/gui_vote_interface.lua index d8c29aab565..069a26509ac 100644 --- a/luaui/Widgets/gui_vote_interface.lua +++ b/luaui/Widgets/gui_vote_interface.lua @@ -17,8 +17,8 @@ local mathFloor = math.floor local mathMax = math.max -- Localized Spring API for performance -local spGetMouseState = Spring.GetMouseState -local spGetViewGeometry = Spring.GetViewGeometry +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry local L_DEPRECATED = LOG.DEPRECATED @@ -35,12 +35,12 @@ local voteTimeout = 75 -- fallback timeout in case vote is aborted undetected local vsx, vsy = spGetViewGeometry() -local ui_scale = tonumber(Spring.GetConfigFloat("ui_scale", 1) or 1) +local ui_scale = tonumber(SpringUnsynced.GetConfigFloat("ui_scale", 1) or 1) local myPlayerID = Spring.GetMyPlayerID() -local myPlayerName, _, mySpec, myTeamID, myAllyTeamID = Spring.GetPlayerInfo(myPlayerID, false) +local myPlayerName, _, mySpec, myTeamID, myAllyTeamID = SpringShared.GetPlayerInfo(myPlayerID, false) -local isreplay = Spring.IsReplay() +local isreplay = SpringUnsynced.IsReplay() local ColorString = Spring.Utilities.Color.ToString local math_isInRect = math.isInRect @@ -62,9 +62,9 @@ local minimized = false local voteStartTime local function isTeamPlayer(playerName) - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() for _, pID in ipairs(players) do - local name, _, _, _, allyTeamID = Spring.GetPlayerInfo(pID, false) + local name, _, _, _, allyTeamID = SpringShared.GetPlayerInfo(pID, false) if name == playerName then if allyTeamID == myAllyTeamID then return true @@ -309,8 +309,8 @@ function widget:ViewResize() end function widget:PlayerChanged(playerID) - mySpec = Spring.GetSpectatingState() - myPlayerName, _, mySpec, myTeamID, myAllyTeamID = Spring.GetPlayerInfo(myPlayerID, false) + mySpec = SpringUnsynced.GetSpectatingState() + myPlayerName, _, mySpec, myTeamID, myAllyTeamID = SpringShared.GetPlayerInfo(myPlayerID, false) end local debug = false @@ -367,13 +367,13 @@ function widget:GameFrame(n) if n > 0 and not gameStarted then gameStarted = true myPlayerID = Spring.GetMyPlayerID() - myPlayerName, _, mySpec, myTeamID, myAllyTeamID = Spring.GetPlayerInfo(myPlayerID, false) + myPlayerName, _, mySpec, myTeamID, myAllyTeamID = SpringShared.GetPlayerInfo(myPlayerID, false) end widgetHandler:RemoveCallIn("GameFrame") end local function colourNames(teamID) - local nameColourR, nameColourG, nameColourB, nameColourA = Spring.GetTeamColor(teamID) + local nameColourR, nameColourG, nameColourB, nameColourA = SpringUnsynced.GetTeamColor(teamID) --if (not mySpecStatus) and anonymousMode ~= "disabled" and teamID ~= myTeamID then -- nameColourR, nameColourG, nameColourB = anonymousTeamColor[1], anonymousTeamColor[2], anonymousTeamColor[3] --end @@ -400,9 +400,9 @@ function widget:AddConsoleLine(lines, priority) -- find who started the vote, and see if we're allied local ownerPlayername = false local alliedWithVoteOwner = false - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() for _, playerID in ipairs(players) do - local playerName, _, spec, teamID, allyTeamID = Spring.GetPlayerInfo(playerID, false) + local playerName, _, spec, teamID, allyTeamID = SpringShared.GetPlayerInfo(playerID, false) if sfind(line, string.gsub(playerName, "%p", "%%%1") .. " called a vote ") then ownerPlayername = playerName if allyTeamID == myAllyTeamID then @@ -442,9 +442,9 @@ function widget:AddConsoleLine(lines, priority) -- colorize playername if isResignVote or isResignVoteMyTeam then - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() for _, pID in ipairs(players) do - local name, _, spec, teamID, allyTeamID = Spring.GetPlayerInfo(pID, false) + local name, _, spec, teamID, allyTeamID = SpringShared.GetPlayerInfo(pID, false) name = ((WG.playernames and WG.playernames.getPlayername) and WG.playernames.getPlayername(pID)) or name local pos = sfind(title, " " .. name .. " ", nil, true) if pos then @@ -548,18 +548,18 @@ function widget:MousePress(x, y, button) if voteDlist and eligibleToVote and not voteEndText and button == 1 then if math_isInRect(x, y, windowArea[1], windowArea[2], windowArea[3], windowArea[4]) then if not weAreVoteOwner and math_isInRect(x, y, yesButtonArea[1], yesButtonArea[2], yesButtonArea[3], yesButtonArea[4]) then - Spring.SendCommands("say !vote y") + SpringUnsynced.SendCommands("say !vote y") MinimizeVote() elseif math_isInRect(x, y, noButtonArea[1], noButtonArea[2], noButtonArea[3], noButtonArea[4]) then if weAreVoteOwner then - Spring.SendCommands("say !endvote") + SpringUnsynced.SendCommands("say !endvote") MinimizeVote() else - Spring.SendCommands("say !vote n") + SpringUnsynced.SendCommands("say !vote n") MinimizeVote() end elseif math_isInRect(x, y, closeButtonArea[1], closeButtonArea[2], closeButtonArea[3], closeButtonArea[4]) then - Spring.SendCommands("say !vote b") + SpringUnsynced.SendCommands("say !vote b") MinimizeVote() end return true diff --git a/luaui/Widgets/log_unitdefids.lua b/luaui/Widgets/log_unitdefids.lua index 7dc3955c561..e0f3c73a2fb 100644 --- a/luaui/Widgets/log_unitdefids.lua +++ b/luaui/Widgets/log_unitdefids.lua @@ -20,5 +20,5 @@ function widget:Initialize() local json = Json.encode(result) - Spring.SendLuaRulesMsg("unitdefs:" .. VFS.ZlibCompress(json)) + SpringUnsynced.SendLuaRulesMsg("unitdefs:" .. VFS.ZlibCompress(json)) end diff --git a/luaui/Widgets/logo_adjuster.lua b/luaui/Widgets/logo_adjuster.lua index 35c455263ba..977da977bb2 100644 --- a/luaui/Widgets/logo_adjuster.lua +++ b/luaui/Widgets/logo_adjuster.lua @@ -13,9 +13,9 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spGetMouseState = Spring.GetMouseState +local spGetMouseState = SpringUnsynced.GetMouseState local doNotify = true local doBlink = true @@ -40,7 +40,7 @@ local gameover = false local currentIcon = nil -- Track currently desired icon for periodic reapplication local faction = "_a" -if UnitDefs[Spring.GetTeamRulesParam(spGetMyTeamID(), "startUnit")].name == "corcom" then +if UnitDefs[SpringShared.GetTeamRulesParam(spGetMyTeamID(), "startUnit")].name == "corcom" then faction = "_c" end @@ -49,7 +49,7 @@ local prevMouseOffscreen = mouseOffscreen local function SetIcon(path) currentIcon = path - Spring.SetWMIcon(path, true) + SpringUnsynced.SetWMIcon(path, true) end function widget:Initialize() @@ -66,7 +66,7 @@ end function widget:GameStart() local prevFaction = faction - if UnitDefs[Spring.GetTeamRulesParam(spGetMyTeamID(), "startUnit")].name == "corcom" then + if UnitDefs[SpringShared.GetTeamRulesParam(spGetMyTeamID(), "startUnit")].name == "corcom" then faction = "_c" else faction = "_a" @@ -100,7 +100,7 @@ function widget:Update(dt) local gameFrame = spGetGameFrame() if gameFrame > 0 then - local _, gameSpeed, isPaused = Spring.GetGameSpeed() + local _, gameSpeed, isPaused = SpringUnsynced.GetGameSpeed() local newPaused = false if gameFrame == previousGameFrame or gameSpeed == 0 then -- when host (admin) paused its just gamespeed 0 newPaused = true @@ -119,7 +119,7 @@ function widget:Update(dt) end else local prevFaction = faction - if UnitDefs[Spring.GetTeamRulesParam(spGetMyTeamID(), "startUnit")].name == "corcom" then + if UnitDefs[SpringShared.GetTeamRulesParam(spGetMyTeamID(), "startUnit")].name == "corcom" then faction = "_c" else faction = "_a" @@ -152,7 +152,7 @@ function widget:Update(dt) else -- Periodically reapply icon to handle OS/WM dropping it if currentIcon then - Spring.SetWMIcon(currentIcon, true) + SpringUnsynced.SetWMIcon(currentIcon, true) end end end diff --git a/luaui/Widgets/map_auto_mapmark_eraser.lua b/luaui/Widgets/map_auto_mapmark_eraser.lua index 0bbf55d6a58..5cb574c3ecb 100644 --- a/luaui/Widgets/map_auto_mapmark_eraser.lua +++ b/luaui/Widgets/map_auto_mapmark_eraser.lua @@ -47,7 +47,7 @@ function widget:GameFrame(f) if pointsToErase[f] then for i = 1, #pointsToErase[f] do local point = pointsToErase[f][i] - Spring.MarkerErasePosition(point[1], point[2], point[3], nil, true, point[4], true) + SpringUnsynced.MarkerErasePosition(point[1], point[2], point[3], nil, true, point[4], true) recentlyErased[#recentlyErased + 1] = { f, point[1], point[2], point[3] } end pointsToErase[f] = nil @@ -75,7 +75,7 @@ function widget:SetConfigData(data) if data.version and data.eraseTime ~= nil then eraseTime = data.eraseTime end - if data.pointsToErase ~= nil and Spring.GetGameFrame() > 0 then + if data.pointsToErase ~= nil and SpringShared.GetGameFrame() > 0 then pointsToErase = data.pointsToErase end end diff --git a/luaui/Widgets/map_draw_blocker.lua b/luaui/Widgets/map_draw_blocker.lua index d2042124926..bbc30195930 100644 --- a/luaui/Widgets/map_draw_blocker.lua +++ b/luaui/Widgets/map_draw_blocker.lua @@ -17,9 +17,9 @@ local counterNum = 25 local blocklimit = 8 local unblocklimit = 0.5 -local GetPlayerList = Spring.GetPlayerList -local GetPlayerInfo = Spring.GetPlayerInfo -local Echo = Spring.Echo +local GetPlayerList = SpringShared.GetPlayerList +local GetPlayerInfo = SpringShared.GetPlayerInfo +local Echo = SpringShared.Echo -- drawCmds[playerid] = {counters = {point = {}, line = {}, erase = {}}, labels = {...}, blocked = false} local drawCmds = {} diff --git a/luaui/Widgets/map_edge_extension2.lua b/luaui/Widgets/map_edge_extension2.lua index fa668eca1b4..651e2bc6bcc 100644 --- a/luaui/Widgets/map_edge_extension2.lua +++ b/luaui/Widgets/map_edge_extension2.lua @@ -15,7 +15,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -36,7 +36,7 @@ local hasBadCulling = false -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -local spIsAABBInView = Spring.IsAABBInView +local spIsAABBInView = SpringUnsynced.IsAABBInView local mapSizeX, mapSizeZ = Game.mapSizeX, Game.mapSizeZ -------------------------------------------------------------------------------- @@ -541,7 +541,7 @@ function widget:Initialize() --UpdateShader() end - Spring.SendCommands("mapborder 1") --..(mapBorderStyle == 'cutaway' and "1" or "0")) + SpringUnsynced.SendCommands("mapborder 1") --..(mapBorderStyle == 'cutaway' and "1" or "0")) if gl.GetMapRendering("voidGround") then restoreMapBorder = false @@ -556,13 +556,13 @@ function widget:Initialize() ----------- terrainVAO = gl.GetVAO() if terrainVAO == nil then - Spring.SendCommands("luaui enablewidget Map Edge Extension Old") + SpringUnsynced.SendCommands("luaui enablewidget Map Edge Extension Old") widgetHandler:RemoveWidget() end terrainInstanceVBO = gl.GetVBO(GL.ARRAY_BUFFER, true) -- GL.ARRAY_BUFFER, false if terrainInstanceVBO == nil then - Spring.SendCommands("luaui enablewidget Map Edge Extension Old") + SpringUnsynced.SendCommands("luaui enablewidget Map Edge Extension Old") widgetHandler:RemoveWidget() end @@ -613,7 +613,7 @@ function widget:Initialize() local shaderCompiled = mapExtensionShader:Initialize() if not shaderCompiled then - Spring.SendCommands("luaui enablewidget Map Edge Extension Old") + SpringUnsynced.SendCommands("luaui enablewidget Map Edge Extension Old") widgetHandler:RemoveWidget() end @@ -634,15 +634,15 @@ function widget:Initialize() local shaderCompiled = mapExtensionShaderDeferred:Initialize() if not shaderCompiled then - Spring.SendCommands("luaui enablewidget Map Edge Extension Old") + SpringUnsynced.SendCommands("luaui enablewidget Map Edge Extension Old") widgetHandler:RemoveWidget() end - Spring.SendCommands("luaui disablewidget External VR Grid") + SpringUnsynced.SendCommands("luaui disablewidget External VR Grid") end function widget:Shutdown() - Spring.SendCommands("mapborder " .. (restoreMapBorder and "1" or "0")) + SpringUnsynced.SendCommands("mapborder " .. (restoreMapBorder and "1" or "0")) if mapExtensionShader then mapExtensionShader:Finalize() @@ -673,8 +673,8 @@ local function UpdateMirrorParams() return x1 * x2 + y1 * y2 + z1 * z2 end - local cpX, cpY, cpZ = Spring.GetCameraPosition() - local cdX, cdY, cdZ = Spring.GetCameraDirection() + local cpX, cpY, cpZ = SpringUnsynced.GetCameraPosition() + local cdX, cdY, cdZ = SpringUnsynced.GetCameraDirection() local checkInView = false @@ -696,7 +696,7 @@ local function UpdateMirrorParams() return end - local minY, maxY = Spring.GetGroundExtremes() + local minY, maxY = SpringShared.GetGroundExtremes() mirrorParams = {} -- spIsAABBInView params are copied from map_edge_extension.lua @@ -877,7 +877,7 @@ end local lastSunChanged = -1 function widget:SunChanged() -- Note that map_nightmode.lua gadget has to change sun twice in a single draw frame to update all - local df = Spring.GetDrawFrame() + local df = SpringUnsynced.GetDrawFrame() if df == lastSunChanged then return diff --git a/luaui/Widgets/map_grass_gl4.lua b/luaui/Widgets/map_grass_gl4.lua index 5bc1d80c1d2..9bea491ca6c 100644 --- a/luaui/Widgets/map_grass_gl4.lua +++ b/luaui/Widgets/map_grass_gl4.lua @@ -30,12 +30,12 @@ local mathMin = math.min local mathRandom = math.random -- Localized Spring API for performance -local spGetUnitPosition = Spring.GetUnitPosition -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay -local spGetCameraPosition = Spring.GetCameraPosition -local spEcho = Spring.Echo -local spGetAllUnits = Spring.GetAllUnits +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetCameraPosition = SpringUnsynced.GetCameraPosition +local spEcho = SpringShared.Echo +local spGetAllUnits = SpringShared.GetAllUnits ----------IMPORTANT USAGE INSTRUCTIONS/ README---------- @@ -208,12 +208,12 @@ end -------------------------------------------------------------------------------- local patchResolution = grassConfig.patchResolution -local spGetGroundHeight = Spring.GetGroundHeight -local spGetGrass = Spring.GetGrass -local spGetUnitDefID = Spring.GetUnitDefID +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetGrass = SpringShared.GetGrass +local spGetUnitDefID = SpringShared.GetUnitDefID local mapSizeX, mapSizeZ = Game.mapSizeX, Game.mapSizeZ local vsx, vsy = gl.GetViewSizes() -local minHeight, maxHeight = Spring.GetGroundExtremes() +local minHeight, maxHeight = SpringShared.GetGroundExtremes() local removedBelowHeight local lastLavaLevel local lavaCheckInterval = 30 -- check every N game frames @@ -351,7 +351,7 @@ local function testForGrass(mx, mz) return nil end else - local gx, gy, gz, gs = Spring.GetGroundNormal(mx, mz) + local gx, gy, gz, gs = SpringShared.GetGroundNormal(mx, mz) local gh = spGetGroundHeight(mx, mz) if (gh > grassConfig.grassMinHeight) and (gh < grassConfig.grassMaxHeight) and (gy > grassConfig.grassMaxSlope) then return gh @@ -431,7 +431,7 @@ local function updateGrassInstanceVBO(wx, wz, size, sizemod, vboOffset) local shift = false if placementMode then - _, _, _, shift = Spring.GetModKeyState() + _, _, _, shift = SpringUnsynced.GetModKeyState() end if sizemod < 1 then if size < grassConfig.grassMinSize or shift then @@ -562,7 +562,7 @@ end function widget:VisibleUnitAdded(unitID, unitDefID, unitTeam) if processChanges and not placementMode and buildingRadius[unitDefID] and not unitGrassRemovedHistory[unitID] then - local isBuilding = Spring.GetUnitIsBeingBuilt(unitID) + local isBuilding = SpringShared.GetUnitIsBeingBuilt(unitID) if isBuilding then removeUnitGrassQueue[unitID] = removeUnitGrassFrames else @@ -601,7 +601,7 @@ function widget:GameFrame(gf) -- check lava level and remove grass where lava is higher than ground if gf % lavaCheckInterval == 0 then - local lavaLevel = Spring.GetGameRulesParam("lavaLevel") + local lavaLevel = SpringShared.GetGameRulesParam("lavaLevel") if lavaLevel and lavaLevel ~= -99999 and (not lastLavaLevel or lavaLevel > lastLavaLevel) then lastLavaLevel = lavaLevel if WG["grassgl4"] and WG["grassgl4"].removeGrassBelowHeight then @@ -620,7 +620,7 @@ function widget:GameFrame(gf) end local allUnits = spGetAllUnits() for _, unitID in pairs(allUnits) do - if isCommander[Spring.GetUnitDefID(unitID)] then + if isCommander[SpringShared.GetUnitDefID(unitID)] then local x, _, z = spGetUnitPosition(unitID) adjustGrass(x, z, 90, 1) end @@ -996,7 +996,7 @@ function widget:Initialize() WG["grassgl4"].removeGrassBelowHeight(20) end -- initial lava check - local initLavaLevel = Spring.GetGameRulesParam("lavaLevel") + local initLavaLevel = SpringShared.GetGameRulesParam("lavaLevel") if initLavaLevel and initLavaLevel ~= -99999 then lastLavaLevel = initLavaLevel WG["grassgl4"].removeGrassBelowHeight(initLavaLevel) @@ -1041,7 +1041,7 @@ function widget:GetConfigData(data) end local function getWindSpeed() - windDirX, _, windDirZ, _ = Spring.GetWind() + windDirX, _, windDirZ, _ = SpringShared.GetWind() -- cap windspeed while preserving direction if windDirX > grassConfig.maxWindSpeed and windDirX > windDirZ then windDirZ = (windDirZ / windDirX) * grassConfig.maxWindSpeed @@ -1058,7 +1058,7 @@ local function mapcoordtorow(mapz, offset) -- is this even worth it? return grassRowInstance[rownum] end -local spIsAABBInView = Spring.IsAABBInView +local spIsAABBInView = SpringUnsynced.IsAABBInView local viewtables = { { 0, 0 }, { vsx - 1, 0 }, { 0, vsy - 1 }, { vsx - 1, vsy - 1 } } @@ -1128,7 +1128,7 @@ function widget:DrawWorldPreUnit() if #grassInstanceData == 0 then return end - local mapDrawMode = Spring.GetMapDrawMode() + local mapDrawMode = SpringUnsynced.GetMapDrawMode() if mapDrawMode ~= "normal" and mapDrawMode ~= "los" then return end @@ -1143,7 +1143,7 @@ function widget:DrawWorldPreUnit() oldGameSeconds = newGameSeconds local cx, cy, cz = spGetCameraPosition() - local gh = (Spring.GetGroundHeight(cx, cz) or 0) + local gh = (SpringShared.GetGroundHeight(cx, cz) or 0) local globalgrassfade = math.clamp(((grassConfig.grassShaderParams.FADEEND * distanceMult) - (cy - gh)) / ((grassConfig.grassShaderParams.FADEEND * distanceMult) - (grassConfig.grassShaderParams.FADESTART * distanceMult)), 0, 1) @@ -1160,7 +1160,7 @@ function widget:DrawWorldPreUnit() if instanceCount <= 0 or startInstanceIndex == #grassInstanceData / 4 then return end - local _, _, isPaused = Spring.GetGameSpeed() + local _, _, isPaused = SpringUnsynced.GetGameSpeed() if not isPaused then getWindSpeed() offsetX = offsetX - ((windDirX * grassConfig.grassWindMult) * timePassed) @@ -1188,7 +1188,7 @@ function widget:DrawWorldPreUnit() -- NOTE THAT INDEXED DRAWING DOESNT WORK YET! grassVAO:DrawArrays(GL.TRIANGLES, grassPatchVBOsize, 0, instanceCount, startInstanceIndex) - if placementMode and Spring.GetGameFrame() % 30 == 0 then + if placementMode and SpringShared.GetGameFrame() % 30 == 0 then spEcho("Drawing", instanceCount, "grass patches") end grassShader:Deactivate() @@ -1207,7 +1207,7 @@ end local lastSunChanged = -1 function widget:SunChanged() -- Note that map_nightmode.lua gadget has to change sun twice in a single draw frame to update all - local df = Spring.GetDrawFrame() + local df = SpringUnsynced.GetDrawFrame() --spEcho("widget:SunChanged", df) if df == lastSunChanged then return diff --git a/luaui/Widgets/map_lighting_adjuster.lua b/luaui/Widgets/map_lighting_adjuster.lua index c4f99612361..ddaade0dfd4 100644 --- a/luaui/Widgets/map_lighting_adjuster.lua +++ b/luaui/Widgets/map_lighting_adjuster.lua @@ -168,22 +168,22 @@ function widget:Initialize() if not mapSunLighting[currentMapname] and not mapSun[currentMapname] then return end - if Spring.GetGameFrame() < 1 then + if SpringShared.GetGameFrame() < 1 then if mapSun[currentMapname] then - Spring.SetSunDirection(mapSun[currentMapname][1], mapSun[currentMapname][2], mapSun[currentMapname][3]) - Spring.SetSunLighting({ groundShadowDensity = gl.GetSun("shadowDensity"), modelShadowDensity = gl.GetSun("shadowDensity") }) + SpringUnsynced.SetSunDirection(mapSun[currentMapname][1], mapSun[currentMapname][2], mapSun[currentMapname][3]) + SpringUnsynced.SetSunLighting({ groundShadowDensity = gl.GetSun("shadowDensity"), modelShadowDensity = gl.GetSun("shadowDensity") }) --Spring.SendCommands("luarules updatesun") end if mapSunLighting[currentMapname] then - Spring.SetSunLighting(mapSunLighting[currentMapname]) - Spring.SendCommands("luarules updatesun") + SpringUnsynced.SetSunLighting(mapSunLighting[currentMapname]) + SpringUnsynced.SendCommands("luarules updatesun") end end end local lastSunChanged = -1 function widget:SunChanged() -- Note that map_nightmode.lua gadget has to change sun twice in a single draw frame to update all - local df = Spring.GetDrawFrame() + local df = SpringUnsynced.GetDrawFrame() if df == lastSunChanged then return diff --git a/luaui/Widgets/map_start_position_suggestions.lua b/luaui/Widgets/map_start_position_suggestions.lua index 4fd22cc3a93..318af98138f 100644 --- a/luaui/Widgets/map_start_position_suggestions.lua +++ b/luaui/Widgets/map_start_position_suggestions.lua @@ -23,10 +23,10 @@ local tableInsert = table.insert local tableConcat = table.concat -- Localized Spring API for performance -local spGetMouseState = Spring.GetMouseState -local spGetGroundHeight = Spring.GetGroundHeight -local spGetViewGeometry = Spring.GetViewGeometry -local spGetTeamColor = Spring.GetTeamColor +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetGroundHeight = SpringShared.GetGroundHeight +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetTeamColor = SpringUnsynced.GetTeamColor --todo: gl4 (also make circles more transparent as you zoom in) @@ -72,10 +72,10 @@ local resMult = vsy / 1440 -- engine call optimizations -- ========================= -local SpringGetCameraState = Spring.GetCameraState -local SpringIsGUIHidden = Spring.IsGUIHidden -local SpringGetCameraRotation = Spring.GetCameraRotation -local SpringGetGameFrame = Spring.GetGameFrame +local SpringGetCameraState = SpringUnsynced.GetCameraState +local SpringIsGUIHidden = SpringUnsynced.IsGUIHidden +local SpringGetCameraRotation = SpringUnsynced.GetCameraRotation +local SpringGetGameFrame = SpringShared.GetGameFrame local glColor = gl.Color local glDepthTest = gl.DepthTest @@ -137,17 +137,17 @@ local function convertXYToXZ(p) } end -local gaiaTeamID = Spring.GetGaiaTeamID() -local gaiaAllyTeamID = select(6, Spring.GetTeamInfo(gaiaTeamID, false)) +local gaiaTeamID = SpringShared.GetGaiaTeamID() +local gaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(gaiaTeamID, false)) local function getTeamSizes() - local allyTeams = Spring.GetAllyTeamList() + local allyTeams = SpringShared.GetAllyTeamList() local allyTeamCount = 0 local playersPerTeam = 0 for _, allyTeamID in ipairs(allyTeams) do if allyTeamID ~= gaiaAllyTeamID then allyTeamCount = allyTeamCount + 1 - local teamList = Spring.GetTeamList(allyTeamID) or {} + local teamList = SpringShared.GetTeamList(allyTeamID) or {} playersPerTeam = mathMax(playersPerTeam, #teamList) end end @@ -171,14 +171,14 @@ local function processModoptionTeamConfig(positions, teamPositions) end local function selectModoptionConfigForPlayers(modoptionData, allyTeamCount, playersPerTeam) - Spring.Log(widget:GetInfo().name, LOG.INFO, "Searching for start positions for " .. table.toString({ + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "Searching for start positions for " .. table.toString({ allyTeamCount = allyTeamCount, playersPerTeam = playersPerTeam, })) for _, teamConfig in ipairs(modoptionData.team) do if teamConfig.playersPerTeam == playersPerTeam and teamConfig.teamCount == allyTeamCount then - Spring.Log(widget:GetInfo().name, LOG.INFO, "Found start positions") + SpringShared.Log(widget:GetInfo().name, LOG.INFO, "Found start positions") return teamConfig.sides end end @@ -187,10 +187,10 @@ local function selectModoptionConfigForPlayers(modoptionData, allyTeamCount, pla end local function loadStartPositions() - local modoptionDataRaw = Spring.GetModOptions().mapmetadata_startpos + local modoptionDataRaw = SpringShared.GetModOptions().mapmetadata_startpos if modoptionDataRaw == nil or string.len(modoptionDataRaw) == 0 then - Spring.Log(widget:GetInfo().name, LOG.WARNING, "No modoption start position data found") + SpringShared.Log(widget:GetInfo().name, LOG.WARNING, "No modoption start position data found") return end @@ -202,7 +202,7 @@ local function loadStartPositions() local selectedConfig = selectModoptionConfigForPlayers(parsed, allyTeamCount, playersPerTeam) if selectedConfig == nil then - Spring.Log(widget:GetInfo().name, LOG.WARNING, "Could not find matching start positions") + SpringShared.Log(widget:GetInfo().name, LOG.WARNING, "Could not find matching start positions") return end @@ -602,7 +602,7 @@ local function wrapText(str, maxLength) end local function drawTooltip() - if not tooltipKey or Spring.DiffTimers(Spring.GetTimer(), tooltipStartTime) < config.tooltipDelay then + if not tooltipKey or SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), tooltipStartTime) < config.tooltipDelay then return end @@ -643,8 +643,8 @@ function widget:ViewResize() vsx, vsy = spGetViewGeometry() resMult = vsy / 1440 local baseFontSize = mathMax(config.playerTextSize, config.roleTextSize) * 0.6 - font = gl.LoadFont("fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf"), baseFontSize * resMult, (baseFontSize * resMult) / 14, 1) - fontTutorial = gl.LoadFont("fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf"), config.tutorialTextSize * resMult, (config.tutorialTextSize * resMult) / 14, 1) + font = gl.LoadFont("fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf"), baseFontSize * resMult, (baseFontSize * resMult) / 14, 1) + fontTutorial = gl.LoadFont("fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf"), config.tutorialTextSize * resMult, (config.tutorialTextSize * resMult) / 14, 1) end function widget:GetConfigData() @@ -660,7 +660,7 @@ function widget:SetConfigData(data) end function widget:Initialize() - Spring.SetLogSectionFilterLevel(widget:GetInfo().name, LOG.INFO) + SpringUnsynced.SetLogSectionFilterLevel(widget:GetInfo().name, LOG.INFO) widget:ViewResize() startPositions = loadStartPositions() if not startPositions then @@ -678,7 +678,7 @@ end local function checkTooltips() local mx, my = spGetMouseState() - local _, mw = Spring.TraceScreenRay(mx, my, true, true) + local _, mw = SpringUnsynced.TraceScreenRay(mx, my, true, true) local mwx, mwy, mwz if mw ~= nil then mwx, mwy, mwz = unpack(mw) @@ -702,7 +702,7 @@ local function checkTooltips() if newKey then if newKey ~= prevTooltipKey then - tooltipStartTime = Spring.GetTimer() + tooltipStartTime = SpringUnsynced.GetTimer() end tooltipKey = newKey end @@ -712,11 +712,11 @@ end local function getPlacedCommanders() local newPlacedCommanders = {} - for _, teamID in ipairs(Spring.GetTeamList()) do - local playerID = select(2, Spring.GetTeamInfo(teamID, false)) - local name, _, spec = Spring.GetPlayerInfo(playerID, false) + for _, teamID in ipairs(SpringShared.GetTeamList()) do + local playerID = select(2, SpringShared.GetTeamInfo(teamID, false)) + local name, _, spec = SpringShared.GetPlayerInfo(playerID, false) if name ~= nil and not spec and teamID ~= gaiaTeamID then - local x, y, z = Spring.GetTeamStartPosition(teamID) + local x, y, z = SpringShared.GetTeamStartPosition(teamID) if x and y and z then tableInsert(newPlacedCommanders, { position = { x, y, z }, diff --git a/luaui/Widgets/map_startbox.lua b/luaui/Widgets/map_startbox.lua index d47130d3f06..44c3f2d49b7 100644 --- a/luaui/Widgets/map_startbox.lua +++ b/luaui/Widgets/map_startbox.lua @@ -20,16 +20,16 @@ local mathFloor = math.floor local mathRandom = math.random local mathAbs = math.abs -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spEcho = Spring.Echo -local spGetSpectatingState = Spring.GetSpectatingState -local spGetTeamList = Spring.GetTeamList -local spGetTeamInfo = Spring.GetTeamInfo -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetTeamStartPosition = Spring.GetTeamStartPosition -local spGetTeamRulesParam = Spring.GetTeamRulesParam -local spGetGroundHeight = Spring.GetGroundHeight +local spEcho = SpringShared.Echo +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetTeamList = SpringShared.GetTeamList +local spGetTeamInfo = SpringShared.GetTeamInfo +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetTeamStartPosition = SpringShared.GetTeamStartPosition +local spGetTeamRulesParam = SpringShared.GetTeamRulesParam +local spGetGroundHeight = SpringShared.GetGroundHeight local glDrawGroundCircle = gl.DrawGroundCircle local GL_SRC_ALPHA = GL.SRC_ALPHA @@ -46,13 +46,13 @@ if Game.startPosType ~= 2 then return false end -local draftMode = Spring.GetModOptions().draft_mode -local allowEnemyAIPlacement = Spring.GetModOptions().allow_enemy_ai_spawn_placement +local draftMode = SpringShared.GetModOptions().draft_mode +local allowEnemyAIPlacement = SpringShared.GetModOptions().allow_enemy_ai_spawn_placement local tooCloseToSpawn -local fontfile = "fonts/" .. Spring.GetConfigString("bar_font", "Poppins-Regular.otf") -local vsx, vsy = Spring.GetViewGeometry() +local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font", "Poppins-Regular.otf") +local vsx, vsy = SpringUnsynced.GetViewGeometry() local fontfileScale = 0.5 + (vsx * vsy / 5700000) local fontfileSize = 50 local fontfileOutlineSize = 8 @@ -60,7 +60,7 @@ local fontfileOutlineStrength = 1.65 local fontfileOutlineStrength2 = 10 local font = gl.LoadFont(fontfile, fontfileSize * fontfileScale, fontfileOutlineSize * fontfileScale, fontfileOutlineStrength) local shadowFont = gl.LoadFont(fontfile, fontfileSize * fontfileScale, 35 * fontfileScale, 1.5) -local fontfile2 = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") +local fontfile2 = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") local font2 = gl.LoadFont(fontfile2, fontfileSize * fontfileScale, fontfileOutlineSize * fontfileScale, fontfileOutlineStrength2) local useThickLeterring = false @@ -77,12 +77,12 @@ local widgetScale = (1 + (vsx * vsy / 5500000)) local startPosRatio = 0.0001 local startPosScale if getCurrentMiniMapRotationOption() == ROTATION.DEG_90 or getCurrentMiniMapRotationOption() == ROTATION.DEG_270 then - startPosScale = (vsx * startPosRatio) / select(4, Spring.GetMiniMapGeometry()) + startPosScale = (vsx * startPosRatio) / select(4, SpringUnsynced.GetMiniMapGeometry()) else - startPosScale = (vsx * startPosRatio) / select(3, Spring.GetMiniMapGeometry()) + startPosScale = (vsx * startPosRatio) / select(3, SpringUnsynced.GetMiniMapGeometry()) end -local isSpec = spGetSpectatingState() or Spring.IsReplay() +local isSpec = spGetSpectatingState() or SpringUnsynced.IsReplay() local myTeamID = spGetMyTeamID() local placeVoiceNotifTimer = false @@ -92,12 +92,12 @@ local amPlaced = false local gaiaTeamID -local startTimer = Spring.GetTimer() +local startTimer = SpringUnsynced.GetTimer() local lastRot = -1 --TODO: switch this to use MiniMapRotationChanged Callin when it is added to Engine local infotextList -local GetTeamColor = Spring.GetTeamColor +local GetTeamColor = SpringUnsynced.GetTeamColor local ColorIsDark = Spring.Utilities.Color.ColorIsDark @@ -159,8 +159,8 @@ local function getAIName(teamID, includeLock) if not baseName then local _, playerID, _, isAI = spGetTeamInfo(teamID, false) if isAI then - local _, _, _, aiName = Spring.GetAIInfo(teamID) - local niceName = Spring.GetGameRulesParam("ainame_" .. teamID) + local _, _, _, aiName = SpringShared.GetAIInfo(teamID) + local niceName = SpringShared.GetGameRulesParam("ainame_" .. teamID) if niceName then aiName = niceName end @@ -288,8 +288,8 @@ local posCache = {} local function getEffectiveStartPosition(teamID) if draggingTeamID == teamID then - local mouseX, mouseY = Spring.GetMouseState() - local traceType, pos = Spring.TraceScreenRay(mouseX, mouseY, true) + local mouseX, mouseY = SpringUnsynced.GetMouseState() + local traceType, pos = SpringUnsynced.TraceScreenRay(mouseX, mouseY, true) if traceType == "ground" then local x = pos[1] + dragOffsetX local z = pos[3] + dragOffsetZ @@ -505,7 +505,7 @@ local startConeShader = nil local function DrawStartPolygons(inminimap) - local _, advMapShading = Spring.HaveAdvShading() + local _, advMapShading = SpringUnsynced.HaveAdvShading() if advMapShading then gl.Texture(0, "$map_gbuffer_zvaltex") @@ -623,7 +623,7 @@ local function getStartUnitTexture(teamID) return "unitpics/other/dice.dds" end -local totalTeams = #Spring.GetTeamList() - 1 +local totalTeams = #SpringShared.GetTeamList() - 1 local function buildIconList(sx, sz) -- Ensure teams data is populated (DrawInMiniMap may be called before DrawWorld) if not teamsToRenderCount or teamsToRenderCount == 0 then @@ -804,13 +804,13 @@ end local function InitStartPolygons() local gaiaAllyTeamID - if Spring.GetGaiaTeamID() then - gaiaAllyTeamID = select(6, spGetTeamInfo(Spring.GetGaiaTeamID(), false)) + if SpringShared.GetGaiaTeamID() then + gaiaAllyTeamID = select(6, spGetTeamInfo(SpringShared.GetGaiaTeamID(), false)) end - for i, teamID in ipairs(Spring.GetAllyTeamList()) do + for i, teamID in ipairs(SpringShared.GetAllyTeamList()) do if teamID ~= gaiaAllyTeamID then --and teamID ~= scavengerAIAllyTeamID and teamID ~= raptorsAIAllyTeamID then - local xn, zn, xp, zp = Spring.GetAllyTeamStartBox(teamID) + local xn, zn, xp, zp = SpringShared.GetAllyTeamStartBox(teamID) --spEcho("Allyteam",teamID,"startbox",xn, zn, xp, zp) StartPolygons[teamID] = { { xn, zn }, { xp, zn }, { xp, zp }, { xn, zp } } end @@ -842,8 +842,8 @@ local function InitStartPolygons() shaderSourceCache.shaderConfig.NUM_BOXES = #StartPolygons - local minY, maxY = Spring.GetGroundExtremes() - local waterlevel = (Spring.GetModOption and Spring.GetModOptions().map_waterlevel) or 0 + local minY, maxY = SpringShared.GetGroundExtremes() + local waterlevel = (SpringShared.GetModOption and SpringShared.GetModOptions().map_waterlevel) or 0 if waterlevel > 0 then minY = minY - waterlevel maxY = maxY - waterlevel @@ -857,7 +857,7 @@ local function InitStartPolygons() for teamID, polygon in pairs(StartPolygons) do numPolygons = numPolygons + 1 local numPoints = #polygon - local xn, zn, xp, zp = Spring.GetAllyTeamStartBox(teamID) + local xn, zn, xp, zp = SpringShared.GetAllyTeamStartBox(teamID) --spEcho("teamID", teamID, "at " ,xn, zn, xp, zp) for vertexID, vertex in ipairs(polygon) do local x, z = vertex[1], vertex[2] @@ -931,7 +931,7 @@ function widget:Initialize() return end - tooCloseToSpawn = Spring.GetGameRulesParam("tooCloseToSpawn") or 350 + tooCloseToSpawn = SpringShared.GetGameRulesParam("tooCloseToSpawn") or 350 widgetHandler:RegisterGlobal("GadgetCoopStartPoint", CoopStartPoint) @@ -941,7 +941,7 @@ function widget:Initialize() updateTeamList() assignTeamColors() - gaiaTeamID = Spring.GetGaiaTeamID() + gaiaTeamID = SpringShared.GetGaiaTeamID() for _, teamID in ipairs(cachedTeamList) do if teamID ~= gaiaTeamID then @@ -1024,7 +1024,7 @@ function widget:DrawWorld() gl.Blending(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) - local time = Spring.DiffTimers(Spring.GetTimer(), startTimer) + local time = SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), startTimer) local alpha = 0.5 + mathAbs(((time * 3) % 1) - 0.5) InstanceVBOTable.clearInstanceTable(startConeVBOTable) @@ -1084,7 +1084,7 @@ function widget:DrawScreenEffects() end if name then - local sx, sy, sz = Spring.WorldToScreenCoords(x, y + 120, z) + local sx, sy, sz = SpringUnsynced.WorldToScreenCoords(x, y + 120, z) if sz < 1 then drawName(sx, sy, name, teamID) end @@ -1122,9 +1122,9 @@ function widget:ViewResize(x, y) local currRot = getCurrentMiniMapRotationOption() if currRot == ROTATION.DEG_90 or currRot == ROTATION.DEG_270 then - startPosScale = (vsx * startPosRatio) / select(4, Spring.GetMiniMapGeometry()) + startPosScale = (vsx * startPosRatio) / select(4, SpringUnsynced.GetMiniMapGeometry()) else - startPosScale = (vsx * startPosRatio) / select(3, Spring.GetMiniMapGeometry()) + startPosScale = (vsx * startPosRatio) / select(3, SpringUnsynced.GetMiniMapGeometry()) end removeTeamLists() invalidateMinimapIcons() @@ -1313,8 +1313,8 @@ function widget:Update(delta) for _, teamID in ipairs(cachedTeamList) do if teamID ~= gaiaTeamID then local _, _, _, isAI, _, allyTeamID = spGetTeamInfo(teamID, false) - if isAI and not aiPlacedPositions[teamID] and (allyTeamID == myAllyTeamID or isSpec or Spring.IsCheatingEnabled() or allowEnemyAIPlacement) then - local xmin, zmin, xmax, zmax = Spring.GetAllyTeamStartBox(allyTeamID) + if isAI and not aiPlacedPositions[teamID] and (allyTeamID == myAllyTeamID or isSpec or SpringShared.IsCheatingEnabled() or allowEnemyAIPlacement) then + local xmin, zmin, xmax, zmax = SpringShared.GetAllyTeamStartBox(allyTeamID) local x, z = GuessStartSpot(teamID, allyTeamID, xmin, zmin, xmax, zmax, startPointTable) if x and x > 0 and z and z > 0 then local prevPos = aiPredictedPositions[teamID] @@ -1363,14 +1363,14 @@ function widget:RecvLuaMsg(msg) invalidatePosCacheEntry(teamID) aiLocationI18NTable.playerName = spGetPlayerInfo(Spring.GetMyPlayerID(), false) aiLocationI18NTable.aiName = getAIName(teamID) - Spring.SendMessage(Spring.I18N("ui.startbox.aiStartLocationRemoved", aiLocationI18NTable)) + SpringUnsynced.SendMessage(Spring.I18N("ui.startbox.aiStartLocationRemoved", aiLocationI18NTable)) else aiPlacedPositions[teamID] = { x = x, z = z } aiPlacementStatus[teamID] = true invalidatePosCacheEntry(teamID) aiLocationI18NTable.playerName = spGetPlayerInfo(Spring.GetMyPlayerID(), false) aiLocationI18NTable.aiName = getAIName(teamID) - Spring.SendMessage(Spring.I18N("ui.startbox.aiStartLocationChanged", aiLocationI18NTable)) + SpringUnsynced.SendMessage(Spring.I18N("ui.startbox.aiStartLocationChanged", aiLocationI18NTable)) end invalidateMinimapIcons() @@ -1395,7 +1395,7 @@ function widget:MousePress(x, y, button) return false end - local traceType, pos = Spring.TraceScreenRay(x, y, true) + local traceType, pos = SpringUnsynced.TraceScreenRay(x, y, true) if traceType ~= "ground" then return false end @@ -1404,7 +1404,7 @@ function widget:MousePress(x, y, button) if button == RIGHT_BUTTON then if aiCurrentlyBeingPlaced then aiCurrentlyBeingPlaced = nil - Spring.SendLuaUIMsg("aiPlacementCancel:") + SpringUnsynced.SendLuaUIMsg("aiPlacementCancel:") return true end @@ -1416,8 +1416,8 @@ function widget:MousePress(x, y, button) local dz = worldZ - placedPos.z if (dx * dx + dz * dz) <= (CONE_CLICK_RADIUS * CONE_CLICK_RADIUS) then aiPlacedPositions[teamID] = nil - Spring.SendLuaRulesMsg("aiPlacedPosition:" .. teamID .. ":0:0") - Spring.SendLuaUIMsg("aiPlacementComplete:" .. teamID .. ":0:0") + SpringUnsynced.SendLuaRulesMsg("aiPlacedPosition:" .. teamID .. ":0:0") + SpringUnsynced.SendLuaUIMsg("aiPlacementComplete:" .. teamID .. ":0:0") return true end end @@ -1430,10 +1430,10 @@ function widget:MousePress(x, y, button) local aiTeamID = aiCurrentlyBeingPlaced local _, _, _, _, _, aiAllyTeamID = spGetTeamInfo(aiTeamID, false) - local xmin, zmin, xmax, zmax = Spring.GetAllyTeamStartBox(aiAllyTeamID) + local xmin, zmin, xmax, zmax = SpringShared.GetAllyTeamStartBox(aiAllyTeamID) if xmin < xmax and zmin < zmax then if worldX >= xmin and worldX <= xmax and worldZ >= zmin and worldZ <= zmax then - Spring.SendLuaRulesMsg("aiPlacedPosition:" .. aiTeamID .. ":" .. worldX .. ":" .. worldZ) + SpringUnsynced.SendLuaRulesMsg("aiPlacedPosition:" .. aiTeamID .. ":" .. worldX .. ":" .. worldZ) aiCurrentlyBeingPlaced = nil return true end @@ -1476,20 +1476,20 @@ function widget:MouseRelease(x, y, button) end if button == LEFT_BUTTON and draggingTeamID then - local traceType, pos = Spring.TraceScreenRay(x, y, true) + local traceType, pos = SpringUnsynced.TraceScreenRay(x, y, true) if traceType == "ground" then local worldX, worldY, worldZ = pos[1], pos[2], pos[3] local finalX = worldX + dragOffsetX local finalZ = worldZ + dragOffsetZ local _, _, _, _, _, aiAllyTeamID = spGetTeamInfo(draggingTeamID, false) - local xmin, zmin, xmax, zmax = Spring.GetAllyTeamStartBox(aiAllyTeamID) + local xmin, zmin, xmax, zmax = SpringShared.GetAllyTeamStartBox(aiAllyTeamID) if xmin < xmax and zmin < zmax then if finalX >= xmin and finalX <= xmax and finalZ >= zmin and finalZ <= zmax then aiPlacedPositions[draggingTeamID] = { x = finalX, z = finalZ } posCache[draggingTeamID] = nil - Spring.SendLuaRulesMsg("aiPlacedPosition:" .. draggingTeamID .. ":" .. finalX .. ":" .. finalZ) + SpringUnsynced.SendLuaRulesMsg("aiPlacedPosition:" .. draggingTeamID .. ":" .. finalX .. ":" .. finalZ) notifySpawnPositionsChanged() end end diff --git a/luaui/Widgets/map_startpolygon_gl4.lua b/luaui/Widgets/map_startpolygon_gl4.lua index 10c0b60e568..d9718f6225f 100644 --- a/luaui/Widgets/map_startpolygon_gl4.lua +++ b/luaui/Widgets/map_startpolygon_gl4.lua @@ -16,7 +16,7 @@ end local mathRandom = math.random -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -- Note: this is now updated to support arbitrary start polygons via GL.SHADER_STORAGE_BUFFER @@ -51,7 +51,7 @@ local StartPolygons = {} -- list of points in clockwise order local LuaShader = gl.LuaShader local InstanceVBOTable = gl.InstanceVBOTable -local minY, maxY = Spring.GetGroundExtremes() +local minY, maxY = SpringShared.GetGroundExtremes() local shaderSourceCache = { vssrcpath = "LuaUI/Shaders/map_startpolygon_gl4.vert.glsl", @@ -87,7 +87,7 @@ local startPolygonShader local startPolygonBuffer = nil -- GL.SHADER_STORAGE_BUFFER for polygon local function DrawStartPolygons(inminimap) - local _, advMapShading = Spring.HaveAdvShading() + local _, advMapShading = SpringUnsynced.HaveAdvShading() if advMapShading then gl.Texture(0, "$map_gbuffer_zvaltex") @@ -142,13 +142,13 @@ end function widget:Initialize() local gaiaAllyTeamID - if Spring.GetGaiaTeamID() then - gaiaAllyTeamID = select(6, Spring.GetTeamInfo(Spring.GetGaiaTeamID(), false)) + if SpringShared.GetGaiaTeamID() then + gaiaAllyTeamID = select(6, SpringShared.GetTeamInfo(SpringShared.GetGaiaTeamID(), false)) end - for i, teamID in ipairs(Spring.GetAllyTeamList()) do + for i, teamID in ipairs(SpringShared.GetAllyTeamList()) do if teamID ~= gaiaAllyTeamID then --and teamID ~= scavengerAIAllyTeamID and teamID ~= raptorsAIAllyTeamID then - local xn, zn, xp, zp = Spring.GetAllyTeamStartBox(teamID) + local xn, zn, xp, zp = SpringShared.GetAllyTeamStartBox(teamID) --spEcho("Allyteam",teamID,"startbox",xn, zn, xp, zp) StartPolygons[teamID] = { { xn, zn }, { xp, zn }, { xp, zp }, { xn, zp } } end @@ -180,7 +180,7 @@ function widget:Initialize() for teamID, polygon in pairs(StartPolygons) do numPolygons = numPolygons + 1 local numPoints = #polygon - local xn, zn, xp, zp = Spring.GetAllyTeamStartBox(teamID) + local xn, zn, xp, zp = SpringShared.GetAllyTeamStartBox(teamID) --spEcho("teamID", teamID, "at " ,xn, zn, xp, zp) for vertexID, vertex in ipairs(polygon) do local x, z = vertex[1], vertex[2] diff --git a/luaui/Widgets/minimap_rotation_manager.lua b/luaui/Widgets/minimap_rotation_manager.lua index 208e0e6414f..a6aa27002a7 100644 --- a/luaui/Widgets/minimap_rotation_manager.lua +++ b/luaui/Widgets/minimap_rotation_manager.lua @@ -14,7 +14,7 @@ end local mathFloor = math.floor -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo --[[ Minimap Rotation Manager @@ -68,8 +68,8 @@ local lastGameID = nil -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -local spSetMiniRot = Spring.SetMiniMapRotation -local spGetMiniRot = Spring.GetMiniMapRotation +local spSetMiniRot = SpringUnsynced.SetMiniMapRotation +local spGetMiniRot = SpringUnsynced.GetMiniMapRotation local PI = math.pi local HALFPI = PI / 2 local TWOPI = PI * 2 @@ -163,7 +163,7 @@ local function applyAutoFitRotation() if mapSizeZ > mapSizeX then -- Map is portrait-oriented: rotate 90 degrees so it fills the wider minimap GUI area if not autoFitTargetRot then - local camState = Spring.GetCameraState() + local camState = SpringUnsynced.GetCameraState() local ry = (camState and camState.ry) or 0 local sunX, _, sunZ = gl.GetSun("pos") -- Compute forward dot sun for both candidate rotations @@ -182,13 +182,13 @@ local function applyAutoFitRotation() if currentRot and math.abs(currentRot - autoFitTargetRot) < 0.01 then -- Minimap confirmed, now rotate the camera (only after minimap is verified) if not autoFitCameraApplied then - local camState = Spring.GetCameraState() + local camState = SpringUnsynced.GetCameraState() if camState then local targetRy = (camState.ry or 0) - autoFitTargetRot camState.ry = targetRy - Spring.SetCameraState(camState, 0) + SpringUnsynced.SetCameraState(camState, 0) -- Verify camera rotation took effect - local verifyCam = Spring.GetCameraState() + local verifyCam = SpringUnsynced.GetCameraState() if verifyCam and math.abs((verifyCam.ry or 0) - targetRy) < 0.1 then autoFitCameraApplied = true spEcho("[MinimapManager] AutoFit: camera rotated to ry=" .. targetRy) @@ -228,7 +228,7 @@ function widget:Initialize() autoFitCameraApplied = false applyAutoFitRotation() else - widget:CameraRotationChanged(Spring.GetCameraRotation()) -- Force update on mode change + widget:CameraRotationChanged(SpringUnsynced.GetCameraRotation()) -- Force update on mode change end end end @@ -242,7 +242,7 @@ function widget:Initialize() mode = temp end - Spring.SetConfigInt("MiniMapCanFlip", 0) + SpringUnsynced.SetConfigInt("MiniMapCanFlip", 0) widgetHandler:AddAction("minimap_rotate", minimapRotateHandler, nil, "p") @@ -258,7 +258,7 @@ function widget:Update() return end - local currentGameID = Game.gameID or Spring.GetGameRulesParam("GameID") + local currentGameID = Game.gameID or SpringShared.GetGameRulesParam("GameID") if not currentGameID then return end -- game not loaded yet diff --git a/luaui/Widgets/shard_help_draw.lua b/luaui/Widgets/shard_help_draw.lua index 66f6aab5567..02945699dd2 100644 --- a/luaui/Widgets/shard_help_draw.lua +++ b/luaui/Widgets/shard_help_draw.lua @@ -67,16 +67,16 @@ local mSin = math.sin local twicePi = math.pi * 2 local mMin = math.min -local spIsSphereInView = Spring.IsSphereInView -local spGetGroundHeight = Spring.GetGroundHeight -local spWorldToScreenCoords = Spring.WorldToScreenCoords -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetTimer = Spring.GetTimer -local spDiffTimers = Spring.DiffTimers +local spIsSphereInView = SpringUnsynced.IsSphereInView +local spGetGroundHeight = SpringShared.GetGroundHeight +local spWorldToScreenCoords = SpringUnsynced.WorldToScreenCoords +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetTimer = SpringUnsynced.GetTimer +local spDiffTimers = SpringUnsynced.DiffTimers local glCreateList = gl.CreateList local glCallList = gl.CallList @@ -949,7 +949,7 @@ local function InterpretStringData(data, command) end local function SaveTable(tableinput, tablename, filename) - Spring.Echo("Saving " .. tablename .. " on " .. filename) + SpringShared.Echo("Saving " .. tablename .. " on " .. filename) local fileobj = io.open(filename, "w") fileobj:write(tablename .. " = " .. tableinput) fileobj:close() @@ -1169,7 +1169,7 @@ function widget:Shutdown() if i == 0 then return end - Spring.SendCommands("screenshot") + SpringUnsynced.SendCommands("screenshot") EchoStats("", timerPermaStats[anyName], longestName, longestKV, true) local namesBySum = {} for name, stats in pairs(timerPermaStats) do diff --git a/luaui/Widgets/snd_mapmark_ping.lua b/luaui/Widgets/snd_mapmark_ping.lua index 109eb125053..48e48b124bd 100644 --- a/luaui/Widgets/snd_mapmark_ping.lua +++ b/luaui/Widgets/snd_mapmark_ping.lua @@ -27,8 +27,8 @@ end function widget:MapDrawCmd(playerID, cmdType, x, y, z, a, b, c) if cmdType == "point" then - Spring.PlaySoundFile(mapmarkFile, volume * 20, x, y, z, nil, nil, nil, "ui") - Spring.PlaySoundFile(mapmarkFile, volume * 0.3, nil, "ui") -- to make sure it's still somewhat audible when far away + SpringUnsynced.PlaySoundFile(mapmarkFile, volume * 20, x, y, z, nil, nil, nil, "ui") + SpringUnsynced.PlaySoundFile(mapmarkFile, volume * 0.3, nil, "ui") -- to make sure it's still somewhat audible when far away end end diff --git a/luaui/Widgets/snd_notifications.lua b/luaui/Widgets/snd_notifications.lua index 291130c4074..649ef9c5b73 100644 --- a/luaui/Widgets/snd_notifications.lua +++ b/luaui/Widgets/snd_notifications.lua @@ -18,18 +18,18 @@ local mathRandom = math.random local tableSort = table.sort -- Localized Spring API for performance -local spGetUnitPosition = Spring.GetUnitPosition +local spGetUnitPosition = SpringShared.GetUnitPosition local spGetMyTeamID = Spring.GetMyTeamID -local spGetMouseState = Spring.GetMouseState -local spEcho = Spring.Echo -local spGetSpectatingState = Spring.GetSpectatingState +local spGetMouseState = SpringUnsynced.GetMouseState +local spEcho = SpringShared.Echo +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local defaultVoiceSet = "en/cephis" local windFunctions = VFS.Include("common/wind_functions.lua") -local useDefaultVoiceFallback = Spring.GetConfigInt("NotificationsSubstitute", 0) == 1 --false -- when a voiceset has missing file, try to load the default voiceset file instead -local playWelcome = Spring.GetConfigInt("WelcomeMessagePlayed", 0) == 0 +local useDefaultVoiceFallback = SpringUnsynced.GetConfigInt("NotificationsSubstitute", 0) == 1 --false -- when a voiceset has missing file, try to load the default voiceset file instead +local playWelcome = SpringUnsynced.GetConfigInt("WelcomeMessagePlayed", 0) == 0 local playedWelcome = false local silentTime = 0.7 -- silent time between queued notifications @@ -43,8 +43,8 @@ local tutorialPlayLimit = 2 -- display the same tutorial message only this many local updateCommandersFrames = Game.gameSpeed * 5 local victoryConditionAllyID = 999 -if not (spGetSpectatingState() or Spring.IsReplay()) then - victoryConditionAllyID = Spring.GetLocalAllyTeamID() +if not (spGetSpectatingState() or SpringUnsynced.IsReplay()) then + victoryConditionAllyID = SpringUnsynced.GetLocalAllyTeamID() end -------------------------------------------------------------------------------- @@ -52,7 +52,7 @@ end local wavFileLengths = VFS.Include("sounds/sound_file_lengths.lua") VFS.Include("common/wav.lua") -local voiceSet = Spring.GetConfigString("voiceset", defaultVoiceSet) +local voiceSet = SpringUnsynced.GetConfigString("voiceset", defaultVoiceSet) if #VFS.DirList("sounds/voice/" .. voiceSet, "*.wav") == 0 then voiceSet = defaultVoiceSet end @@ -61,12 +61,12 @@ local LastPlay = {} local notification = {} local notificationList = {} local notificationOrder = {} -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local gameframe = spGetGameFrame() local gameover = false local lockPlayerID -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() local soundFolder = string.gsub("sounds/voice/" .. voiceSet .. "/", "\\", "/") local soundEffectsFolder = string.gsub("sounds/voice-soundeffects/", "\\", "/") @@ -260,22 +260,22 @@ local suspendUntilSec = 0 local windNotGood = windFunctions.isWindBad() -local spIsUnitAllied = Spring.IsUnitAllied -local spGetUnitDefID = Spring.GetUnitDefID -local spIsUnitInView = Spring.IsUnitInView -local spGetUnitHealth = Spring.GetUnitHealth +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spGetUnitDefID = SpringShared.GetUnitDefID +local spIsUnitInView = SpringUnsynced.IsUnitInView +local spGetUnitHealth = SpringShared.GetUnitHealth local isIdle = false local lastMouseX, lastMouseY = spGetMouseState() local isSpec = spGetSpectatingState() -local isReplay = Spring.IsReplay() +local isReplay = SpringUnsynced.IsReplay() local myTeamID = spGetMyTeamID() local myPlayerID = Spring.GetMyPlayerID() local myAllyTeamID = Spring.GetMyAllyTeamID() -local myRank = select(9, Spring.GetPlayerInfo(myPlayerID)) +local myRank = select(9, SpringShared.GetPlayerInfo(myPlayerID)) -local spGetTeamResources = Spring.GetTeamResources +local spGetTeamResources = SpringShared.GetTeamResources local e_currentLevel, e_storage, e_pull, e_income, e_expense, e_share, e_sent, e_received = spGetTeamResources(myTeamID, "energy") local m_currentLevel, m_storage, m_pull, m_income, m_expense, m_share, m_sent, m_received = spGetTeamResources(myTeamID, "metal") @@ -381,7 +381,7 @@ for udefID, def in ipairs(UnitDefs) do end local function updateCommanders() - local units = Spring.GetTeamUnits(myTeamID) + local units = SpringShared.GetTeamUnits(myTeamID) for i = 1, #units do local unitID = units[i] local unitDefID = spGetUnitDefID(unitID) @@ -441,7 +441,7 @@ local function applyNotificationRules(notifDef) end local function queueNotification(event, forceplay) - if Spring.GetGameFrame() > 20 or forceplay then + if SpringShared.GetGameFrame() > 20 or forceplay then if not isSpec or (isSpec and lockPlayerID ~= nil) or forceplay then if notificationList[event] and notification[event] then if not LastPlay[event] or (spGetGameFrame() >= LastPlay[event] + (notification[event].delay * 30)) then @@ -568,15 +568,15 @@ function widget:Initialize() local m = #notification[event].voiceFiles > 1 and mathRandom(1, #notification[event].voiceFiles) or 1 local mRare = #notification[event].voiceFilesRare > 1 and mathRandom(1, #notification[event].voiceFilesRare) or 1 if math.random() < 0.05 and notification[event].voiceFilesRare[mRare] then - Spring.PlaySoundFile(notification[event].voiceFilesRare[mRare], globalVolume, "ui") + SpringUnsynced.PlaySoundFile(notification[event].voiceFilesRare[mRare], globalVolume, "ui") elseif notification[event].voiceFiles[m] then - Spring.PlaySoundFile(notification[event].voiceFiles[m], globalVolume, "ui") + SpringUnsynced.PlaySoundFile(notification[event].voiceFiles[m], globalVolume, "ui") else spEcho('notification "' .. event .. '" missing sound file: #' .. m) end end if notification[event].soundEffect then - Spring.PlaySoundFile(soundEffectsFolder .. notification[event].soundEffect .. ".wav", globalVolume, "ui") + SpringUnsynced.PlaySoundFile(soundEffectsFolder .. notification[event].soundEffect .. ".wav", globalVolume, "ui") end if displayMessages and WG["messages"] and notification[event].textID and not notification[event].notext then if not notification[event].customText then @@ -618,9 +618,9 @@ function widget:Initialize() end if not WG.NotificationSoundDefsLoaded then -- To prevent reloads and warning spam when changing/refreshing announcers - Spring.LoadSoundDef("gamedata/soundsVoice.lua") + SpringUnsynced.LoadSoundDef("gamedata/soundsVoice.lua") WG.NotificationSoundDefsLoaded = true - Spring.Echo("Notification Sound Items Loaded") + SpringShared.Echo("Notification Sound Items Loaded") end if Spring.Utilities.Gametype.IsRaptors() and Spring.Utilities.Gametype.IsScavengers() then @@ -659,7 +659,7 @@ function widget:GameFrame(gf) -- idle builder check for unitID, frame in pairs(idleBuilder) do - if Spring.GetUnitTeam(unitID) == myTeamID then + if SpringShared.GetUnitTeam(unitID) == myTeamID then if frame < gf and m_currentLevel > m_storage * 0.5 and e_currentLevel > e_storage * 0.5 then queueNotification("IdleConstructors") idleBuilder[unitID] = nil -- do not repeat @@ -670,7 +670,7 @@ function widget:GameFrame(gf) end -- max units check - local maxUnits, currentUnits = Spring.GetTeamMaxUnits(myTeamID) + local maxUnits, currentUnits = SpringShared.GetTeamMaxUnits(myTeamID) if currentUnits >= maxUnits then queueNotification("MaxUnitsReached") end @@ -727,7 +727,7 @@ function widget:UnitFinished(unitID, unitDefID, unitTeam) end end - if #Spring.GetTeamList(myAllyTeamID) > 1 then + if #SpringShared.GetTeamList(myAllyTeamID) > 1 then if isT2mobile[unitDefID] then queueNotification("Tech2TeamReached") elseif isT3mobile[unitDefID] then @@ -768,7 +768,7 @@ function widget:UnitEnteredLos(unitID, unitTeam) if isMine[udefID] then -- ignore when far away local x, _, z = spGetUnitPosition(unitID) - if #Spring.GetUnitsInCylinder(x, z, 1700, myTeamID) > 0 then + if #SpringShared.GetUnitsInCylinder(x, z, 1700, myTeamID) > 0 then queueNotification("UnitDetected/MinesDetected") end end @@ -785,7 +785,7 @@ function widget:UnitTaken(unitID, unitDefID, unitTeam, newTeam) if isCommander[unitDefID] then commanders[unitID] = select(2, spGetUnitHealth(unitID)) end - local maxUnits, currentUnits = Spring.GetTeamMaxUnits(myTeamID) + local maxUnits, currentUnits = SpringShared.GetTeamMaxUnits(myTeamID) if currentUnits >= maxUnits then queueNotification("MaxUnitsReached") end @@ -797,7 +797,7 @@ function widget:UnitGiven(unitID, unitDefID, unitTeam, oldTeam) if isCommander[unitDefID] then commanders[unitID] = select(2, spGetUnitHealth(unitID)) end - local maxUnits, currentUnits = Spring.GetTeamMaxUnits(myTeamID) + local maxUnits, currentUnits = SpringShared.GetTeamMaxUnits(myTeamID) if currentUnits >= maxUnits then queueNotification("MaxUnitsReached") end @@ -809,7 +809,7 @@ function widget:UnitCreated(unitID, unitDefID, unitTeam) return end if unitTeam == myTeamID then - local maxUnits, currentUnits = Spring.GetTeamMaxUnits(myTeamID) + local maxUnits, currentUnits = SpringShared.GetTeamMaxUnits(myTeamID) if currentUnits >= maxUnits then queueNotification("MaxUnitsReached") end @@ -835,7 +835,7 @@ function widget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer) -- notify when commander gets damaged if commanders[unitID] then local x, y, z = spGetUnitPosition(unitID) - local camX, camY, camZ = Spring.GetCameraPosition() + local camX, camY, camZ = SpringUnsynced.GetCameraPosition() if not spIsUnitInView(unitID) or math.diag(camX - x, camY - y, camZ - z) > 3000 then if not commandersDamages[unitID] then commandersDamages[unitID] = {} @@ -871,13 +871,13 @@ local function playNextSound() local event = soundQueue[1] if not muteWhenIdle or not isIdle or notification[event].tutorial then if spoken and #notification[event].voiceFiles > 0 then - if Spring.GetGameFrame() < 30 then + if SpringShared.GetGameFrame() < 30 then math.randomseed(tonumber(math.ceil(os.clock() * 10))) -- brute force this because early game random seems not very random. end local m = #notification[event].voiceFiles > 1 and mathRandom(1, #notification[event].voiceFiles) or 1 local mRare = #notification[event].voiceFilesRare > 1 and mathRandom(1, #notification[event].voiceFilesRare) or 1 if math.random() < 0.05 and notification[event].voiceFilesRare[mRare] then - Spring.PlaySoundFile(notification[event].voiceFilesRare[mRare], globalVolume, "ui") + SpringUnsynced.PlaySoundFile(notification[event].voiceFilesRare[mRare], globalVolume, "ui") local duration = wavFileLengths[string.sub(notification[event].voiceFilesRare[mRare], 8)] if not duration then duration = ReadWAV(notification[event].voiceFilesRare[mRare]) @@ -885,7 +885,7 @@ local function playNextSound() end nextSoundQueued = sec + (duration or 3) + silentTime elseif notification[event].voiceFiles[m] then - Spring.PlaySoundFile(notification[event].voiceFiles[m], globalVolume, "ui") + SpringUnsynced.PlaySoundFile(notification[event].voiceFiles[m], globalVolume, "ui") local duration = wavFileLengths[string.sub(notification[event].voiceFiles[m], 8)] if not duration then duration = ReadWAV(notification[event].voiceFiles[m]) @@ -897,7 +897,7 @@ local function playNextSound() end end if notification[event].soundEffect then - Spring.PlaySoundFile(soundEffectsFolder .. notification[event].soundEffect .. ".wav", globalVolume, "ui") + SpringUnsynced.PlaySoundFile(soundEffectsFolder .. notification[event].soundEffect .. ".wav", globalVolume, "ui") end if displayMessages and WG["messages"] and notification[event].textID and not notification[event].notext then WG["messages"].addMessage(Spring.I18N(notification[event].textID)) @@ -965,7 +965,7 @@ function widget:Update(dt) end if playWelcome then - Spring.SetConfigInt("WelcomeMessagePlayed", 1) + SpringUnsynced.SetConfigInt("WelcomeMessagePlayed", 1) queueNotification("Welcome", true) playWelcome = false playedWelcome = true diff --git a/luaui/Widgets/snd_notifications_addon_ally_alerts.lua b/luaui/Widgets/snd_notifications_addon_ally_alerts.lua index ed0ad15a643..35bb7e3c5eb 100644 --- a/luaui/Widgets/snd_notifications_addon_ally_alerts.lua +++ b/luaui/Widgets/snd_notifications_addon_ally_alerts.lua @@ -18,9 +18,9 @@ function widget:RecvLuaMsg(msg, playerID) end -- Get local and sender ally team ID and spectator status - local myAllyTeamID = Spring.GetLocalAllyTeamID() - local isSpec = Spring.GetSpectatingState() - local _, _, senderIsSpec, _, senderAllyTeamID = Spring.GetPlayerInfo(playerID, false) + local myAllyTeamID = SpringUnsynced.GetLocalAllyTeamID() + local isSpec = SpringUnsynced.GetSpectatingState() + local _, _, senderIsSpec, _, senderAllyTeamID = SpringShared.GetPlayerInfo(playerID, false) -- Ignore if I am spectator, sender is spectator or sender is not an ally if isSpec or senderIsSpec or (myAllyTeamID ~= senderAllyTeamID) then diff --git a/luaui/Widgets/snd_notifications_addon_playerstatus.lua b/luaui/Widgets/snd_notifications_addon_playerstatus.lua index 80001ed2a0a..d589b6e529c 100644 --- a/luaui/Widgets/snd_notifications_addon_playerstatus.lua +++ b/luaui/Widgets/snd_notifications_addon_playerstatus.lua @@ -10,10 +10,10 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetSpectatingState = Spring.GetSpectatingState -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetLocalAllyTeamID = Spring.GetLocalAllyTeamID -local spGetLocalTeamID = Spring.GetLocalTeamID +local spGetSpectatingState = SpringUnsynced.GetSpectatingState +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetLocalAllyTeamID = SpringUnsynced.GetLocalAllyTeamID +local spGetLocalTeamID = SpringUnsynced.GetLocalTeamID local gameOver = false local lockPlayerID @@ -73,7 +73,7 @@ end UpdateTimer = 0 function widget:Update(dt) UpdateTimer = UpdateTimer + dt - if UpdateTimer >= 1 and not gameOver and Spring.GetGameFrame() > 90 then + if UpdateTimer >= 1 and not gameOver and SpringShared.GetGameFrame() > 90 then UpdateTimer = UpdateTimer - 1 if WG.lockcamera and WG.lockcamera.GetPlayerID ~= nil then lockPlayerID = WG.lockcamera.GetPlayerID() @@ -108,7 +108,7 @@ function widget:Update(dt) end function widget:Initialize() - local players = Spring.GetPlayerList() + local players = SpringShared.GetPlayerList() for i = 1, #players do UpdatePlayerData(players[i]) end diff --git a/luaui/Widgets/snd_notifications_addon_scavraptorstatus.lua b/luaui/Widgets/snd_notifications_addon_scavraptorstatus.lua index 88f099a97d2..fbaa89dbd2e 100644 --- a/luaui/Widgets/snd_notifications_addon_scavraptorstatus.lua +++ b/luaui/Widgets/snd_notifications_addon_scavraptorstatus.lua @@ -22,9 +22,9 @@ function widget:Update(dt) UpdateTimer = UpdateTimer - 1 if Spring.Utilities.Gametype.IsRaptors() then - FinalBossProgress = Spring.GetGameRulesParam("raptorQueenAnger") - FinalBossHealth = Spring.GetGameRulesParam("raptorQueenHealth") - TechProgress = Spring.GetGameRulesParam("raptorTechAnger") + FinalBossProgress = SpringShared.GetGameRulesParam("raptorQueenAnger") + FinalBossHealth = SpringShared.GetGameRulesParam("raptorQueenHealth") + TechProgress = SpringShared.GetGameRulesParam("raptorTechAnger") if TechProgress and TechProgress >= 50 and not PlayedMessages["AntiNukeReminder1"] then WG["notifications"].queueNotification("PvE/AntiNukeReminder") @@ -64,7 +64,7 @@ function widget:Update(dt) if FinalBossIsAlive and FinalBossHealth <= 0 and not PlayedMessages["FinalBossIsDestroyed"] then WG["notifications"].queueNotification("PvE/Raptor_QueenIsDestroyed") PlayedMessages["FinalBossIsDestroyed"] = true - if Spring.GetModOptions().scav_endless then + if SpringShared.GetModOptions().scav_endless then FinalBossIsAlive = false PlayedMessages = {} end @@ -96,9 +96,9 @@ function widget:Update(dt) end elseif Spring.Utilities.Gametype.IsScavengers() then - FinalBossProgress = Spring.GetGameRulesParam("scavBossAnger") - FinalBossHealth = Spring.GetGameRulesParam("scavBossHealth") - TechProgress = Spring.GetGameRulesParam("scavTechAnger") + FinalBossProgress = SpringShared.GetGameRulesParam("scavBossAnger") + FinalBossHealth = SpringShared.GetGameRulesParam("scavBossHealth") + TechProgress = SpringShared.GetGameRulesParam("scavTechAnger") if TechProgress and TechProgress >= 50 and not PlayedMessages["AntiNukeReminder1"] then WG["notifications"].queueNotification("PvE/AntiNukeReminder") @@ -138,7 +138,7 @@ function widget:Update(dt) if FinalBossIsAlive and FinalBossHealth <= 0 and not PlayedMessages["FinalBossIsDestroyed"] then WG["notifications"].queueNotification("PvE/Scav_BossIsDestroyed") PlayedMessages["FinalBossIsDestroyed"] = true - if Spring.GetModOptions().scav_endless then + if SpringShared.GetModOptions().scav_endless then FinalBossIsAlive = false PlayedMessages = {} end diff --git a/luaui/Widgets/snd_unit_finished.lua b/luaui/Widgets/snd_unit_finished.lua index f0f5acd95be..e0ac4ba2c95 100644 --- a/luaui/Widgets/snd_unit_finished.lua +++ b/luaui/Widgets/snd_unit_finished.lua @@ -16,9 +16,9 @@ end -------------------------------------------------------------------------------- local activateSounds = {} -local GetUnitPosition = Spring.GetUnitPosition -local PlaySoundFile = Spring.PlaySoundFile -local configVolume = tonumber(Spring.GetConfigString("snd_volunitreply") or 100) +local GetUnitPosition = SpringShared.GetUnitPosition +local PlaySoundFile = SpringUnsynced.PlaySoundFile +local configVolume = tonumber(SpringUnsynced.GetConfigString("snd_volunitreply") or 100) local volume = ((configVolume or 100) / 100) function widget:Initialize() diff --git a/luaui/Widgets/snd_volume_osd.lua b/luaui/Widgets/snd_volume_osd.lua index 05b58ca343f..57f0af1726f 100644 --- a/luaui/Widgets/snd_volume_osd.lua +++ b/luaui/Widgets/snd_volume_osd.lua @@ -22,7 +22,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -59,7 +59,7 @@ local GL_ONE = GL.ONE local RectRound local function sndVolumeIncreaseHandler(_, _, _, _, isRepeat) - volume = Spring.GetConfigInt("snd_volmaster", 80) + volume = SpringUnsynced.GetConfigInt("snd_volmaster", 80) volume = volume + step if volume < 0 then volume = 0 @@ -67,17 +67,17 @@ local function sndVolumeIncreaseHandler(_, _, _, _, isRepeat) if volume > 200 then volume = 200 end - Spring.SetConfigInt("snd_volmaster", volume) + SpringUnsynced.SetConfigInt("snd_volmaster", volume) --spEcho("Volume = " .. volume) if not isRepeat then - Spring.PlaySoundFile(TEST_SOUND, 1.0, "ui") + SpringUnsynced.PlaySoundFile(TEST_SOUND, 1.0, "ui") end dt = os.clock() return true end local function sndVolumeDecreaseHandler(_, _, _, _, isRepeat) - volume = Spring.GetConfigInt("snd_volmaster", 80) + volume = SpringUnsynced.GetConfigInt("snd_volmaster", 80) volume = volume - step if volume < 0 then volume = 0 @@ -85,17 +85,17 @@ local function sndVolumeDecreaseHandler(_, _, _, _, isRepeat) if volume > 200 then volume = 200 end - Spring.SetConfigInt("snd_volmaster", volume) + SpringUnsynced.SetConfigInt("snd_volmaster", volume) --spEcho("Volume = " .. volume) if not isRepeat then - Spring.PlaySoundFile(TEST_SOUND, 1.0, "ui") + SpringUnsynced.PlaySoundFile(TEST_SOUND, 1.0, "ui") end dt = os.clock() return true end function widget:Initialize() - volume = Spring.GetConfigInt("snd_volmaster", 60) + volume = SpringUnsynced.GetConfigInt("snd_volmaster", 60) widgetHandler:AddAction("snd_volume_increase", sndVolumeIncreaseHandler, nil, "pR") widgetHandler:AddAction("snd_volume_decrease", sndVolumeDecreaseHandler, nil, "pR") diff --git a/luaui/Widgets/stats_damage.lua b/luaui/Widgets/stats_damage.lua index 335db20c027..624be9d3203 100644 --- a/luaui/Widgets/stats_damage.lua +++ b/luaui/Widgets/stats_damage.lua @@ -97,7 +97,7 @@ function RecieveStats(uDID, n, ts, dmg_dealt, dmg_rec, minutes, kills, killed_co end function widget:GameOver() - if not info or Spring.IsReplay() then + if not info or SpringUnsynced.IsReplay() then return end if Spring.Utilities.IsDevMode() then diff --git a/luaui/Widgets/test_DPAT.lua b/luaui/Widgets/test_DPAT.lua index af8f3489e20..ac91e5939cf 100644 --- a/luaui/Widgets/test_DPAT.lua +++ b/luaui/Widgets/test_DPAT.lua @@ -13,8 +13,8 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spEcho = Spring.Echo -local spGetUnitTeam = Spring.GetUnitTeam +local spEcho = SpringShared.Echo +local spGetUnitTeam = SpringShared.GetUnitTeam -- Configurable Parts: local texture = "luaui/images/backgroundtile.png" @@ -46,15 +46,15 @@ local GL_REPLACE = GL.REPLACE local GL_POINTS = GL.POINTS local function AddPrimitiveAtUnit(unitID, unitDefID) - local gf = Spring.GetGameFrame() - unitDefID = unitDefID or Spring.GetUnitDefID(unitID) + local gf = SpringShared.GetGameFrame() + unitDefID = unitDefID or SpringShared.GetUnitDefID(unitID) if unitDefID == nil then return end -- these cant be selected local numVertices = 64 -- default to cornered rectangle local cornersize = 0 - local radius = Spring.GetUnitRadius(unitID) * 2.6 or 64 + local radius = SpringShared.GetUnitRadius(unitID) * 2.6 or 64 local width = radius local length = radius local additionalheight = 0 @@ -109,7 +109,7 @@ function widget:DrawWorldPreUnit() if drawFrame % 100 == 0 then spEcho("selectionVBO.usedElements", selectionVBO.usedElements) end - local disticon = Spring.GetConfigInt("UnitIconDist", 200) -- iconLength = unitIconDist * unitIconDist * 750.0f; + local disticon = SpringUnsynced.GetConfigInt("UnitIconDist", 200) -- iconLength = unitIconDist * unitIconDist * 750.0f; --gl.Culling(false) disticon = disticon * 27 -- should be sqrt(750) but not really glTexture(0, texture) @@ -188,7 +188,7 @@ function widget:Initialize() return end if true then -- FOR TESTING - local units = Spring.GetAllUnits() + local units = SpringShared.GetAllUnits() for _, unitID in ipairs(units) do AddPrimitiveAtUnit(unitID) end diff --git a/luaui/Widgets/test_dpat_minimal_example.lua b/luaui/Widgets/test_dpat_minimal_example.lua index 02157c75b68..6f4c5d28e2c 100644 --- a/luaui/Widgets/test_dpat_minimal_example.lua +++ b/luaui/Widgets/test_dpat_minimal_example.lua @@ -27,15 +27,15 @@ local luaShaderDir = "LuaUI/Include/" local glTexture = gl.Texture local function AddPrimitiveAtUnit(unitID, unitDefID) - local gf = Spring.GetGameFrame() - unitDefID = unitDefID or Spring.GetUnitDefID(unitID) + local gf = SpringShared.GetGameFrame() + unitDefID = unitDefID or SpringShared.GetUnitDefID(unitID) if unitDefID == nil then return end -- these cant be selected local numVertices = 62 -- default to circle local cornersize = 0 - local radius = Spring.GetUnitRadius(unitID) * 2.6 or 64 + local radius = SpringShared.GetUnitRadius(unitID) * 2.6 or 64 local width = radius local length = radius local additionalheight = 2 * radius @@ -47,7 +47,7 @@ local function AddPrimitiveAtUnit(unitID, unitDefID) width, cornersize, additionalheight, -- lengthwidthcornerheight - Spring.GetUnitTeam(unitID), -- teamID + SpringShared.GetUnitTeam(unitID), -- teamID numVertices, -- how many trianges should we make gf, 0, @@ -71,7 +71,7 @@ end function widget:DrawWorldPreUnit() if selectionVBO.usedElements > 0 then - local disticon = 27 * Spring.GetConfigInt("UnitIconDist", 200) -- iconLength = unitIconDist * unitIconDist * 750.0f; + local disticon = 27 * SpringUnsynced.GetConfigInt("UnitIconDist", 200) -- iconLength = unitIconDist * unitIconDist * 750.0f; glTexture(0, texture) selectShader:Activate() selectShader:SetUniform("iconDistance", disticon) @@ -83,7 +83,7 @@ function widget:DrawWorldPreUnit() end function widget:UnitCreated(unitID) - if not Spring.IsUnitAllied(unitID) then + if not SpringUnsynced.IsUnitAllied(unitID) then return end AddPrimitiveAtUnit(unitID) @@ -101,7 +101,7 @@ function widget:Initialize() shaderConfig.HEIGHTOFFSET = 1 selectionVBO, selectShader = InitDrawPrimitiveAtUnit(shaderConfig, "TESTDPAUMinimal") if true then -- FOR TESTING - local units = Spring.GetAllUnits() + local units = SpringShared.GetAllUnits() for _, unitID in ipairs(units) do AddPrimitiveAtUnit(unitID) end diff --git a/luaui/Widgets/tweakdefs_unit_translations.lua b/luaui/Widgets/tweakdefs_unit_translations.lua index 597dc83d059..c1b05a46441 100644 --- a/luaui/Widgets/tweakdefs_unit_translations.lua +++ b/luaui/Widgets/tweakdefs_unit_translations.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end local function updateTranslations() - local currentLanguage = Spring.GetConfigString("language", "en") + local currentLanguage = SpringUnsynced.GetConfigString("language", "en") for unitDefName, unitDef in pairs(UnitDefNames) do --Naming convention for language overrides diff --git a/luaui/Widgets/unit_alt_set_target_type.lua b/luaui/Widgets/unit_alt_set_target_type.lua index 5404422fe93..c1191851c67 100644 --- a/luaui/Widgets/unit_alt_set_target_type.lua +++ b/luaui/Widgets/unit_alt_set_target_type.lua @@ -14,20 +14,20 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame - -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder -local spAreTeamsAllied = Spring.AreTeamsAllied -local spGetUnitTeam = Spring.GetUnitTeam -local spGiveOrderArrayToUnit = Spring.GiveOrderArrayToUnit -local spGetSelectedUnits = Spring.GetSelectedUnits +local spGetGameFrame = SpringShared.GetGameFrame + +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGiveOrderArrayToUnit = SpringSynced.GiveOrderArrayToUnit +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits local spGetMyTeamID = Spring.GetMyTeamID -local spGetActiveCommand = Spring.GetActiveCommand -local spGetMouseState = Spring.GetMouseState -local spTraceScreenRay = Spring.TraceScreenRay -local spGetModKeyState = Spring.GetModKeyState +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetMouseState = SpringUnsynced.GetMouseState +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetModKeyState = SpringUnsynced.GetModKeyState local trackedUnitsToUnitDefID = {} local unitRanges = {} @@ -275,7 +275,7 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOpts) end function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -290,7 +290,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end WG.FindNearestEnemyUnit = FindNearestEnemyUnit diff --git a/luaui/Widgets/unit_area_reclaim_enemy.lua b/luaui/Widgets/unit_area_reclaim_enemy.lua index 8d3f67f3d82..ca55b8b8052 100644 --- a/luaui/Widgets/unit_area_reclaim_enemy.lua +++ b/luaui/Widgets/unit_area_reclaim_enemy.lua @@ -16,22 +16,22 @@ local allyTeam = Spring.GetMyAllyTeamID() -- Speedups -local spGiveOrderToUnitArray = Spring.GiveOrderToUnitArray -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder -local spWorldToScreenCoords = Spring.WorldToScreenCoords -local spTraceScreenRay = Spring.TraceScreenRay -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitAllyTeam = Spring.GetUnitAllyTeam -local spGetUnitCmdDescs = Spring.GetUnitCmdDescs -local spGetUnitPosition = Spring.GetUnitPosition +local spGiveOrderToUnitArray = SpringSynced.GiveOrderToUnitArray +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local spWorldToScreenCoords = SpringUnsynced.WorldToScreenCoords +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitAllyTeam = SpringShared.GetUnitAllyTeam +local spGetUnitCmdDescs = SpringShared.GetUnitCmdDescs +local spGetUnitPosition = SpringShared.GetUnitPosition local reclaimEnemy = Game.reclaimAllowEnemies local CMD_RECLAIM = CMD.RECLAIM function maybeRemoveSelf() - if Spring.GetSpectatingState() and (Spring.GetGameFrame() > 0) then + if SpringUnsynced.GetSpectatingState() and (SpringShared.GetGameFrame() > 0) then widgetHandler:RemoveWidget() end end @@ -45,7 +45,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() then + if SpringUnsynced.IsReplay() then maybeRemoveSelf() end end @@ -72,7 +72,7 @@ function widget:CommandNotify(id, params, options) -- get all enemy units in the area for i = 1, #areaUnits do local unitID = areaUnits[i] - local enemyUnit = not Spring.AreTeamsAllied(Spring.GetUnitTeam(unitID), Spring.GetMyTeamID()) + local enemyUnit = not SpringShared.AreTeamsAllied(SpringShared.GetUnitTeam(unitID), Spring.GetMyTeamID()) if enemyUnit then table.insert(enemyUnits, unitID) end @@ -83,7 +83,7 @@ function widget:CommandNotify(id, params, options) end -- get avg point of selected units - local avgx, avgy, avgz = Spring.GetUnitArrayCentroid(selectedUnits) + local avgx, avgy, avgz = SpringShared.GetUnitArrayCentroid(selectedUnits) -- sort enemyUnits by distance from averagePoint of selected units table.sort(enemyUnits, function(unit1, unit2) local x1, _, z1 = spGetUnitPosition(unit1) @@ -107,7 +107,7 @@ function widget:CommandNotify(id, params, options) -- add the command to all units with reclaim if #newCmds > 0 then - Spring.GiveOrderArrayToUnitArray(selectedUnits, newCmds) + SpringSynced.GiveOrderArrayToUnitArray(selectedUnits, newCmds) return true end end diff --git a/luaui/Widgets/unit_attackMoveNotification.lua b/luaui/Widgets/unit_attackMoveNotification.lua index 2abed533240..37974dfce01 100644 --- a/luaui/Widgets/unit_attackMoveNotification.lua +++ b/luaui/Widgets/unit_attackMoveNotification.lua @@ -17,14 +17,14 @@ local mathRandom = math.random local alarmInterval = 15 --seconds -local spGetLocalTeamID = Spring.GetLocalTeamID -local spPlaySoundFile = Spring.PlaySoundFile -local spEcho = Spring.Echo -local spGetTimer = Spring.GetTimer -local spDiffTimers = Spring.DiffTimers -local spIsUnitInView = Spring.IsUnitInView -local spGetUnitPosition = Spring.GetUnitPosition -local spSetLastMessagePosition = Spring.SetLastMessagePosition +local spGetLocalTeamID = SpringUnsynced.GetLocalTeamID +local spPlaySoundFile = SpringUnsynced.PlaySoundFile +local spEcho = SpringShared.Echo +local spGetTimer = SpringUnsynced.GetTimer +local spDiffTimers = SpringUnsynced.DiffTimers +local spIsUnitInView = SpringUnsynced.IsUnitInView +local spGetUnitPosition = SpringShared.GetUnitPosition +local spSetLastMessagePosition = SpringUnsynced.SetLastMessagePosition local random = mathRandom local lastAlarmTime = nil @@ -50,7 +50,7 @@ local function refreshUnitInfo() end function widget:PlayerChanged(playerID) - if Spring.GetSpectatingState() then + if SpringUnsynced.GetSpectatingState() then widgetHandler:RemoveWidget() end localTeamID = spGetLocalTeamID() @@ -63,7 +63,7 @@ end function widget:Initialize() refreshUnitInfo() - if Spring.IsReplay() or Spring.GetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or SpringShared.GetGameFrame() > 0 then widget:PlayerChanged() end diff --git a/luaui/Widgets/unit_auto_cloak.lua b/luaui/Widgets/unit_auto_cloak.lua index acbc4ab83d5..675934929b3 100644 --- a/luaui/Widgets/unit_auto_cloak.lua +++ b/luaui/Widgets/unit_auto_cloak.lua @@ -42,7 +42,7 @@ unitdefConfigNames = nil local CMD_CLOAK = 37382 local cloak = CMD_CLOAK --just simplified Var local cloakunits = {} -- get UnitID for initial local function -local giveOrderToUnit = Spring.GiveOrderToUnit --optimization +local giveOrderToUnit = SpringSynced.GiveOrderToUnit --optimization local spUnitTeam = Spring.GetMyTeamID --optimization local function cloakDeActive(unitID, unitDefID) --DeActivator of Cloak for all units with clock @@ -72,13 +72,13 @@ local function NewUnit(unitID, unitDefID, unitTeam) --check later if could be re end local function maybeRemoveSelf() - if Spring.GetSpectatingState() then + if SpringUnsynced.GetSpectatingState() then widgetHandler:RemoveWidget() end end function widget:Initialize() - if Spring.IsReplay() or Spring.GetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or SpringShared.GetGameFrame() > 0 then maybeRemoveSelf() end @@ -91,10 +91,10 @@ function widget:Initialize() unitdefConfig[type] = value end - local allUnits = Spring.GetAllUnits() + local allUnits = SpringShared.GetAllUnits() for i = 1, #allUnits do local unitID = allUnits[i] - cloakActive(unitID, Spring.GetUnitDefID(unitID)) + cloakActive(unitID, SpringShared.GetUnitDefID(unitID)) end end diff --git a/luaui/Widgets/unit_auto_group.lua b/luaui/Widgets/unit_auto_group.lua index 97589e866aa..953fb81e52b 100644 --- a/luaui/Widgets/unit_auto_group.lua +++ b/luaui/Widgets/unit_auto_group.lua @@ -18,10 +18,10 @@ end local tableInsert = table.insert -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spGetGameFrame = Spring.GetGameFrame +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID -local spGetTeamUnits = Spring.GetTeamUnits +local spGetTeamUnits = SpringShared.GetTeamUnits include("keysym.h.lua") @@ -84,19 +84,19 @@ local prevHealth = {} local gameStarted -local GetUnitGroup = Spring.GetUnitGroup -local SetUnitGroup = Spring.SetUnitGroup -local GetSelectedUnits = Spring.GetSelectedUnits +local GetUnitGroup = SpringUnsynced.GetUnitGroup +local SetUnitGroup = SpringUnsynced.SetUnitGroup +local GetSelectedUnits = SpringUnsynced.GetSelectedUnits local GetUnitDefID = spGetUnitDefID -local GetUnitHealth = Spring.GetUnitHealth -local GetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt -local GetMouseState = Spring.GetMouseState -local SelectUnitArray = Spring.SelectUnitArray -local TraceScreenRay = Spring.TraceScreenRay -local GetUnitPosition = Spring.GetUnitPosition +local GetUnitHealth = SpringShared.GetUnitHealth +local GetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt +local GetMouseState = SpringUnsynced.GetMouseState +local SelectUnitArray = SpringUnsynced.SelectUnitArray +local TraceScreenRay = SpringUnsynced.TraceScreenRay +local GetUnitPosition = SpringShared.GetUnitPosition local GetGameFrame = spGetGameFrame -local Echo = Spring.Echo -local GetUnitRulesParam = Spring.GetUnitRulesParam +local Echo = SpringShared.Echo +local GetUnitRulesParam = SpringShared.GetUnitRulesParam function widget:GameStart() gameStarted = true @@ -104,7 +104,7 @@ function widget:GameStart() end function widget:PlayerChanged(playerID) - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() return end @@ -303,7 +303,7 @@ function widget:UnitFinished(unitID, unitDefID, unitTeam) finiGroup[unitID] = 1 end - if not immediate and ((builtInPlace[unitID] and Spring.GetUnitCommandCount(unitID) == 0) or builtInFrame) then + if not immediate and ((builtInPlace[unitID] and SpringShared.GetUnitCommandCount(unitID) == 0) or builtInFrame) then local gr = unit2group[unitDefID] if gr ~= nil and GetUnitGroup(unitID) == nil then SetUnitGroup(unitID, gr) diff --git a/luaui/Widgets/unit_autofirstbuildfacing.lua b/luaui/Widgets/unit_autofirstbuildfacing.lua index 9338e71861a..755097d5292 100644 --- a/luaui/Widgets/unit_autofirstbuildfacing.lua +++ b/luaui/Widgets/unit_autofirstbuildfacing.lua @@ -27,12 +27,12 @@ local n = 0 -- Count all units and calculate their barycenter function widget:GameFrame(f) if f == 3 then - if Spring.GetTeamUnitCount(spGetMyTeamID()) and Spring.GetTeamUnitCount(spGetMyTeamID()) > 0 then - local units = Spring.GetTeamUnits(spGetMyTeamID()) + if SpringShared.GetTeamUnitCount(spGetMyTeamID()) and SpringShared.GetTeamUnitCount(spGetMyTeamID()) > 0 then + local units = SpringShared.GetTeamUnits(spGetMyTeamID()) for i = 1, #units do local ux = 0 local uz = 0 - ux, _, uz = Spring.GetUnitPosition(units[i]) + ux, _, uz = SpringShared.GetUnitPosition(units[i]) if ux and uz then x = x + ux z = z + uz @@ -48,7 +48,7 @@ end -- Set buildfacing the first time a building is about to be built function widget:Update() - local _, cmd = Spring.GetActiveCommand() + local _, cmd = SpringUnsynced.GetActiveCommand() if cmd and cmd < 0 then if mathAbs(Game.mapSizeX - 2 * x) > mathAbs(Game.mapSizeZ - 2 * z) then if 2 * x > Game.mapSizeX then @@ -63,7 +63,7 @@ function widget:Update() facing = "south" end end - Spring.SendCommands({ "buildfacing " .. facing }) + SpringUnsynced.SendCommands({ "buildfacing " .. facing }) widget.widgetHandler.RemoveCallIn(widget.widget, "Update") end end diff --git a/luaui/Widgets/unit_builder_priority.lua b/luaui/Widgets/unit_builder_priority.lua index f4c70870198..540a794a4e8 100644 --- a/luaui/Widgets/unit_builder_priority.lua +++ b/luaui/Widgets/unit_builder_priority.lua @@ -16,13 +16,13 @@ end -- Localized Spring API for performance local spGetMyTeamID = Spring.GetMyTeamID -local spEcho = Spring.Echo +local spEcho = SpringShared.Echo local CMD_PRIORITY = GameCMD.PRIORITY -- symbol localization optimization for engine calls -local spGetUnitDefID = Spring.GetUnitDefID -local spGiveOrderToUnit = Spring.GiveOrderToUnit +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit local myTeamID = spGetMyTeamID() @@ -116,13 +116,13 @@ end function widget:PlayerChanged(playerID) myTeamID = spGetMyTeamID() - if Spring.GetSpectatingState() then + if SpringUnsynced.GetSpectatingState() then widgetHandler:RemoveWidget() end end function widget:Initialize() - if Spring.IsReplay() or Spring.GetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or SpringShared.GetGameFrame() > 0 then widget:PlayerChanged() end @@ -149,7 +149,7 @@ function widget:Initialize() toggleCons() end - local myUnits = Spring.GetTeamUnits(myTeamID) + local myUnits = SpringShared.GetTeamUnits(myTeamID) for i = 1, #myUnits do local unitID = myUnits[i] local unitDefID = spGetUnitDefID(unitID) diff --git a/luaui/Widgets/unit_clean_builder_queue.lua b/luaui/Widgets/unit_clean_builder_queue.lua index e667fd1b36a..b7eda4c68ba 100644 --- a/luaui/Widgets/unit_clean_builder_queue.lua +++ b/luaui/Widgets/unit_clean_builder_queue.lua @@ -10,15 +10,15 @@ function widget:GetInfo() } end -local GetUnitCmdDescs = Spring.GetUnitCmdDescs -local GetUnitCommands = Spring.GetUnitCommands -local GiveOrderToUnit = Spring.GiveOrderToUnit -local GetUnitPosition = Spring.GetUnitPosition -local GetUnitDefID = Spring.GetUnitDefID -local GetTeamUnits = Spring.GetTeamUnits +local GetUnitCmdDescs = SpringShared.GetUnitCmdDescs +local GetUnitCommands = SpringShared.GetUnitCommands +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit +local GetUnitPosition = SpringShared.GetUnitPosition +local GetUnitDefID = SpringShared.GetUnitDefID +local GetTeamUnits = SpringShared.GetTeamUnits local GetMyTeamID = Spring.GetMyTeamID -local GetSpectatingState = Spring.GetSpectatingState -local GetUnitsInCylinder = Spring.GetUnitsInCylinder +local GetSpectatingState = SpringUnsynced.GetSpectatingState +local GetUnitsInCylinder = SpringShared.GetUnitsInCylinder local CMD_REMOVE = CMD.REMOVE local CMD_REPEAT = CMD.REPEAT diff --git a/luaui/Widgets/unit_cloak_firestate.lua b/luaui/Widgets/unit_cloak_firestate.lua index 71a919b4ee0..ba374afa488 100644 --- a/luaui/Widgets/unit_cloak_firestate.lua +++ b/luaui/Widgets/unit_cloak_firestate.lua @@ -22,8 +22,8 @@ local spGetMyTeamID = Spring.GetMyTeamID -------------------------------------------------------------------------------- -- Speedups -local GiveOrderToUnit = Spring.GiveOrderToUnit -local GetUnitStates = Spring.GetUnitStates +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit +local GetUnitStates = SpringShared.GetUnitStates local CMD_WANT_CLOAK = GameCMD.WANT_CLOAK -------------------------------------------------------------------------------- @@ -108,7 +108,7 @@ end ------------------------------------------------------------------------------------------------ local function maybeRemoveSelf() - if Spring.GetSpectatingState() and (Spring.GetGameFrame() > 0) or Spring.IsReplay() then + if SpringUnsynced.GetSpectatingState() and (SpringShared.GetGameFrame() > 0) or SpringUnsynced.IsReplay() then widgetHandler:RemoveWidget() end end @@ -116,8 +116,8 @@ end function widget:Initialize() myTeam = spGetMyTeamID() maybeRemoveSelf() - for _, unitID in ipairs(Spring.GetAllUnits()) do - widget:UnitCreated(unitID, Spring.GetUnitDefID(unitID)) + for _, unitID in ipairs(SpringShared.GetAllUnits()) do + widget:UnitCreated(unitID, SpringShared.GetUnitDefID(unitID)) end end diff --git a/luaui/Widgets/unit_debug_alt_set_target_type.lua b/luaui/Widgets/unit_debug_alt_set_target_type.lua index 60a45dd7d81..047f41f7151 100644 --- a/luaui/Widgets/unit_debug_alt_set_target_type.lua +++ b/luaui/Widgets/unit_debug_alt_set_target_type.lua @@ -14,15 +14,15 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGetUnitsInCylinder = Spring.GetUnitsInCylinder -local spAreTeamsAllied = Spring.AreTeamsAllied -local spGetUnitTeam = Spring.GetUnitTeam -local spGiveOrderArrayToUnit = Spring.GiveOrderArrayToUnit -local spGetSelectedUnits = Spring.GetSelectedUnits +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetUnitsInCylinder = SpringShared.GetUnitsInCylinder +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGiveOrderArrayToUnit = SpringSynced.GiveOrderArrayToUnit +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits local trackedUnitsToUnitDefID = {} local unitRanges = {} @@ -38,7 +38,7 @@ local UNIT_RANGE_MULTIPLIER = 1.5 local shouldLog = true local function printf(arg) if shouldLog then - Spring.Echo(arg) + SpringShared.Echo(arg) end end @@ -159,7 +159,7 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOpts) end function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then printf("CAT6: removing self for some reason") widgetHandler:RemoveWidget() end @@ -178,7 +178,7 @@ end function widget:Initialize() printf("CAT6: Init widget") - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end end diff --git a/luaui/Widgets/unit_default_spy_move_cloaked.lua b/luaui/Widgets/unit_default_spy_move_cloaked.lua index 0f63e945a10..f8a4ad8a932 100644 --- a/luaui/Widgets/unit_default_spy_move_cloaked.lua +++ b/luaui/Widgets/unit_default_spy_move_cloaked.lua @@ -13,12 +13,12 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetSelectedUnitsCount = Spring.GetSelectedUnitsCount -local spGetGameFrame = Spring.GetGameFrame +local spGetSelectedUnitsCount = SpringUnsynced.GetSelectedUnitsCount +local spGetGameFrame = SpringShared.GetGameFrame -local spGetSelectedUnitsSorted = Spring.GetSelectedUnitsSorted +local spGetSelectedUnitsSorted = SpringUnsynced.GetSelectedUnitsSorted local spGetMyTeamID = Spring.GetMyTeamID -local spGetUnitStates = Spring.GetUnitStates +local spGetUnitStates = SpringShared.GetUnitStates local idCanBuildCloakMove = {} for unitDefID, unitDef in pairs(UnitDefs) do @@ -33,7 +33,7 @@ local CMD_MOVE = CMD.MOVE local CMD_WANT_CLOAK = GameCMD.WANT_CLOAK local function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -48,7 +48,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end end diff --git a/luaui/Widgets/unit_dgun_stall_assist.lua b/luaui/Widgets/unit_dgun_stall_assist.lua index 0c986249b04..10db05b5516 100644 --- a/luaui/Widgets/unit_dgun_stall_assist.lua +++ b/luaui/Widgets/unit_dgun_stall_assist.lua @@ -13,7 +13,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local watchForTime = 3 --How long to monitor the energy level after the dgun command is given @@ -31,15 +31,15 @@ local gameStarted ---------------------------------------------------------------- -- Speedups ---------------------------------------------------------------- -local spGetActiveCommand = Spring.GetActiveCommand -local spGiveOrderToUnitArray = Spring.GiveOrderToUnitArray -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGetFactoryCommands = Spring.GetFactoryCommands +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGiveOrderToUnitArray = SpringSynced.GiveOrderToUnitArray +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGetFactoryCommands = SpringShared.GetFactoryCommands local spGetMyTeamID = Spring.GetMyTeamID -local spGetTeamResources = Spring.GetTeamResources -local spGetTeamUnits = Spring.GetTeamUnits -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitIsBeingBuilt = Spring.GetUnitIsBeingBuilt +local spGetTeamResources = SpringShared.GetTeamResources +local spGetTeamUnits = SpringShared.GetTeamUnits +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitIsBeingBuilt = SpringShared.GetUnitIsBeingBuilt local CMD_DGUN = CMD.DGUN local CMD_WAIT = CMD.WAIT @@ -52,7 +52,7 @@ local CMD_RECLAIM = CMD.RECLAIM ---------------------------------------------------------------- function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -67,7 +67,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end @@ -85,7 +85,7 @@ function widget:Update(dt) local _, activeCmdID = spGetActiveCommand() if activeCmdID == CMD_DGUN then - local selection = Spring.GetSelectedUnitsCounts() + local selection = SpringUnsynced.GetSelectedUnitsCounts() local stallUnitSelected = false for uDefID, _ in next, selection do diff --git a/luaui/Widgets/unit_factory_assist_fix.lua b/luaui/Widgets/unit_factory_assist_fix.lua index 57d21ccc1fc..8386e059340 100644 --- a/luaui/Widgets/unit_factory_assist_fix.lua +++ b/luaui/Widgets/unit_factory_assist_fix.lua @@ -14,7 +14,7 @@ end -- Localized Spring API for performance local spGetMyTeamID = Spring.GetMyTeamID -local spGetTeamUnits = Spring.GetTeamUnits +local spGetTeamUnits = SpringShared.GetTeamUnits ---------------------------------------------------------------- -- Globals @@ -29,12 +29,12 @@ local isAssistBuilder = {} ---------------------------------------------------------------- -- Speedups ---------------------------------------------------------------- -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spAreTeamsAllied = Spring.AreTeamsAllied -local spGetUnitHealth = Spring.GetUnitHealth -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitIsDead = Spring.GetUnitIsDead +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spAreTeamsAllied = SpringShared.AreTeamsAllied +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitIsDead = SpringShared.GetUnitIsDead local CMD_REPAIR = CMD.REPAIR local CMD_GUARD = CMD.GUARD @@ -95,7 +95,7 @@ end ----- Returns true if the widget was actually removed local function maybeRemoveSelf() - if Spring.GetSpectatingState() and (Spring.GetGameFrame() > 0) or Spring.IsReplay() then + if SpringUnsynced.GetSpectatingState() and (SpringShared.GetGameFrame() > 0) or SpringUnsynced.IsReplay() then widgetHandler:RemoveWidget() return true end diff --git a/luaui/Widgets/unit_factory_quota.lua b/luaui/Widgets/unit_factory_quota.lua index 07731951a21..71dea645c1b 100644 --- a/luaui/Widgets/unit_factory_quota.lua +++ b/luaui/Widgets/unit_factory_quota.lua @@ -42,11 +42,11 @@ end ----- Speed ups ------ local myTeam = spGetMyTeamID() -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetFactoryCommands = Spring.GetFactoryCommands -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitCmdDescs = Spring.GetUnitCmdDescs -local spFindUnitCmdDesc = Spring.FindUnitCmdDesc +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetFactoryCommands = SpringShared.GetFactoryCommands +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitCmdDescs = SpringShared.GetUnitCmdDescs +local spFindUnitCmdDesc = SpringShared.FindUnitCmdDesc local CMD_INSERT = CMD.INSERT local CMD_OPT_ALT = CMD.OPT_ALT @@ -97,10 +97,10 @@ local function isFactoryUsable(factoryID) end local function appendToFactoryQueue(factoryID, unitDefID) - local currentCmdID, targetID = Spring.GetUnitWorkerTask(factoryID) + local currentCmdID, targetID = SpringShared.GetUnitWorkerTask(factoryID) local insertPosition = 1 if targetID then - local _, _, _, _, buildProgress = Spring.GetUnitHealth(targetID) + local _, _, _, _, buildProgress = SpringShared.GetUnitHealth(targetID) if buildProgress < maxBuildProg and metalcosts[-currentCmdID] and (buildProgress * metalcosts[-currentCmdID]) < maxMetal then -- 7.5 % is the most that it is willing to cancel, and maximally 500 metal insertPosition = 0 end @@ -174,7 +174,7 @@ function widget:UnitGiven(unitID, unitDefID, newTeam, oldTeam) end function widget:PlayerChanged(playerID) - if Spring.GetSpectatingState() then + if SpringUnsynced.GetSpectatingState() then widgetHandler:RemoveWidget() end myTeam = spGetMyTeamID() diff --git a/luaui/Widgets/unit_ghostradar_gl4.lua b/luaui/Widgets/unit_ghostradar_gl4.lua index 5176bf7343b..e9c4a18639e 100644 --- a/luaui/Widgets/unit_ghostradar_gl4.lua +++ b/luaui/Widgets/unit_ghostradar_gl4.lua @@ -13,19 +13,19 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local shapeOpacity = 0.5 local addHeight = 8 -- compensate for unit wobbling underground -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spIsUnitInView = Spring.IsUnitInView +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spIsUnitInView = SpringUnsynced.IsUnitInView local unitshapes = {} local dots = {} local spec, specFullView = spGetSpectatingState() -local gaiaTeamID = Spring.GetGaiaTeamID() +local gaiaTeamID = SpringShared.GetGaiaTeamID() local includedUnitDefIDs = {} for unitDefID, unitDef in ipairs(UnitDefs) do @@ -177,7 +177,7 @@ function widget:GetConfigData() end function widget:SetConfigData(data) - if Spring.GetGameFrame() > 0 and data.dots ~= nil then + if SpringShared.GetGameFrame() > 0 and data.dots ~= nil then dots = data.dots end end diff --git a/luaui/Widgets/unit_ghostsite_gl4.lua b/luaui/Widgets/unit_ghostsite_gl4.lua index f6d998e5216..018aa6b697e 100644 --- a/luaui/Widgets/unit_ghostsite_gl4.lua +++ b/luaui/Widgets/unit_ghostsite_gl4.lua @@ -13,17 +13,17 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetSpectatingState = Spring.GetSpectatingState +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local shapeOpacity = 0.15 local highlightAmount = 0.11 local updateRate = 1 -local spGetUnitDefID = Spring.GetUnitDefID -local spIsUnitAllied = Spring.IsUnitAllied -local spGetUnitDirection = Spring.GetUnitDirection -local spGetUnitBasePosition = Spring.GetUnitBasePosition -local spGetPositionLosState = Spring.GetPositionLosState +local spGetUnitDefID = SpringShared.GetUnitDefID +local spIsUnitAllied = SpringUnsynced.IsUnitAllied +local spGetUnitDirection = SpringShared.GetUnitDirection +local spGetUnitBasePosition = SpringShared.GetUnitBasePosition +local spGetPositionLosState = SpringShared.GetPositionLosState local math_deg = math.deg local math_atan2 = math.atan2 local math_rad = math.rad @@ -67,7 +67,7 @@ function widget:UnitEnteredLos(unitID, teamID) return end local unitDefID = spGetUnitDefID(unitID) - if includedUnitDefIDs[unitDefID] and Spring.GetUnitIsBeingBuilt(unitID) then + if includedUnitDefIDs[unitDefID] and SpringShared.GetUnitIsBeingBuilt(unitID) then local x, y, z = spGetUnitBasePosition(unitID) local dx, _, dz = spGetUnitDirection(unitID) local angle = math_deg(math_atan2(dx, dz)) @@ -87,7 +87,7 @@ local function updateGhostSites() for unitID, site in pairs(ghostSites) do if not unitshapes[unitID] then local _, inLos, _ = spGetPositionLosState(site.x, site.y, site.z) - if inLos and not Spring.GetUnitIsBeingBuilt(unitID) then + if inLos and not SpringShared.GetUnitIsBeingBuilt(unitID) then removeUnitShape(unitID) ghostSites[unitID] = nil end @@ -121,8 +121,8 @@ end -- remove ghostsites for dead allyteams function widget:TeamDied(teamID) -- Check if the entire allyteam is dead before removing ghost sites - local allyTeamID = select(6, Spring.GetTeamInfo(teamID)) - local allyTeamList = Spring.GetTeamList(allyTeamID) + local allyTeamID = select(6, SpringShared.GetTeamInfo(teamID)) + local allyTeamList = SpringShared.GetTeamList(allyTeamID) if not allyTeamList then return end @@ -131,7 +131,7 @@ function widget:TeamDied(teamID) local allyTeamDead = true for _, checkTeamID in ipairs(allyTeamList) do -- Check if team is still alive (not dead) - if checkTeamID ~= teamID and not select(3, Spring.GetTeamInfo(checkTeamID)) then + if checkTeamID ~= teamID and not select(3, SpringShared.GetTeamInfo(checkTeamID)) then allyTeamDead = false break end @@ -140,7 +140,7 @@ function widget:TeamDied(teamID) -- Only remove ghost sites if the entire allyteam is dead if allyTeamDead then for unitID, site in pairs(ghostSites) do - if select(6, Spring.GetTeamInfo(site.teamID)) == allyTeamID then + if select(6, SpringShared.GetTeamInfo(site.teamID)) == allyTeamID then removeUnitShape(unitID) ghostSites[unitID] = nil end @@ -175,7 +175,7 @@ function widget:GetConfigData() end function widget:SetConfigData(data) - if Spring.GetGameFrame() > 0 and data.ghostSites ~= nil then + if SpringShared.GetGameFrame() > 0 and data.ghostSites ~= nil then ghostSites = data.ghostSites end end diff --git a/luaui/Widgets/unit_hold_position.lua b/luaui/Widgets/unit_hold_position.lua index c18722c67c8..03ab8b2d2b8 100644 --- a/luaui/Widgets/unit_hold_position.lua +++ b/luaui/Widgets/unit_hold_position.lua @@ -28,7 +28,7 @@ end local function setToHoldPos(unitID, unitDefID, unitTeam) if unitTeam == myTeamID then if not isAir[unitDefID] then - Spring.GiveOrderToUnit(unitID, CMD.MOVE_STATE, { 0 }, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.MOVE_STATE, { 0 }, 0) end end end @@ -48,7 +48,7 @@ end --------------------------------------------------------------- local function maybeRemoveSelf() - if Spring.IsReplay() or Spring.GetSpectatingState() then + if SpringUnsynced.IsReplay() or SpringUnsynced.GetSpectatingState() then widgetHandler.RemoveWidget() end end diff --git a/luaui/Widgets/unit_idle_guard.lua b/luaui/Widgets/unit_idle_guard.lua index 7d800b8d10e..71b6aa0a43d 100644 --- a/luaui/Widgets/unit_idle_guard.lua +++ b/luaui/Widgets/unit_idle_guard.lua @@ -15,9 +15,9 @@ end local CMD_GUARD = CMD.GUARD local OPT_SHIFT = CMD.OPT_SHIFT local spGetMyTeamID = Spring.GetMyTeamID -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitsInSphere = Spring.GetUnitsInSphere -local spGetUnitDefID = Spring.GetUnitDefID +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitsInSphere = SpringShared.GetUnitsInSphere +local spGetUnitDefID = SpringShared.GetUnitDefID local validGuardingBuilders = {} for unitDefID, ud in pairs(UnitDefs) do validGuardingBuilders[unitDefID] = (ud.isBuilder and ud.canAssist and ud.canMove and not ud.isFactory) @@ -34,7 +34,7 @@ function widget:UnitCmdDone(unitID, unitDefID, unitTeam, cmdID, cmdParams, _, _) if unitTeam ~= spGetMyTeamID() then return end - if Spring.GetUnitCommandCount(unitID) > 0 then + if SpringShared.GetUnitCommandCount(unitID) > 0 then return end diff --git a/luaui/Widgets/unit_immobile_builder.lua b/luaui/Widgets/unit_immobile_builder.lua index 27a6578e415..cbb2eaa9314 100644 --- a/luaui/Widgets/unit_immobile_builder.lua +++ b/luaui/Widgets/unit_immobile_builder.lua @@ -13,17 +13,17 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local CMD_MOVE_STATE = CMD.MOVE_STATE local CMD_FIGHT = CMD.FIGHT local spGetMyTeamID = Spring.GetMyTeamID -local spGetTeamUnits = Spring.GetTeamUnits -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitPosition = Spring.GetUnitPosition -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand +local spGetTeamUnits = SpringShared.GetTeamUnits +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand local halfMapSizeX = Game.mapSizeX / 2 local halfMapSizeZ = Game.mapSizeZ / 2 @@ -61,7 +61,7 @@ local function setupUnit(unitID) end local function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -77,7 +77,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end for _, unitID in ipairs(spGetTeamUnits(spGetMyTeamID())) do diff --git a/luaui/Widgets/unit_load_own_moving.lua b/luaui/Widgets/unit_load_own_moving.lua index dd9269d505e..94746b3b6d7 100644 --- a/luaui/Widgets/unit_load_own_moving.lua +++ b/luaui/Widgets/unit_load_own_moving.lua @@ -15,7 +15,7 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame ------------------------------------------------------------------- -- Globals @@ -33,11 +33,11 @@ end -- Speedups ------------------------------------------------------------------- local spGetMyTeamID = Spring.GetMyTeamID -local spGetUnitTeam = Spring.GetUnitTeam -local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetUnitSeparation = Spring.GetUnitSeparation -local spGetUnitVelocity = Spring.GetUnitVelocity +local spGetUnitTeam = SpringShared.GetUnitTeam +local spGetUnitCurrentCommand = SpringShared.GetUnitCurrentCommand +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetUnitSeparation = SpringShared.GetUnitSeparation +local spGetUnitVelocity = SpringShared.GetUnitVelocity local CMD_INSERT = CMD.INSERT local CMD_LOAD_UNITS = CMD.LOAD_UNITS @@ -114,7 +114,7 @@ function widget:UnitTaken(uID) end function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -129,7 +129,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end end diff --git a/luaui/Widgets/unit_loop_select.lua b/luaui/Widgets/unit_loop_select.lua index 503ca2d97a3..0374a6a84da 100644 --- a/luaui/Widgets/unit_loop_select.lua +++ b/luaui/Widgets/unit_loop_select.lua @@ -45,15 +45,15 @@ local glLineWidth = gl.LineWidth local glVertex = gl.Vertex local glBeginEnd = gl.BeginEnd -local spGetMouseState = Spring.GetMouseState -local spGetActiveCommand = Spring.GetActiveCommand -local spGetSpecState = Spring.GetSpectatingState +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetSpecState = SpringUnsynced.GetSpectatingState local spGetMyTeamID = Spring.GetMyTeamID -local spGetVisibleUnits = Spring.GetVisibleUnits -local spGetUnitPos = Spring.GetUnitPosition -local spTraceScreenRay = Spring.TraceScreenRay -local spGetSelUnits = Spring.GetSelectedUnits -local spSelUnitArray = Spring.SelectUnitArray +local spGetVisibleUnits = SpringUnsynced.GetVisibleUnits +local spGetUnitPos = SpringShared.GetUnitPosition +local spTraceScreenRay = SpringUnsynced.TraceScreenRay +local spGetSelUnits = SpringUnsynced.GetSelectedUnits +local spSelUnitArray = SpringUnsynced.SelectUnitArray local tremove = table.remove diff --git a/luaui/Widgets/unit_only_fighters_patrol.lua b/luaui/Widgets/unit_only_fighters_patrol.lua index 8c0d9a49af5..2187fcf9bc5 100644 --- a/luaui/Widgets/unit_only_fighters_patrol.lua +++ b/luaui/Widgets/unit_only_fighters_patrol.lua @@ -27,12 +27,12 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local spGetMyTeamID = Spring.GetMyTeamID local stop_builders = true -- Whever to stop builders or not. Set to true if you dont use factory guard widget. -local GetUnitCommands = Spring.GetUnitCommands +local GetUnitCommands = SpringShared.GetUnitCommands local myTeamID = spGetMyTeamID() local gameStarted @@ -84,12 +84,12 @@ function widget:UnitFromFactory(unitID, unitDefID, unitTeam, factID, factDefID, return end if MustStop(unitID, unitDefID) then - Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) + SpringSynced.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) end end function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -105,7 +105,7 @@ function widget:PlayerChanged(playerID) end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end end diff --git a/luaui/Widgets/unit_set_fighters_fly.lua b/luaui/Widgets/unit_set_fighters_fly.lua index 466de1cb281..5e4055218aa 100644 --- a/luaui/Widgets/unit_set_fighters_fly.lua +++ b/luaui/Widgets/unit_set_fighters_fly.lua @@ -22,9 +22,9 @@ local spGetMyTeamID = Spring.GetMyTeamID -------------------------------------------------------------------------------- -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spGetTeamUnits = Spring.GetTeamUnits -local spGetUnitDefID = Spring.GetUnitDefID +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spGetTeamUnits = SpringShared.GetTeamUnits +local spGetUnitDefID = SpringShared.GetUnitDefID local cmdFly = 145 local myTeamID = spGetMyTeamID() @@ -57,13 +57,13 @@ end function widget:PlayerChanged(playerID) myTeamID = spGetMyTeamID() - if Spring.GetSpectatingState() then + if SpringUnsynced.GetSpectatingState() then widgetHandler:RemoveWidget() end end function widget:Initialize() - if Spring.IsReplay() or Spring.GetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or SpringShared.GetGameFrame() > 0 then widget:PlayerChanged() end for _, unitID in ipairs(spGetTeamUnits(myTeamID)) do -- init existing labs diff --git a/luaui/Widgets/unit_share_tracker.lua b/luaui/Widgets/unit_share_tracker.lua index 34c79f278a9..f77df489465 100644 --- a/luaui/Widgets/unit_share_tracker.lua +++ b/luaui/Widgets/unit_share_tracker.lua @@ -15,18 +15,18 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetUnitPosition = Spring.GetUnitPosition -local spGetViewGeometry = Spring.GetViewGeometry -local spGetPlayerInfo = Spring.GetPlayerInfo -local spGetTeamColor = Spring.GetTeamColor +local spGetUnitPosition = SpringShared.GetUnitPosition +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetPlayerInfo = SpringShared.GetPlayerInfo +local spGetTeamColor = SpringUnsynced.GetTeamColor local spGetMyTeamID = Spring.GetMyTeamID local spGetMyPlayerID = Spring.GetMyPlayerID -local spGetUnitHealth = Spring.GetUnitHealth -local spGetUnitRulesParam = Spring.GetUnitRulesParam -local spEcho = Spring.Echo -local spPlaySoundFile = Spring.PlaySoundFile +local spGetUnitHealth = SpringShared.GetUnitHealth +local spGetUnitRulesParam = SpringShared.GetUnitRulesParam +local spEcho = SpringShared.Echo +local spPlaySoundFile = SpringUnsynced.PlaySoundFile local spI18N = Spring.I18N -local spWorldToScreenCoords = Spring.WorldToScreenCoords +local spWorldToScreenCoords = SpringUnsynced.WorldToScreenCoords -- Localized GL functions local glColor = gl.Color diff --git a/luaui/Widgets/unit_smart_area_reclaim.lua b/luaui/Widgets/unit_smart_area_reclaim.lua index c53e374a610..53378282ca4 100644 --- a/luaui/Widgets/unit_smart_area_reclaim.lua +++ b/luaui/Widgets/unit_smart_area_reclaim.lua @@ -26,22 +26,22 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetGameFrame = Spring.GetGameFrame +local spGetGameFrame = SpringShared.GetGameFrame local maxOrdersCheck = 100 -- max amount of orders to check for duplicate orders on units local maxReclaimOrders = 1000 -- max amount of orders to issue at once local maxUnits = Game.maxUnits -local GetSelectedUnits = Spring.GetSelectedUnits -local GetUnitDefID = Spring.GetUnitDefID -local GetUnitCommands = Spring.GetUnitCommands -local GetUnitPosition = Spring.GetUnitPosition -local GetFeaturePosition = Spring.GetFeaturePosition -local GetFeatureResources = Spring.GetFeatureResources -local GiveOrderToUnit = Spring.GiveOrderToUnit +local GetSelectedUnits = SpringUnsynced.GetSelectedUnits +local GetUnitDefID = SpringShared.GetUnitDefID +local GetUnitCommands = SpringShared.GetUnitCommands +local GetUnitPosition = SpringShared.GetUnitPosition +local GetFeaturePosition = SpringShared.GetFeaturePosition +local GetFeatureResources = SpringShared.GetFeatureResources +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit -local WorldToScreenCoords = Spring.WorldToScreenCoords -local TraceScreenRay = Spring.TraceScreenRay +local WorldToScreenCoords = SpringUnsynced.WorldToScreenCoords +local TraceScreenRay = SpringUnsynced.TraceScreenRay local sort = table.sort @@ -70,7 +70,7 @@ for udefID, def in ipairs(UnitDefs) do end local function maybeRemoveSelf() - if Spring.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then + if SpringUnsynced.GetSpectatingState() and (spGetGameFrame() > 0 or gameStarted) then widgetHandler:RemoveWidget() end end @@ -85,7 +85,7 @@ function widget:PlayerChanged() end function widget:Initialize() - if Spring.IsReplay() or spGetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or spGetGameFrame() > 0 then maybeRemoveSelf() end end @@ -222,7 +222,7 @@ function widget:CommandNotify(id, params, options) local x, y, z, r = params[1], params[2], params[3], params[4] if r > mapSize / 4 then - Spring.Log(widget.GetInfo().name, LOG.WARNING, "Smart reclaim area is too large, limiting size") + SpringShared.Log(widget.GetInfo().name, LOG.WARNING, "Smart reclaim area is too large, limiting size") r = math.floor(mapSize / 4) end @@ -233,7 +233,7 @@ function widget:CommandNotify(id, params, options) return false end - local commandHeight = Spring.GetGroundHeight(x, z) + local commandHeight = SpringShared.GetGroundHeight(x, z) local mobiles, stationaries = {}, {} local mobileb, stationaryb = false, false @@ -277,7 +277,7 @@ function widget:CommandNotify(id, params, options) local retw, rmtw, retg, rmtg = {}, {}, {}, {} -- Sort features by above water, below water, metal value, energy value - local features = Spring.GetFeaturesInCylinder(x, z, r) + local features = SpringShared.GetFeaturesInCylinder(x, z, r) for i = 1, #features, 1 do local featureID = features[i] local _, featY, _ = GetFeaturePosition(featureID) @@ -336,7 +336,7 @@ function widget:CommandNotify(id, params, options) end end if mListCount > maxReclaimOrders then - Spring.Log(widget:GetInfo().name, LOG.WARNING, "Command count exceeded, feature selection may be incomplete") + SpringShared.Log(widget:GetInfo().name, LOG.WARNING, "Command count exceeded, feature selection may be incomplete") break end end diff --git a/luaui/Widgets/unit_smart_select.lua b/luaui/Widgets/unit_smart_select.lua index 79ecaa9edef..dc09ea9ae96 100644 --- a/luaui/Widgets/unit_smart_select.lua +++ b/luaui/Widgets/unit_smart_select.lua @@ -13,10 +13,10 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetSelectedUnits = Spring.GetSelectedUnits +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits local spGetMyTeamID = Spring.GetMyTeamID -local spGetViewGeometry = Spring.GetViewGeometry -local spGetSpectatingState = Spring.GetSpectatingState +local spGetViewGeometry = SpringUnsynced.GetViewGeometry +local spGetSpectatingState = SpringUnsynced.GetSpectatingState local minimapToWorld = VFS.Include("luaui/Include/minimap_utils.lua").minimapToWorld local selectApi = VFS.Include("luaui/Include/select_api.lua") @@ -51,25 +51,25 @@ local lastMouseSelection = {} local lastMouseSelectionCount = 0 local externalSelectionReference = {} -- Track initial selection for external (PIP) box drags -local spGetMouseState = Spring.GetMouseState -local spGetModKeyState = Spring.GetModKeyState -local spGetSelectionBox = Spring.GetSelectionBox +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetModKeyState = SpringUnsynced.GetModKeyState +local spGetSelectionBox = SpringUnsynced.GetSelectionBox -local spGetUnitCommandCount = Spring.GetUnitCommandCount -local spIsGodModeEnabled = Spring.IsGodModeEnabled +local spGetUnitCommandCount = SpringShared.GetUnitCommandCount +local spIsGodModeEnabled = SpringShared.IsGodModeEnabled -local spGetUnitsInScreenRectangle = Spring.GetUnitsInScreenRectangle -local spGetUnitsInRectangle = Spring.GetUnitsInRectangle -local spSelectUnitArray = Spring.SelectUnitArray -local spGetActiveCommand = Spring.GetActiveCommand -local spGetUnitTeam = Spring.GetUnitTeam +local spGetUnitsInScreenRectangle = SpringUnsynced.GetUnitsInScreenRectangle +local spGetUnitsInRectangle = SpringShared.GetUnitsInRectangle +local spSelectUnitArray = SpringUnsynced.SelectUnitArray +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetUnitTeam = SpringShared.GetUnitTeam -local spIsAboveMiniMap = Spring.IsAboveMiniMap +local spIsAboveMiniMap = SpringUnsynced.IsAboveMiniMap -local spGetUnitDefID = Spring.GetUnitDefID -local spGetUnitNoSelect = Spring.GetUnitNoSelect +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetUnitNoSelect = SpringUnsynced.GetUnitNoSelect -local GaiaTeamID = Spring.GetGaiaTeamID() +local GaiaTeamID = SpringShared.GetGaiaTeamID() local selectedUnits = spGetSelectedUnits() local spec = spGetSpectatingState() @@ -173,7 +173,7 @@ local function handleClearCustomFilter(_, _, _) end function widget:ViewResize() - dualScreen = Spring.GetMiniMapDualScreen() + dualScreen = SpringUnsynced.GetMiniMapDualScreen() _, _, _, vpy = spGetViewGeometry() end diff --git a/luaui/Widgets/unit_stateprefs.lua b/luaui/Widgets/unit_stateprefs.lua index b88aeba0bca..7713418e467 100644 --- a/luaui/Widgets/unit_stateprefs.lua +++ b/luaui/Widgets/unit_stateprefs.lua @@ -16,9 +16,9 @@ function widget:GetInfo() end -- Localized Spring API for performance -local spGetUnitDefID = Spring.GetUnitDefID -local spGetSelectedUnits = Spring.GetSelectedUnits -local spEcho = Spring.Echo +local spGetUnitDefID = SpringShared.GetUnitDefID +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spEcho = SpringShared.Echo --[[------------------------------------------------------------------------------ @@ -81,7 +81,7 @@ local function GetCmdOpts(alt, ctrl, meta, shift, right) end function widget:PlayerChanged(playerID) - if Spring.GetSpectatingState() then + if SpringUnsynced.GetSpectatingState() then widget:GameOver() end end @@ -91,7 +91,7 @@ function widget:Initialize() for i, v in pairs(unitArray) do unitSet[i] = v end - if Spring.IsReplay() then + if SpringUnsynced.IsReplay() then widget:GameOver() end @@ -132,7 +132,7 @@ function doClearUnit() unitSet[name] = {} spEcho("All state prefs removed for unit: " .. name) end - Spring.PlaySoundFile(clearSound, 0.6, "ui") + SpringUnsynced.PlaySoundFile(clearSound, 0.6, "ui") saveStatePrefs() end @@ -141,8 +141,8 @@ function widget:CommandNotify(cmdID, cmdParams, cmdOpts) return false end - local index = Spring.GetCmdDescIndex(cmdID) - local command = Spring.GetActiveCmdDesc(index) + local index = SpringUnsynced.GetCmdDescIndex(cmdID) + local command = SpringUnsynced.GetActiveCmdDesc(index) -- need to filter only state commands! if type(command) ~= "table" or command.type ~= CMDTYPE_ICON_MODE then return @@ -178,7 +178,7 @@ function widget:UnitFinished(unitID, unitDefID, unitTeam) if cmdID == 115 then return end -- we're skipping "repeat" command here for now - local success = Spring.GiveOrderToUnit(unitID, cmdID, { cmdParam }, cmdOpts) + local success = SpringSynced.GiveOrderToUnit(unitID, cmdID, { cmdParam }, cmdOpts) --spEcho("".. name .. ", " .. tostring(cmdID) .. ", " .. tostring(cmdParam) .. " success: ".. tostring(success)) end end diff --git a/luaui/Widgets/unit_transport_ai.lua b/luaui/Widgets/unit_transport_ai.lua index 2de7e773ec2..2640657a5e6 100644 --- a/luaui/Widgets/unit_transport_ai.lua +++ b/luaui/Widgets/unit_transport_ai.lua @@ -41,17 +41,17 @@ local ST_STOPPED = 3 -- unit is enroute from factory but stopped local timer = 0 local myTeamID -local GetUnitPosition = Spring.GetUnitPosition -local GetUnitDefID = Spring.GetUnitDefID -local GetPlayerInfo = Spring.GetPlayerInfo -local GetUnitCommands = Spring.GetUnitCommands -local GetUnitSeparation = Spring.GetUnitSeparation -local GiveOrderToUnit = Spring.GiveOrderToUnit -local GetUnitDefDimensions = Spring.GetUnitDefDimensions -local GetTeamUnits = Spring.GetTeamUnits -local GetSelectedUnits = Spring.GetSelectedUnits -local GetUnitIsTransporting = Spring.GetUnitIsTransporting -local GetGroundHeight = Spring.GetGroundHeight +local GetUnitPosition = SpringShared.GetUnitPosition +local GetUnitDefID = SpringShared.GetUnitDefID +local GetPlayerInfo = SpringShared.GetPlayerInfo +local GetUnitCommands = SpringShared.GetUnitCommands +local GetUnitSeparation = SpringShared.GetUnitSeparation +local GiveOrderToUnit = SpringSynced.GiveOrderToUnit +local GetUnitDefDimensions = SpringShared.GetUnitDefDimensions +local GetTeamUnits = SpringShared.GetTeamUnits +local GetSelectedUnits = SpringUnsynced.GetSelectedUnits +local GetUnitIsTransporting = SpringShared.GetUnitIsTransporting +local GetGroundHeight = SpringShared.GetGroundHeight local math_sqrt = math.sqrt local isFactory = {} @@ -174,13 +174,13 @@ function AddToPick(transportID, unitID, stopped, fact) end function widget:PlayerChanged(playerID) - if Spring.GetSpectatingState() then + if SpringUnsynced.GetSpectatingState() then widgetHandler:RemoveWidget() end end function widget:Initialize() - if Spring.IsReplay() or Spring.GetGameFrame() > 0 then + if SpringUnsynced.IsReplay() or SpringShared.GetGameFrame() > 0 then widget:PlayerChanged() end @@ -481,7 +481,7 @@ function widget:UnitUnloaded(unitID, unitDefID, teamID, transportID) GiveOrderToUnit(unitID, x[1], x[2], x[3]) end storedQueue[unitID] = nil - local cmdID = Spring.GetUnitCurrentCommand(unitID, 1) --GetUnitCommands(unitID,2) -- not sure if bug or that this old code actually meant to get the 2nd cmd in queue + local cmdID = SpringShared.GetUnitCurrentCommand(unitID, 1) --GetUnitCommands(unitID,2) -- not sure if bug or that this old code actually meant to get the 2nd cmd in queue if cmdID and cmdID == CMD.WAIT then GiveOrderToUnit(unitID, CMD.WAIT, {}, 0) -- workaround: clears wait order if STOP fails to do so end diff --git a/luaui/Widgets/unit_waypoint_dragger_2.lua b/luaui/Widgets/unit_waypoint_dragger_2.lua index c32595d996a..6045d99c9ff 100644 --- a/luaui/Widgets/unit_waypoint_dragger_2.lua +++ b/luaui/Widgets/unit_waypoint_dragger_2.lua @@ -12,17 +12,17 @@ function widget:GetInfo() } end -local spGetActiveCommand = Spring.GetActiveCommand -local spGetGameSeconds = Spring.GetGameSeconds -local spGetSelectedUnits = Spring.GetSelectedUnits -local spGetUnitCommands = Spring.GetUnitCommands -local spGetMouseState = Spring.GetMouseState -local spGetModKeyState = Spring.GetModKeyState -local spGiveOrderToUnit = Spring.GiveOrderToUnit -local spIsAboveMiniMap = Spring.IsAboveMiniMap - -local spWorldToScreenCoords = Spring.WorldToScreenCoords -local spTraceScreenRay = Spring.TraceScreenRay +local spGetActiveCommand = SpringUnsynced.GetActiveCommand +local spGetGameSeconds = SpringShared.GetGameSeconds +local spGetSelectedUnits = SpringUnsynced.GetSelectedUnits +local spGetUnitCommands = SpringShared.GetUnitCommands +local spGetMouseState = SpringUnsynced.GetMouseState +local spGetModKeyState = SpringUnsynced.GetModKeyState +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit +local spIsAboveMiniMap = SpringUnsynced.IsAboveMiniMap + +local spWorldToScreenCoords = SpringUnsynced.WorldToScreenCoords +local spTraceScreenRay = SpringUnsynced.TraceScreenRay local floor = math.floor diff --git a/luaui/Widgets/widget_selector.lua b/luaui/Widgets/widget_selector.lua index 2a7f7e178c4..52f106753b4 100644 --- a/luaui/Widgets/widget_selector.lua +++ b/luaui/Widgets/widget_selector.lua @@ -37,9 +37,9 @@ local mathMax = math.max local mathMin = math.min -- Localized Spring API for performance -local spGetMouseState = Spring.GetMouseState -local spEcho = Spring.Echo -local spGetViewGeometry = Spring.GetViewGeometry +local spGetMouseState = SpringUnsynced.GetMouseState +local spEcho = SpringShared.Echo +local spGetViewGeometry = SpringUnsynced.GetViewGeometry ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- @@ -73,14 +73,14 @@ local fontSize = 14.25 local fontSpace = 8.5 local yStep = fontSize + fontSpace -local fontfile = "fonts/" .. Spring.GetConfigString("bar_font", "Poppins-Regular.otf") +local fontfile = "fonts/" .. SpringUnsynced.GetConfigString("bar_font", "Poppins-Regular.otf") local vsx, vsy = spGetViewGeometry() local fontfileScale = (0.5 + (vsx * vsy / 5700000)) local fontfileSize = 36 local fontfileOutlineSize = 6 local fontfileOutlineStrength = 1.3 local font = gl.LoadFont(fontfile, fontfileSize * fontfileScale, fontfileOutlineSize * fontfileScale, fontfileOutlineStrength) -local fontfile2 = "fonts/" .. Spring.GetConfigString("bar_font2", "Exo2-SemiBold.otf") +local fontfile2 = "fonts/" .. SpringUnsynced.GetConfigString("bar_font2", "Exo2-SemiBold.otf") local font2 = gl.LoadFont(fontfile2, fontfileSize * fontfileScale, fontfileOutlineSize * fontfileScale, fontfileOutlineStrength) local bgPadding = 4.5 @@ -121,7 +121,7 @@ local dlistGuishader, dlistGuishader2, lastStart local widgetScale = (vsy / 1080) local allowuserwidgets = true -if not Spring.GetModOptions().allowuserwidgets and not Spring.IsReplay() then +if not SpringShared.GetModOptions().allowuserwidgets and not SpringUnsynced.IsReplay() then allowuserwidgets = false buttons[3] = "" end @@ -153,7 +153,7 @@ function widget:RecvLuaMsg(msg, playerID) end function widget:TextInput(char) -- if it isnt working: chobby probably hijacked it - if not chobbyInterface and not Spring.IsGUIHidden() and showTextInput and show then + if not chobbyInterface and not SpringUnsynced.IsGUIHidden() and showTextInput and show then if inputTextInsertActive then inputText = utf8.sub(inputText, 1, inputTextPosition) .. char .. utf8.sub(inputText, inputTextPosition + 2) if inputTextPosition <= utf8.len(inputText) then @@ -193,7 +193,7 @@ end local function cancelChatInput() clearChatInput() - Spring.SDLStopTextInput() + SpringUnsynced.SDLStopTextInput() widgetHandler.textOwner = nil --widgetHandler:DisownText() UpdateList(true) end @@ -315,10 +315,10 @@ local function widgetselectorCmd(_, _, params) show = not show if show then widgetHandler.textOwner = self --widgetHandler:OwnText() - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! - Spring.SetConfigInt("widgetselector", 1) + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SetConfigInt("widgetselector", 1) else - Spring.SDLStopTextInput() + SpringUnsynced.SDLStopTextInput() widgetHandler.textOwner = nil --widgetHandler:DisownText() end end @@ -326,7 +326,7 @@ end local function factoryresetCmd(_, _, params) widgetHandler.__blankOutConfig = true --widgetHandler.__allowUserWidgets = false - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SendCommands("luarules reloadluaui") end local function userwidgetsCmd(_, _, params) @@ -337,7 +337,7 @@ local function userwidgetsCmd(_, _, params) widgetHandler.__allowUserWidgets = true spEcho("Allowed user widgets, reloading...") end - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SendCommands("luarules reloadluaui") end function widget:Initialize() @@ -360,7 +360,7 @@ function widget:Initialize() end widgetHandler.knownChanged = true - Spring.SendCommands("unbindkeyset f11") + SpringUnsynced.SendCommands("unbindkeyset f11") WG["widgetselector"] = {} WG["widgetselector"].toggle = function(state) @@ -374,10 +374,10 @@ function widget:Initialize() show = newShow if show then widgetHandler.textOwner = self --widgetHandler:OwnText() - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! - Spring.SetConfigInt("widgetselector", 1) + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SetConfigInt("widgetselector", 1) else - Spring.SDLStopTextInput() + SpringUnsynced.SDLStopTextInput() widgetHandler.textOwner = nil --widgetHandler:DisownText() end end @@ -411,7 +411,7 @@ function widget:MouseWheel(up, value) return false end - local a, c, m, s = Spring.GetModKeyState() + local a, c, m, s = SpringUnsynced.GetModKeyState() if a or m then return false -- alt and meta allow normal control end @@ -679,15 +679,15 @@ function widget:KeyPress(key, mods, isRepeat) WG["topbar"].hideWindows() end show = newShow - if show and not (Spring.Utilities.IsDevMode() or Spring.Utilities.ShowDevUI() or Spring.GetConfigInt("widgetselector", 0) == 1 or localWidgetCount > 0) then + if show and not (Spring.Utilities.IsDevMode() or Spring.Utilities.ShowDevUI() or SpringUnsynced.GetConfigInt("widgetselector", 0) == 1 or localWidgetCount > 0) then show = false end if show then widgetHandler.textOwner = self --widgetHandler:OwnText() - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! - Spring.SetConfigInt("widgetselector", 1) + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SetConfigInt("widgetselector", 1) else - Spring.SDLStopTextInput() + SpringUnsynced.SDLStopTextInput() widgetHandler.textOwner = nil --widgetHandler:DisownText() end end @@ -1050,7 +1050,7 @@ function widget:DrawScreen() end function widget:MousePress(x, y, button) - if Spring.IsGUIHidden() or not show then + if SpringUnsynced.IsGUIHidden() or not show then return false end @@ -1108,7 +1108,7 @@ function widget:MousePress(x, y, button) return true else show = false - Spring.SDLStopTextInput() + SpringUnsynced.SDLStopTextInput() widgetHandler.textOwner = nil --widgetHandler:DisownText() return false end @@ -1124,7 +1124,7 @@ function widget:MouseMove(x, y, dx, dy, button) end function widget:MouseRelease(x, y, mb) - if Spring.IsGUIHidden() or not show then + if SpringUnsynced.IsGUIHidden() or not show then return -1 end @@ -1146,7 +1146,7 @@ function widget:MouseRelease(x, y, mb) curMaxEntries = curMaxEntries + 1 UpdateListScroll() UpdateGeometry() - Spring.WarpMouse(x, y + 0.5 * (fontSize + fontSpace)) + SpringUnsynced.WarpMouse(x, y + 0.5 * (fontSize + fontSpace)) return -1 end if minx < x and x < minx + 10 and maxy + bgPadding < y and y < maxy + buttonFontSize + 7 + bgPadding then @@ -1155,7 +1155,7 @@ function widget:MouseRelease(x, y, mb) curMaxEntries = curMaxEntries - 1 UpdateListScroll() UpdateGeometry() - Spring.WarpMouse(x, y - 0.5 * (fontSize + fontSpace)) + SpringUnsynced.WarpMouse(x, y - 0.5 * (fontSize + fontSpace)) end return -1 end @@ -1170,7 +1170,7 @@ function widget:MouseRelease(x, y, mb) end end if buttonID == 1 then - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SendCommands("luarules reloadluaui") return -1 end if buttonID == 2 then @@ -1190,15 +1190,15 @@ function widget:MouseRelease(x, y, mb) widgetHandler.__allowUserWidgets = true spEcho("Allowed user widgets, reloading...") end - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SendCommands("luarules reloadluaui") return -1 end if buttonID == 4 then - Spring.SendCommands("luaui reset") + SpringUnsynced.SendCommands("luaui reset") return -1 end if buttonID == 5 then - Spring.SendCommands("luaui factoryreset") + SpringUnsynced.SendCommands("luaui factoryreset") return -1 end end @@ -1259,12 +1259,12 @@ function widget:SetConfigData(data) show = data.show or show if show then widgetHandler.textOwner = self --widgetHandler:OwnText() - Spring.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! + SpringUnsynced.SDLStartTextInput() -- because: touch chobby's text edit field once and widget:TextInput is gone for the game, so we make sure its started! end end function widget:Shutdown() - Spring.SendCommands("bind f11 luaui selector") -- if this one is removed or crashes, then have the backup one take over. + SpringUnsynced.SendCommands("bind f11 luaui selector") -- if this one is removed or crashes, then have the backup one take over. cancelChatInput() if WG["guishader"] then WG["guishader"].DeleteDlist("widgetselector") diff --git a/luaui/barwidgets.lua b/luaui/barwidgets.lua index 631521594b9..c53093edaab 100644 --- a/luaui/barwidgets.lua +++ b/luaui/barwidgets.lua @@ -32,35 +32,35 @@ local SAFEDRAW = false -- requires SAFEWRAP to work local glPopAttrib = gl.PopAttrib local glPushAttrib = gl.PushAttrib -Spring.SendCommands({ +SpringUnsynced.SendCommands({ "unbindkeyset Any+f11", "unbindkeyset Ctrl+f11", "bind f11 luaui selector", "echo LuaUI: bound F11 to the widget selector", }) -local allowuserwidgets = Spring.GetModOptions().allowuserwidgets -local allowunitcontrolwidgets = Spring.GetModOptions().allowunitcontrolwidgets +local allowuserwidgets = SpringShared.GetModOptions().allowuserwidgets +local allowunitcontrolwidgets = SpringShared.GetModOptions().allowunitcontrolwidgets local SandboxedSystem = {} local SANDBOXED_ERROR_MSG = "User 'unit control' widgets disallowed on this game" -local anonymousMode = Spring.GetModOptions().teamcolors_anonymous_mode +local anonymousMode = SpringShared.GetModOptions().teamcolors_anonymous_mode if anonymousMode ~= "disabled" then allowuserwidgets = false -- disabling individual Spring functions isnt really good enough -- disabling user widget draw access would probably do the job but that wouldnt be easy to do - Spring.SetTeamColor = function() + SpringUnsynced.SetTeamColor = function() return true end - if not Spring.GetSpectatingState() then - Spring.SendCommands("info 0") + if not SpringUnsynced.GetSpectatingState() then + SpringUnsynced.SendCommands("info 0") end end -if Spring.IsReplay() or Spring.GetSpectatingState() then +if SpringUnsynced.IsReplay() or SpringUnsynced.GetSpectatingState() then allowuserwidgets = true allowunitcontrolwidgets = true end @@ -253,11 +253,11 @@ function widgetHandler:LoadConfigData() local chunk, err = loadfile(CONFIG_FILENAME) if chunk == nil or err then if err then - Spring.Log("barwidgets.lua", LOG.INFO, err) + SpringShared.Log("barwidgets.lua", LOG.INFO, err) end return {} elseif chunk() == nil then - Spring.Log("barwidgets.lua", LOG.ERROR, "Luaui config file was blank") + SpringShared.Log("barwidgets.lua", LOG.ERROR, "Luaui config file was blank") return {} end local tmp = {} @@ -299,11 +299,11 @@ end -------------------------------------------------------------------------------- local unsortedWidgets -local doMoreYield = (Spring.Yield ~= nil) +local doMoreYield = (SpringUnsynced.Yield ~= nil) local function Yield() if doMoreYield then - doMoreYield = Spring.Yield() + doMoreYield = SpringUnsynced.Yield() end end @@ -361,7 +361,7 @@ function widgetHandler:Initialize() self.allowUserWidgets = true end - Spring.CreateDir(LUAUI_DIRNAME .. "Config") + SpringUnsynced.CreateDir(LUAUI_DIRNAME .. "Config") unsortedWidgets = {} @@ -370,11 +370,11 @@ function widgetHandler:Initialize() CreateSandboxedSystem() end - Spring.Echo("LuaUI: Allowing User Widgets") + SpringShared.Echo("LuaUI: Allowing User Widgets") loadWidgetFiles(WIDGET_DIRNAME, VFS.RAW) loadWidgetFiles(RML_WIDGET_DIRNAME, VFS.RAW) else - Spring.Echo("LuaUI: Disallowing User Widgets") + SpringShared.Echo("LuaUI: Disallowing User Widgets") end loadWidgetFiles(WIDGET_DIRNAME, VFS.ZIP) @@ -401,7 +401,7 @@ function widgetHandler:Initialize() local name = w.whInfo.name local basename = w.whInfo.basename local source = self.knownWidgets[name].fromZip and "mod: " or "user:" - Spring.Echo(string.format("Loading widget from %s %-18s <%s> ...", source, name, basename)) + SpringShared.Echo(string.format("Loading widget from %s %-18s <%s> ...", source, name, basename)) Yield() widgetHandler:InsertWidgetRaw(w) end @@ -425,14 +425,14 @@ function widgetHandler:AddSpadsMessage(contents) -- will get parsed by barmanager, and forwarded to autohostmonitor as: -- match-event <35> local myPlayerID = Spring.GetMyPlayerID() - local myPlayerName = Spring.GetPlayerInfo(myPlayerID, false) - local gameSeconds = math.max(0, math.round(Spring.GetGameFrame() / 30)) + local myPlayerName = SpringShared.GetPlayerInfo(myPlayerID, false) + local gameSeconds = math.max(0, math.round(SpringShared.GetGameFrame() / 30)) if type(contents) == "table" then contents = Json.encode(contents) end local rawmessage = string.format("<%s> <%s> <%d>", myPlayerName, contents, gameSeconds) local b64message = "lu@$p@d$:" .. string.base64Encode(rawmessage) - Spring.SendLuaRulesMsg(b64message) + SpringUnsynced.SendLuaRulesMsg(b64message) end function widgetHandler:ReloadUserWidgetFromGameRaw(name) @@ -443,7 +443,7 @@ function widgetHandler:ReloadUserWidgetFromGameRaw(name) local w = widgetHandler:LoadWidget(ki.filename, true, ki.localsAccess, true) if w then widgetHandler:InsertWidgetRaw(w) - Spring.Echo("Reloaded from game: " .. name .. " (user 'unit control' widgets disabled for this game)") + SpringShared.Echo("Reloaded from game: " .. name .. " (user 'unit control' widgets disabled for this game)") end return w end @@ -452,7 +452,7 @@ function widgetHandler:LoadWidget(filename, fromZip, enableLocalsAccess, reload) local basename = Basename(filename) local text = VFS.LoadFile(filename, not (self.allowUserWidgets and allowuserwidgets and not reload) and VFS.ZIP or VFS.RAW_FIRST) if text == nil then - Spring.Echo("Failed to load: " .. basename .. " (missing file: " .. filename .. ")") + SpringShared.Echo("Failed to load: " .. basename .. " (missing file: " .. filename .. ")") return nil end @@ -467,7 +467,7 @@ function widgetHandler:LoadWidget(filename, fromZip, enableLocalsAccess, reload) local chunk, err = loadstring(textWithLocalsDetector, filename) if chunk == nil then - Spring.Echo("Failed to load: " .. basename .. " (" .. err .. ")") + SpringShared.Echo("Failed to load: " .. basename .. " (" .. err .. ")") return nil end @@ -475,7 +475,7 @@ function widgetHandler:LoadWidget(filename, fromZip, enableLocalsAccess, reload) setfenv(chunk, widget) local success, err = pcall(chunk) if not success then - Spring.Echo("Failed to load: " .. basename .. " (" .. err .. ")") + SpringShared.Echo("Failed to load: " .. basename .. " (" .. err .. ")") return nil end if err == false then @@ -489,7 +489,7 @@ function widgetHandler:LoadWidget(filename, fromZip, enableLocalsAccess, reload) local chunk, err = loadstring(text, filename) if chunk == nil then - Spring.Echo("Failed to load: " .. basename .. " (" .. err .. ")") + SpringShared.Echo("Failed to load: " .. basename .. " (" .. err .. ")") return nil end @@ -497,7 +497,7 @@ function widgetHandler:LoadWidget(filename, fromZip, enableLocalsAccess, reload) setfenv(chunk, widget) local success, err = pcall(chunk) if not success then - Spring.Echo("Failed to load: " .. basename .. " (" .. err .. ")") + SpringShared.Echo("Failed to load: " .. basename .. " (" .. err .. ")") return nil end if err == false then @@ -514,7 +514,7 @@ function widgetHandler:LoadWidget(filename, fromZip, enableLocalsAccess, reload) if fromZip or true then widget.widgetHandler = self else - Spring.Echo("Failed to load: " .. basename .. " (user widgets may not access widgetHandler)", fromZip, filename, allowuserwidgets) + SpringShared.Echo("Failed to load: " .. basename .. " (user widgets may not access widgetHandler)", fromZip, filename, allowuserwidgets) return nil end end @@ -527,14 +527,14 @@ function widgetHandler:LoadWidget(filename, fromZip, enableLocalsAccess, reload) err = self:ValidateWidget(widget) if err then - Spring.Echo("Failed to load: " .. basename .. " (" .. err .. ")") + SpringShared.Echo("Failed to load: " .. basename .. " (" .. err .. ")") return nil end local knownInfo = self.knownWidgets[name] if knownInfo and not reload then if knownInfo.active then - Spring.Echo("Failed to load: " .. basename .. " (duplicate name)") + SpringShared.Echo("Failed to load: " .. basename .. " (duplicate name)") return nil end else @@ -553,7 +553,7 @@ function widgetHandler:LoadWidget(filename, fromZip, enableLocalsAccess, reload) knownInfo.localsAccess = enableLocalsAccess if widget.GetInfo == nil then - Spring.Echo("Failed to load: " .. basename .. " (no GetInfo() call)") + SpringShared.Echo("Failed to load: " .. basename .. " (no GetInfo() call)") return nil end @@ -753,10 +753,10 @@ local function widgetFailure(w, funcName, errorMsg) widgetHandler:ReloadUserWidgetFromGame(name) end else - Spring.Echo("Error in Shutdown()") + SpringShared.Echo("Error in Shutdown()") end - Spring.Echo(errorBase .. " in " .. funcName .. "(): " .. tostring(errorMsg)) - Spring.Echo("Removed widget: " .. name) + SpringShared.Echo(errorBase .. " in " .. funcName .. "(): " .. tostring(errorMsg)) + SpringShared.Echo("Removed widget: " .. name) return nil end @@ -802,7 +802,7 @@ local function SafeWrapWidget(widget) return elseif SAFEWRAP == 1 then if widget.GetInfo and widget.GetInfo().unsafe then - Spring.Echo("LuaUI: loaded unsafe widget: " .. widget.whInfo.name) + SpringShared.Echo("LuaUI: loaded unsafe widget: " .. widget.whInfo.name) return end end @@ -879,11 +879,11 @@ function widgetHandler:HookReorderPost(name, topMethod) -- measure. local func = self[name] if not func or not type(func) == "function" then - Spring.Log("barwidgets.lua", LOG.WARNING, name .. " does not exist or isn't a function") + SpringShared.Log("barwidgets.lua", LOG.WARNING, name .. " does not exist or isn't a function") return end if self[name .. "Raw"] then - Spring.Log("barwidgets.lua", LOG.WARNING, name .. "Raw already exists") + SpringShared.Log("barwidgets.lua", LOG.WARNING, name .. "Raw already exists") return end self[name .. "Raw"] = func @@ -952,14 +952,14 @@ function widgetHandler:InsertWidgetRaw(widget) if self.knownWidgets[name] then self.knownWidgets[name].active = false end - Spring.Echo("Missing capabilities: " .. name .. ". Disabling.") + SpringShared.Echo("Missing capabilities: " .. name .. ". Disabling.") return end -- Gracefully ignore/reload good control widgets advertising themselves as such, if user 'unit control' widgets disabled. if widget.GetInfo and widget:GetInfo().control and not widget.canControlUnits then local name = widget.whInfo.name if not self:ReloadUserWidgetFromGameRaw(name) then - Spring.Echo("Blocked loading: " .. name .. " (user 'unit control' widgets disabled for this game)") + SpringShared.Echo("Blocked loading: " .. name .. " (user 'unit control' widgets disabled for this game)") end return end @@ -1052,7 +1052,7 @@ function widgetHandler:UpdateWidgetCallInRaw(name, w) end self:UpdateCallIn(name) else - Spring.Echo("UpdateWidgetCallIn: bad name: " .. name) + SpringShared.Echo("UpdateWidgetCallIn: bad name: " .. name) end end @@ -1063,7 +1063,7 @@ function widgetHandler:RemoveWidgetCallInRaw(name, w) ArrayRemove(ciList, w) self:UpdateCallIn(name) else - Spring.Echo("RemoveWidgetCallIn: bad name: " .. name) + SpringShared.Echo("RemoveWidgetCallIn: bad name: " .. name) end end @@ -1082,11 +1082,11 @@ end function widgetHandler:EnableWidgetRaw(name, enableLocalsAccess) local ki = self.knownWidgets[name] if not ki then - Spring.Echo("EnableWidget(), could not find widget: " .. tostring(name)) + SpringShared.Echo("EnableWidget(), could not find widget: " .. tostring(name)) return false end if not ki.active then - Spring.Echo("Loading: " .. ki.filename .. (enableLocalsAccess and " (with locals)" or "")) + SpringShared.Echo("Loading: " .. ki.filename .. (enableLocalsAccess and " (with locals)" or "")) local order = widgetHandler.orderList[name] if not order or order <= 0 then self.orderList[name] = 1 @@ -1104,7 +1104,7 @@ end function widgetHandler:DisableWidgetRaw(name) local ki = self.knownWidgets[name] if not ki then - Spring.Echo("DisableWidget(), could not find widget: " .. tostring(name)) + SpringShared.Echo("DisableWidget(), could not find widget: " .. tostring(name)) return false end if ki.active then @@ -1112,7 +1112,7 @@ function widgetHandler:DisableWidgetRaw(name) if not w then return false end - Spring.Echo("Removed: " .. ki.filename) + SpringShared.Echo("Removed: " .. ki.filename) self:RemoveWidgetRaw(w) -- deactivate self.orderList[name] = 0 -- disable self:SaveConfigData() @@ -1123,7 +1123,7 @@ end function widgetHandler:ToggleWidgetRaw(name) local ki = self.knownWidgets[name] if not ki then - Spring.Echo("ToggleWidget(), could not find widget: " .. tostring(name)) + SpringShared.Echo("ToggleWidget(), could not find widget: " .. tostring(name)) return end if ki.active then @@ -1331,12 +1331,12 @@ function widgetHandler:Update() if gcCheckCounter >= 30 then gcCheckCounter = 0 if collectgarbage("count") > 1200000 then - Spring.Echo("Warning: Emergency garbage collection due to exceeding 1.2GB LuaRAM") + SpringShared.Echo("Warning: Emergency garbage collection due to exceeding 1.2GB LuaRAM") collectgarbage("collect") end end - local deltaTime = Spring.GetLastUpdateSeconds() + local deltaTime = SpringUnsynced.GetLastUpdateSeconds() -- update the hour timer hourTimer = (hourTimer + deltaTime) % 3600.0 tracy.ZoneBeginN("W:Update") @@ -1501,7 +1501,7 @@ end function widgetHandler:DrawScreen() tracy.ZoneBeginN("W:DrawScreen") - if not Spring.IsGUIHidden() then + if not SpringUnsynced.IsGUIHidden() then if not self.chobbyInterface then local list = self.DrawScreenList for i = #list, 1, -1 do @@ -1909,7 +1909,7 @@ end function widgetHandler:MouseRelease(x, y, button) tracy.ZoneBeginN("W:MouseRelease") local mo = self.mouseOwner - local _, _, lmb, mmb, rmb = Spring.GetMouseState() + local _, _, lmb, mmb, rmb = SpringUnsynced.GetMouseState() if not (lmb or mmb or rmb) then self.mouseOwner = nil end @@ -2133,8 +2133,8 @@ function widgetHandler:PlayerRemoved(playerID, reason) end function widgetHandler:PlayerChanged(playerID) - if anonymousMode ~= "disabled" and not Spring.GetSpectatingState() then - Spring.SendCommands("info 0") + if anonymousMode ~= "disabled" and not SpringUnsynced.GetSpectatingState() then + SpringUnsynced.SendCommands("info 0") end tracy.ZoneBeginN("W:PlayerChanged") for _, w in ipairs(self.PlayerChangedList) do @@ -2173,7 +2173,7 @@ local oldSelection = {} function widgetHandler:UpdateSelection() tracy.ZoneBeginN("W:UpdateSelection") local changed - local newSelection = Spring.GetSelectedUnits() + local newSelection = SpringUnsynced.GetSelectedUnits() if #newSelection == #oldSelection then for i = 1, #oldSelection do if newSelection[i] ~= oldSelection[i] then @@ -2218,7 +2218,7 @@ function widgetHandler:SelectionChanged(selectedUnits, subselection) for _, w in ipairs(self.SelectionChangedList) do local unitArray = w:SelectionChanged(selectedUnits, subselection) if unitArray then - Spring.SelectUnitArray(unitArray) + SpringUnsynced.SelectUnitArray(unitArray) tracy.ZoneEnd() return true end diff --git a/luaui/configs/DeferredLightsGL4WeaponsConfig.lua b/luaui/configs/DeferredLightsGL4WeaponsConfig.lua index 3237b6ab2ea..43136746127 100644 --- a/luaui/configs/DeferredLightsGL4WeaponsConfig.lua +++ b/luaui/configs/DeferredLightsGL4WeaponsConfig.lua @@ -592,7 +592,7 @@ local ColorSets = { -- TODO add advanced dual-color sets! Team = { r = -1, g = -1, b = -1 }, } -local globalDamageMult = Spring.GetModOptions().multiplier_weapondamage or 1 +local globalDamageMult = SpringShared.GetModOptions().multiplier_weapondamage or 1 local function GetClosestSizeClass(desiredsize) local delta = math.huge @@ -1031,7 +1031,7 @@ local function AssignLightsToAllWeapons() end end end - Spring.Echo(Spring.GetGameFrame(), "DLGL4 weapons conf using", usedclasses, "light types") + SpringShared.Echo(SpringShared.GetGameFrame(), "DLGL4 weapons conf using", usedclasses, "light types") end AssignLightsToAllWeapons() diff --git a/luaui/configs/DeferredLightsGL4config.lua b/luaui/configs/DeferredLightsGL4config.lua index 7169379e2b0..c558f96dd23 100644 --- a/luaui/configs/DeferredLightsGL4config.lua +++ b/luaui/configs/DeferredLightsGL4config.lua @@ -26146,7 +26146,7 @@ for unitName, lights in pairs(unitLights) do end unitLights = nil -if not (Spring.GetConfigInt("headlights", 1) == 1) then +if not (SpringUnsynced.GetConfigInt("headlights", 1) == 1) then for unitDefID, lights in pairs(unitDefLights) do for name, params in pairs(lights) do if string.find(name, "headlight") or string.find(name, "searchlight") then @@ -26156,7 +26156,7 @@ if not (Spring.GetConfigInt("headlights", 1) == 1) then end end -if not (Spring.GetConfigInt("buildlights", 1) == 1) then +if not (SpringUnsynced.GetConfigInt("buildlights", 1) == 1) then for unitDefID, lights in pairs(unitDefLights) do for name, params in pairs(lights) do if string.find(name, "buildlight") then diff --git a/luaui/configs/DistortionGL4Config.lua b/luaui/configs/DistortionGL4Config.lua index 7171743ecb0..18837b860fc 100644 --- a/luaui/configs/DistortionGL4Config.lua +++ b/luaui/configs/DistortionGL4Config.lua @@ -2263,7 +2263,7 @@ end unitDistortions = nil -- oof this should not be a GetConfigInt :/ -if not (Spring.GetConfigInt("headdistortions", 1) == 1) then +if not (SpringUnsynced.GetConfigInt("headdistortions", 1) == 1) then for unitDefID, distortions in pairs(unitDefDistortions) do for name, params in pairs(distortions) do if string.find(name, "headdistortion") or string.find(name, "searchdistortion") then @@ -2273,7 +2273,7 @@ if not (Spring.GetConfigInt("headdistortions", 1) == 1) then end end -if not (Spring.GetConfigInt("builddistortions", 1) == 1) then +if not (SpringUnsynced.GetConfigInt("builddistortions", 1) == 1) then for unitDefID, distortions in pairs(unitDefDistortions) do for name, params in pairs(distortions) do if string.find(name, "builddistortion") then @@ -2297,8 +2297,7 @@ local featureDefDistortions = {} local crystalDistortionBase = { distortionType = "point", - distortionConfig = { posx = 0, posy = 8, posz = 0, radius = 20, onlyModelMap = 0, riseRate = 0.5, windAffected = -0.5, -noiseStrength = 0.4, noiseScaleSpace = 2.2, distanceFalloff = 1.2, lifeTime = 0, effectType = 0 }, + distortionConfig = { posx = 0, posy = 8, posz = 0, radius = 20, onlyModelMap = 0, riseRate = 0.5, windAffected = -0.5, noiseStrength = 0.4, noiseScaleSpace = 2.2, distanceFalloff = 1.2, lifeTime = 0, effectType = 0 }, } local crystalColors = { -- note that the underscores are needed here diff --git a/luaui/configs/DistortionGL4WeaponsConfig.lua b/luaui/configs/DistortionGL4WeaponsConfig.lua index 589f6380003..4553dc079f2 100644 --- a/luaui/configs/DistortionGL4WeaponsConfig.lua +++ b/luaui/configs/DistortionGL4WeaponsConfig.lua @@ -1338,7 +1338,7 @@ local SizeRadius = { Planetary = 5000, } -local globalDamageMult = Spring.GetModOptions().multiplier_weapondamage or 1 +local globalDamageMult = SpringShared.GetModOptions().multiplier_weapondamage or 1 local function GetClosestSizeClass(desiredsize) local delta = math.huge @@ -1532,7 +1532,7 @@ local function AssignDistortionsToAllWeapons() -- if it's a machine-gun or rapid-fire, give it NO distortion if lname:find("mg_weapon") or lname:find("legflak") or lname:find("machinegun") or lname:find("shotgun") then - Spring.Echo("LaserCannon no distortion for " .. weaponDef.name) + SpringShared.Echo("LaserCannon no distortion for " .. weaponDef.name) --projectileDefDistortions[weaponID] = GetDistortionClass("NoEffect", sizeclass, overrideTable) -- otherwise give it the regular cannon distortion @@ -1719,7 +1719,7 @@ local function AssignDistortionsToAllWeapons() end end end - Spring.Echo(Spring.GetGameFrame(), "DLGL4 weapons conf using", usedclasses, "distortion types") + SpringShared.Echo(SpringShared.GetGameFrame(), "DLGL4 weapons conf using", usedclasses, "distortion types") end AssignDistortionsToAllWeapons() -- disable this if it doest work diff --git a/luaui/configs/gridmenu_config.lua b/luaui/configs/gridmenu_config.lua index f1a0f1fe956..8435e9d72bc 100644 --- a/luaui/configs/gridmenu_config.lua +++ b/luaui/configs/gridmenu_config.lua @@ -47,7 +47,7 @@ local categoryGroupMapping = { for uname, ugrid in pairs(unitGrids) do local builder = UnitDefNames[uname] if not builder then - Spring.Echo("gridmenu config: no unitdefname found for: " .. uname) + SpringShared.Echo("gridmenu config: no unitdefname found for: " .. uname) else local builderId = builder.id @@ -89,7 +89,7 @@ end for uname, ugrid in pairs(labGrids) do local udef = UnitDefNames[uname] if not udef then - Spring.Echo("gridmenu config: no unitdefname found for: " .. uname) + SpringShared.Echo("gridmenu config: no unitdefname found for: " .. uname) else local uid = udef.id diff --git a/luaui/configs/gridmenu_layouts.lua b/luaui/configs/gridmenu_layouts.lua index 187705278f8..28807dd3bb3 100644 --- a/luaui/configs/gridmenu_layouts.lua +++ b/luaui/configs/gridmenu_layouts.lua @@ -2942,7 +2942,7 @@ local unitGrids = { unitGrids["dummycom"] = unitGrids["armcom"] -if Spring.GetModOptions().experimentalextraunits or Spring.GetModOptions().scavunitsforplayers then +if SpringShared.GetModOptions().experimentalextraunits or SpringShared.GetModOptions().scavunitsforplayers then for _, builder in pairs({ "armaca", "coraca", "legaca", "armack", "corack", "legack", "armacv", "coracv", "legacv" }) do local faction = builder:sub(1, 3) unitGrids[builder][1][3][3] = faction .. "wint2" @@ -2954,7 +2954,7 @@ if Spring.GetModOptions().experimentalextraunits or Spring.GetModOptions().scavu end -if Spring.Utilities.Gametype.IsScavengers() or Spring.GetModOptions().forceallunits then +if Spring.Utilities.Gametype.IsScavengers() or SpringShared.GetModOptions().forceallunits then local scavLabGrids = {} local scavUnitGrids = {} for unitName, content in pairs(labGrids) do @@ -2997,7 +2997,7 @@ if Spring.Utilities.Gametype.IsScavengers() or Spring.GetModOptions().forceallun table.mergeInPlace(unitGrids, scavUnitGrids) end -if Spring.GetModOptions().techsplit then +if SpringShared.GetModOptions().techsplit then -- Unit Grids diff --git a/luaui/configs/keyboard_layouts.lua b/luaui/configs/keyboard_layouts.lua index cd9617f564e..e20d72bdba3 100644 --- a/luaui/configs/keyboard_layouts.lua +++ b/luaui/configs/keyboard_layouts.lua @@ -328,7 +328,7 @@ local function sanitizeKey(key, layout) return "" end - layout = layout or Spring.GetConfigString("KeyboardLayout", "qwerty") + layout = layout or SpringUnsynced.GetConfigString("KeyboardLayout", "qwerty") key = key:upper():gsub("ANY%+", "") key = key:gsub("SC_(.)", function(c) diff --git a/luaui/debug.lua b/luaui/debug.lua index 6ec156f023b..5fd7028e0d1 100644 --- a/luaui/debug.lua +++ b/luaui/debug.lua @@ -12,12 +12,12 @@ -------------------------------------------------------------------------------- function PrintInCommand() - local cmdIndex, cmdId, cmdType, name = Spring.GetActiveCommand() + local cmdIndex, cmdId, cmdType, name = SpringUnsynced.GetActiveCommand() print("InCommand: ", cmdIndex, cmdId, cmdType, name) end function PrintBuildQueue(unitID) - local queue, count = Spring.GetRealBuildQueue(unitID) + local queue, count = SpringShared.GetRealBuildQueue(unitID) print("BuildQueue(" .. unitID .. "): " .. count) for i, v in pairs(queue) do for i2, v2 in pairs(v) do @@ -27,14 +27,14 @@ function PrintBuildQueue(unitID) end function PrintSelection() - local udTable, n = Spring.GetSelectedUnitsSorted() - local selectedGroup = Spring.GetSelectedGroup() + local udTable, n = SpringUnsynced.GetSelectedUnitsSorted() + local selectedGroup = SpringUnsynced.GetSelectedGroup() print("Selected Group = " .. selectedGroup) print("Selected: " .. n .. " types") for udid, uTable in pairs(udTable) do print(" " .. udid .. "=" .. UnitDefs[udid].name .. " count " .. uTable.n) for _, uid in ipairs(uTable) do - local health, maxHealth, paralyze, capture, build = Spring.GetUnitHealth(uid) + local health, maxHealth, paralyze, capture, build = SpringShared.GetUnitHealth(uid) print(" ", uid, health, maxHealth, paralyze, capture, build) PrintCommandQueue(uid) end @@ -47,7 +47,7 @@ function PrintSelection() end function PrintCommandQueue(uid) - local queue = Spring.GetUnitCommands(uid, -1) + local queue = SpringShared.GetUnitCommands(uid, -1) if queue ~= nil then local msg = "" local count = 0 @@ -66,7 +66,7 @@ function PrintCommandQueue(uid) end function PrintGroups() - local groupList, count = Spring.GetGroupList() + local groupList, count = SpringUnsynced.GetGroupList() print("GetGroupList: " .. tostring(count)) for i, v in pairs(groupList) do local groupName = Spring.GetGroupAIName(i) @@ -78,7 +78,7 @@ function PrintGroups() for g, c in pairs(groupList) do print("Units in Group " .. g) - local udTable = Spring.GetGroupUnitsSorted(g) + local udTable = SpringUnsynced.GetGroupUnitsSorted(g) print(" MyTeamUnits: " .. udTable.n .. " types") udTable.n = nil for udid, uTable in pairs(udTable) do @@ -92,7 +92,7 @@ function PrintGroups() end function PrintTeamUnits(team) - udTable = Spring.GetTeamUnitsSorted(team) + udTable = SpringShared.GetTeamUnitsSorted(team) -- print("TeamUnits(" .. team .. "): " .. udTable.n .. " types") -- udTable.n = nil if udTable == nil then @@ -110,7 +110,7 @@ end function PrintTeamUnitsCounts(team) print("Team Units Count:" .. team) - local countTable = Spring.GetTeamUnitsCounts(team) + local countTable = SpringShared.GetTeamUnitsCounts(team) if countTable == nil then return end @@ -121,7 +121,7 @@ function PrintTeamUnitsCounts(team) end function PrintAlliedUnits() - local teamTable = Spring.GetTeamList(Spring.GetMyAllyTeamID()) + local teamTable = SpringShared.GetTeamList(Spring.GetMyAllyTeamID()) -- print("AlliedUnits: " .. teamTable.n .. " teams") teamTable.n = nil for n, tid in pairs(teamTable) do @@ -130,7 +130,7 @@ function PrintAlliedUnits() end function PrintAllyTeamList() - local allyTeamTable = Spring.GetAllyTeamList() + local allyTeamTable = SpringShared.GetAllyTeamList() local msg = "AllyTeams(" .. allyTeamTable.n .. ")" allyTeamTable.n = nil for n, atid in pairs(allyTeamTable) do @@ -142,9 +142,9 @@ end function PrintTeamList(allyTeam) local teamTable if allyTeam == nil then - teamTable = Spring.GetTeamList() + teamTable = SpringShared.GetTeamList() else - teamTable = Spring.GetTeamList(allyTeam) + teamTable = SpringShared.GetTeamList(allyTeam) end if teamTable == nil then return @@ -161,9 +161,9 @@ end function PrintPlayerList(team) local playerTable if team == nil then - playerTable = Spring.GetTeamList() + playerTable = SpringShared.GetTeamList() else - playerTable = Spring.GetTeamList(team) + playerTable = SpringShared.GetTeamList(team) end if playerTable == nil then return @@ -178,15 +178,15 @@ function PrintPlayerList(team) end function PrintPlayerTree() - local atTable = Spring.GetAllyTeamList() + local atTable = SpringShared.GetAllyTeamList() for atn, atid in ipairs(atTable) do print("Ally team: " .. atid) - local tTable = Spring.GetTeamList(atid) + local tTable = SpringShared.GetTeamList(atid) for tn, tid in ipairs(tTable) do print(" Team: " .. tid) - local pTable = Spring.GetPlayerList(tid) + local pTable = SpringShared.GetPlayerList(tid) for pn, pid in ipairs(pTable) do - local pname, active = Spring.GetPlayerInfo(pid, false) + local pname, active = SpringShared.GetPlayerInfo(pid, false) if active then print(" Player: " .. pid .. " " .. pname) end @@ -196,7 +196,7 @@ function PrintPlayerTree() end function PrintTeamInfo(teamID) - local num, leader, dead, isAI, side, allyTeam = Spring.GetTeamInfo(teamID, false) + local num, leader, dead, isAI, side, allyTeam = SpringShared.GetTeamInfo(teamID, false) print("Team number: " .. num) print(" leader: " .. leader) print(" dead: " .. tostring(dead)) @@ -206,7 +206,7 @@ function PrintTeamInfo(teamID) end function PrintTeamResources(teamID, type) - local current, storage, pull, income, expense, share, sent, received = Spring.GetTeamResources(teamID, type) + local current, storage, pull, income, expense, share, sent, received = SpringShared.GetTeamResources(teamID, type) if current ~= nil then print("Team number: " .. teamID) print(" " .. type .. ": " .. current) @@ -221,7 +221,7 @@ function PrintTeamResources(teamID, type) end function PrintTeamUnitStats(teamID) - local kills, deaths, caps, losses, recv, sent = Spring.GetTeamUnitStats(teamID) + local kills, deaths, caps, losses, recv, sent = SpringShared.GetTeamUnitStats(teamID) if kills ~= nil then print("Team number: " .. teamID) print(" kills: " .. kills) @@ -234,7 +234,7 @@ function PrintTeamUnitStats(teamID) end function PrintPlayerInfo(playerID) - local name, active, spectator, team, allyteam, ping, cpuUsage = Spring.GetPlayerInfo(playerID, false) + local name, active, spectator, team, allyteam, ping, cpuUsage = SpringShared.GetPlayerInfo(playerID, false) print(" name: " .. name) print(" id: " .. playerID) print(" active: " .. tostring(active)) @@ -306,9 +306,9 @@ function Debug() PrintSelection() PrintGroups() PrintInCommand() - print("UserName = " .. Spring.GetConfigString("name", "")) - print("Shadows = " .. Spring.GetConfigString("Shadows", 0)) - print("ReflectiveWater = " .. Spring.GetConfigString("ReflectiveWater", 1)) + print("UserName = " .. SpringUnsynced.GetConfigString("name", "")) + print("Shadows = " .. SpringUnsynced.GetConfigString("Shadows", 0)) + print("ReflectiveWater = " .. SpringUnsynced.GetConfigString("ReflectiveWater", 1)) PrintTeamUnits(Spring.GetMyTeamID()) diff --git a/luaui/layout.lua b/luaui/layout.lua index a63071a02e4..12539fa894f 100644 --- a/luaui/layout.lua +++ b/luaui/layout.lua @@ -91,4 +91,4 @@ end LayoutButtons = DummyLayoutHandler -- refresh, this prevents default engine buildmenu still showing up after a luaui reload -Spring.ForceLayoutUpdate() +SpringUnsynced.ForceLayoutUpdate() diff --git a/luaui/main.lua b/luaui/main.lua index d0b51ae249e..ee8785ef26e 100644 --- a/luaui/main.lua +++ b/luaui/main.lua @@ -12,15 +12,15 @@ -------------------------------------------------------------------------------- -- set default gaia teamcolor -Spring.SetTeamColor(Spring.GetGaiaTeamID(), 0.3, 0.3, 0.3) +SpringUnsynced.SetTeamColor(SpringShared.GetGaiaTeamID(), 0.3, 0.3, 0.3) -local spSendCommands = Spring.SendCommands +local spSendCommands = SpringUnsynced.SendCommands spSendCommands("ctrlpanel " .. LUAUI_DIRNAME .. "ctrlpanel.txt") VFS.Include("init.lua", nil, VFS.ZIP) VFS.Include(LUAUI_DIRNAME .. "rml_setup.lua", nil, VFS.ZIP) -Spring.I18N.setLanguage(Spring.GetConfigString("language", "en")) +Spring.I18N.setLanguage(SpringUnsynced.GetConfigString("language", "en")) VFS.Include(LUAUI_DIRNAME .. "utils.lua", nil, VFS.ZIP) VFS.Include(LUAUI_DIRNAME .. "setupdefs.lua", nil, VFS.ZIP) diff --git a/luaui/rml_setup.lua b/luaui/rml_setup.lua index 78c296167d7..456c9be28fe 100644 --- a/luaui/rml_setup.lua +++ b/luaui/rml_setup.lua @@ -37,9 +37,9 @@ local function NewCreateContext(name) local context = oldCreateContext(name) -- set up dp_ratio considering the user's UI scale preference and the screen resolution - local viewSizeX, viewSizeY = Spring.GetViewGeometry() + local viewSizeX, viewSizeY = SpringUnsynced.GetViewGeometry() - local userScale = Spring.GetConfigFloat("ui_scale", 1) + local userScale = SpringUnsynced.GetConfigFloat("ui_scale", 1) local baseWidth = 1920 local baseHeight = 1080 @@ -57,7 +57,7 @@ RmlUi.CreateContext = NewCreateContext RmlUi.LoadFontFace("fonts/Poppins-Regular.otf", true) local font_files = VFS.DirList("fonts/exo2", "*.ttf") for _, file in ipairs(font_files) do - Spring.Echo("loading font", file) + SpringShared.Echo("loading font", file) RmlUi.LoadFontFace(file, true) end diff --git a/luaui/system.lua b/luaui/system.lua index d75a40ec2f6..2c092275b86 100644 --- a/luaui/system.lua +++ b/luaui/system.lua @@ -13,7 +13,7 @@ if System == nil then if tracy == nil then - Spring.Echo("Tracy: No support detected, replacing tracy.* with function stubs.") + SpringShared.Echo("Tracy: No support detected, replacing tracy.* with function stubs.") tracy = {} tracy.ZoneBeginN = function() return diff --git a/luaui/utils.lua b/luaui/utils.lua index 913b37378de..af986c8d857 100644 --- a/luaui/utils.lua +++ b/luaui/utils.lua @@ -20,11 +20,11 @@ UtilsGuard = true -------------------------------------------------------------------------------- function Say(msg) - Spring.SendCommands({ "say " .. msg }) + SpringUnsynced.SendCommands({ "say " .. msg }) end function SendCommand(msg) - Spring.SendCommands({ msg }) + SpringUnsynced.SendCommands({ msg }) end -------------------------------------------------------------------------------- diff --git a/modelmaterials/001_units_s3o_assimp.lua b/modelmaterials/001_units_s3o_assimp.lua index 550a4ffafe9..1154c99da0b 100644 --- a/modelmaterials/001_units_s3o_assimp.lua +++ b/modelmaterials/001_units_s3o_assimp.lua @@ -15,7 +15,7 @@ local unitsNormalMapTemplate = table.merge(matTemplate, { "#define ROUGHNESS_AA 1.0", - "#define ENV_SMPL_NUM " .. tostring(Spring.GetConfigInt("ENV_SMPL_NUM", 64)), + "#define ENV_SMPL_NUM " .. tostring(SpringUnsynced.GetConfigInt("ENV_SMPL_NUM", 64)), "#define USE_ENVIRONMENT_DIFFUSE 1", "#define USE_ENVIRONMENT_SPECULAR 1", @@ -30,7 +30,7 @@ local unitsNormalMapTemplate = table.merge(matTemplate, { "#define ROUGHNESS_AA 1.0", - "#define ENV_SMPL_NUM " .. tostring(Spring.GetConfigInt("ENV_SMPL_NUM", 64)), + "#define ENV_SMPL_NUM " .. tostring(SpringUnsynced.GetConfigInt("ENV_SMPL_NUM", 64)), "#define USE_ENVIRONMENT_DIFFUSE 1", "#define USE_ENVIRONMENT_SPECULAR 1", @@ -61,15 +61,15 @@ local GL_FLOAT = 0x1406 local GL_INT = 0x1404 -- args= local mySetMaterialUniform = { - [false] = Spring.UnitRendering.SetForwardMaterialUniform, - [true] = Spring.UnitRendering.SetDeferredMaterialUniform, + [false] = SpringUnsynced.UnitRendering.SetForwardMaterialUniform, + [true] = SpringUnsynced.UnitRendering.SetDeferredMaterialUniform, } local armTanks = {} local corTanks = {} local raptorUnits = {} local otherUnits = {} -local spGetUnitHealth = Spring.GetUnitHealth +local spGetUnitHealth = SpringShared.GetUnitHealth local unitsHealth = {} --cache local healthArray = { [1] = 0.0 } @@ -147,8 +147,8 @@ local function SendUnitID(unitID, hasStd, hasDef, hasShad) end end -local spGetUnitVelocity = Spring.GetUnitVelocity -local spGetUnitDirection = Spring.GetUnitDirection +local spGetUnitVelocity = SpringShared.GetUnitVelocity +local spGetUnitDirection = SpringShared.GetUnitDirection local floor = math.floor local treadSpeeds = {} --cache local treadsArray = { [1] = 0.0 } diff --git a/modelmaterials/128_features_special.lua b/modelmaterials/128_features_special.lua index bb503a5b631..1c4a5050162 100644 --- a/modelmaterials/128_features_special.lua +++ b/modelmaterials/128_features_special.lua @@ -7,11 +7,11 @@ local GL_FLOAT = 0x1406 local GL_INT = 0x1404 -- args= local mySetMaterialUniform = { - [false] = Spring.FeatureRendering.SetForwardMaterialUniform, - [true] = Spring.FeatureRendering.SetDeferredMaterialUniform, + [false] = SpringUnsynced.FeatureRendering.SetForwardMaterialUniform, + [true] = SpringUnsynced.FeatureRendering.SetDeferredMaterialUniform, } -local spGetFeatureHealth = Spring.GetFeatureHealth +local spGetFeatureHealth = SpringShared.GetFeatureHealth local featuresHealth = {} --cache local healthArray = { [1] = 0.0 } @@ -398,11 +398,11 @@ for id = 1, #FeatureDefs do local fromUnit = featureDef.name:find("_dead") or featureDef.name:find("_heap") if fromUnit then - Spring.PreloadFeatureDefModel(id) + SpringUnsynced.PreloadFeatureDefModel(id) local lowercasetex1 = "" if featureDef.model.textures.tex1 == nil then - Spring.Echo("nil texture 1 detected for", featureDef.name) + SpringShared.Echo("nil texture 1 detected for", featureDef.name) else lowercasetex1 = string.lower(featureDef.model.textures.tex1) end @@ -416,7 +416,7 @@ for id = 1, #FeatureDefs do if not wreckNormalTex then table.insert(failedwrecknormaltex, 1, featureDef.name) - Spring.Echo("Failed to find normal map for unit wreck: ", featureDef.name, lowercasetex1) + SpringShared.Echo("Failed to find normal map for unit wreck: ", featureDef.name, lowercasetex1) end featureMaterials[id] = { "featuresMetalDeadOrHeap", NORMALTEX = wreckNormalTex } @@ -429,7 +429,7 @@ for id = 1, #FeatureDefs do end if #failedwrecknormaltex > 0 then - Spring.Echo("Failed to find normal map for unit wreck: ", table.concat(failedwrecknormaltex, ",")) + SpringShared.Echo("Failed to find normal map for unit wreck: ", table.concat(failedwrecknormaltex, ",")) end -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- diff --git a/modelmaterials/Templates/defaultMaterialTemplate.lua b/modelmaterials/Templates/defaultMaterialTemplate.lua index 31ce829e9d8..96670e00123 100644 --- a/modelmaterials/Templates/defaultMaterialTemplate.lua +++ b/modelmaterials/Templates/defaultMaterialTemplate.lua @@ -1764,16 +1764,16 @@ local function SunChanged(luaShader) luaShader:SetUniformAlways("sunSpecular", gl.GetSun("specular", "unit")) luaShader:SetUniformFloatArrayAlways("pbrParams", { - Spring.GetConfigFloat("tonemapA", 4.75), - Spring.GetConfigFloat("tonemapB", 0.75), - Spring.GetConfigFloat("tonemapC", 3.5), - Spring.GetConfigFloat("tonemapD", 0.85), - Spring.GetConfigFloat("tonemapE", 1.0), - Spring.GetConfigFloat("envAmbient", 0.25), - Spring.GetConfigFloat("unitSunMult", 1.0), - Spring.GetConfigFloat("unitExposureMult", 1.0), + SpringUnsynced.GetConfigFloat("tonemapA", 4.75), + SpringUnsynced.GetConfigFloat("tonemapB", 0.75), + SpringUnsynced.GetConfigFloat("tonemapC", 3.5), + SpringUnsynced.GetConfigFloat("tonemapD", 0.85), + SpringUnsynced.GetConfigFloat("tonemapE", 1.0), + SpringUnsynced.GetConfigFloat("envAmbient", 0.25), + SpringUnsynced.GetConfigFloat("unitSunMult", 1.0), + SpringUnsynced.GetConfigFloat("unitExposureMult", 1.0), }) - luaShader:SetUniformFloatAlways("gamma", Spring.GetConfigFloat("modelGamma", 1.0)) + luaShader:SetUniformFloatAlways("gamma", SpringUnsynced.GetConfigFloat("modelGamma", 1.0)) end defaultMaterialTemplate.ProcessOptions = ProcessOptions diff --git a/modelmaterials_gl4/001_units_s3o_assimp.lua b/modelmaterials_gl4/001_units_s3o_assimp.lua index b865e52ebd7..37c6e6a4bb4 100644 --- a/modelmaterials_gl4/001_units_s3o_assimp.lua +++ b/modelmaterials_gl4/001_units_s3o_assimp.lua @@ -15,7 +15,7 @@ local unitsNormalMapTemplate = table.merge(matTemplate, { "#define ROUGHNESS_AA 1.0", - "#define ENV_SMPL_NUM " .. tostring(Spring.GetConfigInt("ENV_SMPL_NUM", 64)), + "#define ENV_SMPL_NUM " .. tostring(SpringUnsynced.GetConfigInt("ENV_SMPL_NUM", 64)), "#define USE_ENVIRONMENT_DIFFUSE 1", "#define USE_ENVIRONMENT_SPECULAR 1", @@ -30,7 +30,7 @@ local unitsNormalMapTemplate = table.merge(matTemplate, { "#define ROUGHNESS_AA 1.0", - "#define ENV_SMPL_NUM " .. tostring(Spring.GetConfigInt("ENV_SMPL_NUM", 64)), + "#define ENV_SMPL_NUM " .. tostring(SpringUnsynced.GetConfigInt("ENV_SMPL_NUM", 64)), "#define USE_ENVIRONMENT_DIFFUSE 1", "#define USE_ENVIRONMENT_SPECULAR 1", @@ -61,15 +61,15 @@ local GL_FLOAT = 0x1406 local GL_INT = 0x1404 -- args= local mySetMaterialUniform = { - [false] = Spring.UnitRendering.SetForwardMaterialUniform, - [true] = Spring.UnitRendering.SetDeferredMaterialUniform, + [false] = SpringUnsynced.UnitRendering.SetForwardMaterialUniform, + [true] = SpringUnsynced.UnitRendering.SetDeferredMaterialUniform, } local armTanks = {} local corTanks = {} local raptorUnits = {} local otherUnits = {} -local spGetUnitHealth = Spring.GetUnitHealth +local spGetUnitHealth = SpringShared.GetUnitHealth local unitsHealth = {} --cache local healthArray = { [1] = 0.0 } @@ -147,8 +147,8 @@ local function SendUnitID(unitID, hasStd, hasDef, hasShad) end end -local spGetUnitVelocity = Spring.GetUnitVelocity -local spGetUnitDirection = Spring.GetUnitDirection +local spGetUnitVelocity = SpringShared.GetUnitVelocity +local spGetUnitDirection = SpringShared.GetUnitDirection local floor = math.floor local treadSpeeds = {} --cache local treadsArray = { [1] = 0.0 } diff --git a/modelmaterials_gl4/128_features_special.lua b/modelmaterials_gl4/128_features_special.lua index bb503a5b631..1c4a5050162 100644 --- a/modelmaterials_gl4/128_features_special.lua +++ b/modelmaterials_gl4/128_features_special.lua @@ -7,11 +7,11 @@ local GL_FLOAT = 0x1406 local GL_INT = 0x1404 -- args= local mySetMaterialUniform = { - [false] = Spring.FeatureRendering.SetForwardMaterialUniform, - [true] = Spring.FeatureRendering.SetDeferredMaterialUniform, + [false] = SpringUnsynced.FeatureRendering.SetForwardMaterialUniform, + [true] = SpringUnsynced.FeatureRendering.SetDeferredMaterialUniform, } -local spGetFeatureHealth = Spring.GetFeatureHealth +local spGetFeatureHealth = SpringShared.GetFeatureHealth local featuresHealth = {} --cache local healthArray = { [1] = 0.0 } @@ -398,11 +398,11 @@ for id = 1, #FeatureDefs do local fromUnit = featureDef.name:find("_dead") or featureDef.name:find("_heap") if fromUnit then - Spring.PreloadFeatureDefModel(id) + SpringUnsynced.PreloadFeatureDefModel(id) local lowercasetex1 = "" if featureDef.model.textures.tex1 == nil then - Spring.Echo("nil texture 1 detected for", featureDef.name) + SpringShared.Echo("nil texture 1 detected for", featureDef.name) else lowercasetex1 = string.lower(featureDef.model.textures.tex1) end @@ -416,7 +416,7 @@ for id = 1, #FeatureDefs do if not wreckNormalTex then table.insert(failedwrecknormaltex, 1, featureDef.name) - Spring.Echo("Failed to find normal map for unit wreck: ", featureDef.name, lowercasetex1) + SpringShared.Echo("Failed to find normal map for unit wreck: ", featureDef.name, lowercasetex1) end featureMaterials[id] = { "featuresMetalDeadOrHeap", NORMALTEX = wreckNormalTex } @@ -429,7 +429,7 @@ for id = 1, #FeatureDefs do end if #failedwrecknormaltex > 0 then - Spring.Echo("Failed to find normal map for unit wreck: ", table.concat(failedwrecknormaltex, ",")) + SpringShared.Echo("Failed to find normal map for unit wreck: ", table.concat(failedwrecknormaltex, ",")) end -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- diff --git a/modelmaterials_gl4/templates/defaultMaterialTemplate.lua b/modelmaterials_gl4/templates/defaultMaterialTemplate.lua index e19ff065df2..5cec6b5d047 100644 --- a/modelmaterials_gl4/templates/defaultMaterialTemplate.lua +++ b/modelmaterials_gl4/templates/defaultMaterialTemplate.lua @@ -52,7 +52,7 @@ local defaultMaterialTemplate = { "#define ROUGHNESS_AA 1.0", - "#define ENV_SMPL_NUM " .. tostring(Spring.GetConfigInt("ENV_SMPL_NUM", 64)), + "#define ENV_SMPL_NUM " .. tostring(SpringUnsynced.GetConfigInt("ENV_SMPL_NUM", 64)), "#define USE_ENVIRONMENT_DIFFUSE 1", "#define USE_ENVIRONMENT_SPECULAR 1", @@ -70,7 +70,7 @@ local defaultMaterialTemplate = { "#define ROUGHNESS_AA 1.0", - "#define ENV_SMPL_NUM " .. tostring(Spring.GetConfigInt("ENV_SMPL_NUM", 64)), + "#define ENV_SMPL_NUM " .. tostring(SpringUnsynced.GetConfigInt("ENV_SMPL_NUM", 64)), "#define USE_ENVIRONMENT_DIFFUSE 1", "#define USE_ENVIRONMENT_SPECULAR 1", @@ -105,7 +105,7 @@ local defaultMaterialTemplate = { "#define ROUGHNESS_AA 1.0", - "#define ENV_SMPL_NUM " .. tostring(Spring.GetConfigInt("ENV_SMPL_NUM", 64)), + "#define ENV_SMPL_NUM " .. tostring(SpringUnsynced.GetConfigInt("ENV_SMPL_NUM", 64)), "#define USE_ENVIRONMENT_DIFFUSE 1", "#define USE_ENVIRONMENT_SPECULAR 1", @@ -193,16 +193,16 @@ local shaderPlugins = { local function SunChanged(luaShader) luaShader:SetUniformFloatArrayAlways("pbrParams", { - Spring.GetConfigFloat("tonemapA", 4.75), - Spring.GetConfigFloat("tonemapB", 0.75), - Spring.GetConfigFloat("tonemapC", 3.5), - Spring.GetConfigFloat("tonemapD", 0.85), - Spring.GetConfigFloat("tonemapE", 1.0), - Spring.GetConfigFloat("envAmbient", 0.125), - Spring.GetConfigFloat("unitSunMult", 1.0), - Spring.GetConfigFloat("unitExposureMult", 1.0), + SpringUnsynced.GetConfigFloat("tonemapA", 4.75), + SpringUnsynced.GetConfigFloat("tonemapB", 0.75), + SpringUnsynced.GetConfigFloat("tonemapC", 3.5), + SpringUnsynced.GetConfigFloat("tonemapD", 0.85), + SpringUnsynced.GetConfigFloat("tonemapE", 1.0), + SpringUnsynced.GetConfigFloat("envAmbient", 0.125), + SpringUnsynced.GetConfigFloat("unitSunMult", 1.0), + SpringUnsynced.GetConfigFloat("unitExposureMult", 1.0), }) - luaShader:SetUniformFloatAlways("gamma", Spring.GetConfigFloat("modelGamma", 1.0)) + luaShader:SetUniformFloatAlways("gamma", SpringUnsynced.GetConfigFloat("modelGamma", 1.0)) end defaultMaterialTemplate.SunChangedOrig = SunChanged diff --git a/modules/commands.lua b/modules/commands.lua index b9ac46412fc..55d630d1a67 100644 --- a/modules/commands.lua +++ b/modules/commands.lua @@ -3,7 +3,7 @@ local bit_and = math.bit_and -local spGiveOrderToUnit = Spring.GiveOrderToUnit +local spGiveOrderToUnit = SpringSynced.GiveOrderToUnit local CMD_INSERT = CMD.INSERT diff --git a/modules/customcommands.lua b/modules/customcommands.lua index 6acc586d422..43c646743c3 100644 --- a/modules/customcommands.lua +++ b/modules/customcommands.lua @@ -50,7 +50,7 @@ local globalCmdDeprecatedShown = false local importCommandsToObject = function(object) if not globalCmdDeprecatedShown and not object.gadgetHandler then local msg = "Should not use customcmds.h.lua or importCommandsToObject. Use the CMD table directly, or read modules/customcommands.lua for more information." - Spring.Log("CMD", LOG.DEPRECATED, msg) + SpringShared.Log("CMD", LOG.DEPRECATED, msg) globalCmdDeprecatedShown = true end for code, cmdID in pairs(gameCommands) do @@ -63,10 +63,10 @@ end for code, cmdID in pairs(gameCommands) do if CMD[cmdID] then - Spring.Log("CMD", LOG.ERROR, "Duplicate command id: " .. code .. " " .. tostring(cmdID) .. "!") + SpringShared.Log("CMD", LOG.ERROR, "Duplicate command id: " .. code .. " " .. tostring(cmdID) .. "!") end if CMD[code] then - Spring.Log("CMD", LOG.ERROR, "Duplicate command code: " .. code .. " " .. tostring(cmdID) .. "!") + SpringShared.Log("CMD", LOG.ERROR, "Duplicate command code: " .. code .. " " .. tostring(cmdID) .. "!") end gameCommands[cmdID] = code end diff --git a/modules/graphics/LuaShader.lua b/modules/graphics/LuaShader.lua index 5747398ca3b..2b79b119d20 100644 --- a/modules/graphics/LuaShader.lua +++ b/modules/graphics/LuaShader.lua @@ -11,7 +11,7 @@ local glUniformInt = gl.UniformInt local glUniformMatrix = gl.UniformMatrix local glUniformArray = gl.UniformArray -local gldebugannotations = (Spring.GetConfigInt("gldebugannotations") == 1) +local gldebugannotations = (SpringUnsynced.GetConfigInt("gldebugannotations") == 1) local function new(class, shaderParams, shaderName, logEntries) local logEntriesSanitized @@ -43,11 +43,11 @@ local function IsTesselationShaderSupported() end local function IsDeferredShadingEnabled() - return (Spring.GetConfigInt("AllowDeferredMapRendering") == 1) and (Spring.GetConfigInt("AllowDeferredModelRendering") == 1) and (Spring.GetConfigInt("AdvMapShading") == 1) + return (SpringUnsynced.GetConfigInt("AllowDeferredMapRendering") == 1) and (SpringUnsynced.GetConfigInt("AllowDeferredModelRendering") == 1) and (SpringUnsynced.GetConfigInt("AdvMapShading") == 1) end local function GetAdvShadingActive() - local _, advMapShading = Spring.HaveAdvShading() + local _, advMapShading = SpringUnsynced.HaveAdvShading() if advMapShading == nil then advMapShading = true end --old engine @@ -512,8 +512,8 @@ LuaShader.GetQuaternionDefs = GetQuaternionDefs local function CheckShaderUpdates(shadersourcecache, delaytime) -- todo: extract shaderconfig - if shadersourcecache.forceupdate or shadersourcecache.lastshaderupdate == nil or Spring.DiffTimers(Spring.GetTimer(), shadersourcecache.lastshaderupdate) > (delaytime or 0.5) then - shadersourcecache.lastshaderupdate = Spring.GetTimer() + if shadersourcecache.forceupdate or shadersourcecache.lastshaderupdate == nil or SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), shadersourcecache.lastshaderupdate) > (delaytime or 0.5) then + shadersourcecache.lastshaderupdate = SpringUnsynced.GetTimer() local vsSrcNew = (shadersourcecache.vssrcpath and VFS.LoadFile(shadersourcecache.vssrcpath)) or shadersourcecache.vsSrc local fsSrcNew = (shadersourcecache.fssrcpath and VFS.LoadFile(shadersourcecache.fssrcpath)) or shadersourcecache.fsSrc local gsSrcNew = (shadersourcecache.gssrcpath and VFS.LoadFile(shadersourcecache.gssrcpath)) or shadersourcecache.gsSrc @@ -521,7 +521,7 @@ local function CheckShaderUpdates(shadersourcecache, delaytime) --Spring.Echo("No change in shaders") return nil else - local compilestarttime = Spring.GetTimer() + local compilestarttime = SpringUnsynced.GetTimer() shadersourcecache.vsSrc = vsSrcNew shadersourcecache.fsSrc = fsSrcNew shadersourcecache.gsSrc = gsSrcNew @@ -534,7 +534,7 @@ local function CheckShaderUpdates(shadersourcecache, delaytime) local printfpattern = "^[^/]*printf%s*%(%s*([%w_%.]+)%s*%)" local printf = nil if not fsSrcNew then - Spring.Echo("Warning: No fragment shader source found for", shadersourcecache.shaderName) + SpringShared.Echo("Warning: No fragment shader source found for", shadersourcecache.shaderName) end local fsSrcNewLines = string.lines(fsSrcNew) for i, line in ipairs(fsSrcNewLines) do @@ -564,7 +564,7 @@ local function CheckShaderUpdates(shadersourcecache, delaytime) local vardata = { name = glslvariable, count = glslvarcount, line = i, index = #printf["vars"], swizzle = swizzle, shaderstage = "f" } table.insert(printf["vars"], vardata) local replacementstring = string.format("if (all(lessThan(abs(mouseScreenPos.xy- (gl_FragCoord.xy + vec2(0.5, -1.5))),vec2(0.25) ))) { printfData[%i].%s = %s;} //printfData[INDEX] = vertexPos.xyzw;", vardata.index, string.sub("xyzw", 1, vardata.count), vardata.name) - Spring.Echo(string.format("Replacing f:%d %s", i, line)) + SpringShared.Echo(string.format("Replacing f:%d %s", i, line)) fsSrcNewLines[i] = replacementstring end end @@ -593,7 +593,7 @@ local function CheckShaderUpdates(shadersourcecache, delaytime) for i, line in ipairs(fsSrcNewLines) do if string.find(line, "#version", nil, true) then if line ~= "#version 430 core" then - Spring.Echo("Replacing shader version", line, "with #version 430 core") + SpringShared.Echo("Replacing shader version", line, "with #version 430 core") fsSrcNewLines[i] = "" table.insert(fsSrcNewLines, 1, "#version 430 core\n") break @@ -650,7 +650,7 @@ local function CheckShaderUpdates(shadersourcecache, delaytime) }, shadersourcecache.shaderName) local shaderCompiled = reinitshader:Initialize() if not shadersourcecache.silent then - Spring.Echo(shadersourcecache.shaderName, " recompiled in ", Spring.DiffTimers(Spring.GetTimer(), compilestarttime, true), "ms at", Spring.GetGameFrame(), "success", shaderCompiled or false) + SpringShared.Echo(shadersourcecache.shaderName, " recompiled in ", SpringUnsynced.DiffTimers(SpringUnsynced.GetTimer(), compilestarttime, true), "ms at", SpringShared.GetGameFrame(), "success", shaderCompiled or false) end if shaderCompiled then reinitshader.printf = printf @@ -760,11 +760,11 @@ function LuaShader:OutputLogEntry(text, isError) local warnErr = (isError and "error") or "warning" message = string.format("LuaShader: [%s] shader %s(s):\n%s", self.shaderName, warnErr, text) - Spring.Echo(message) + SpringShared.Echo(message) if isError then local linetable = self:CreateLineTable() - Spring.Echo(translateLines(linetable, text)) + SpringShared.Echo(translateLines(linetable, text)) end if self.logHash[message] == nil then @@ -777,7 +777,7 @@ function LuaShader:OutputLogEntry(text, isError) if newCnt == self.logEntries then message = message .. string.format("\nSupressing further %s of the same kind", warnErr) end - Spring.Echo(message) + SpringShared.Echo(message) end end @@ -799,7 +799,7 @@ local includeRegexps = { function LuaShader:HandleIncludes(shaderCode, shaderName) local incFiles = {} - local t1 = Spring.GetTimer() + local t1 = SpringUnsynced.GetTimer() repeat local incFile local regEx @@ -811,15 +811,15 @@ function LuaShader:HandleIncludes(shaderCode, shaderName) end end - Spring.Echo(shaderName, incFile) + SpringShared.Echo(shaderName, incFile) if incFile then shaderCode = string.gsub(shaderCode, regEx, "", 1) table.insert(incFiles, incFile) end until incFile == nil - local t2 = Spring.GetTimer() - Spring.Echo(Spring.DiffTimers(t2, t1, true)) + local t2 = SpringUnsynced.GetTimer() + SpringShared.Echo(SpringUnsynced.DiffTimers(t2, t1, true)) local includeText = "" for _, incFile in ipairs(incFiles) do @@ -900,7 +900,7 @@ function LuaShader:Compile(suppresswarnings) if location then self.uniformLocations[uniName] = location else - Spring.Echo(string.format("Notice from shader %s: Could not find location of uniform name: %s", "dunno", uniName)) + SpringShared.Echo(string.format("Notice from shader %s: Could not find location of uniform name: %s", "dunno", uniName)) end end @@ -937,7 +937,7 @@ function LuaShader:Activate() if self.printf then local bindingIndex = self.printf.SSBO:BindBufferRange(7) if bindingIndex <= 0 then - Spring.Echo("Failed to bind printfData SSBO for shader", self.shaderName) + SpringShared.Echo("Failed to bind printfData SSBO for shader", self.shaderName) end end @@ -994,7 +994,7 @@ function LuaShader:Deactivate() if not self.DrawPrintf then --Spring.Echo("creating DrawPrintf") - local fontfile3 = "fonts/monospaced/" .. Spring.GetConfigString("bar_font3", "SourceCodePro-Semibold.otf") + local fontfile3 = "fonts/monospaced/" .. SpringUnsynced.GetConfigString("bar_font3", "SourceCodePro-Semibold.otf") local fontSize = 16 local font3 = gl.LoadFont(fontfile3, 32, 0.5, 1) @@ -1011,7 +1011,7 @@ function LuaShader:Deactivate() xoffset = sometimesself end - local mx, my = Spring.GetMouseState() + local mx, my = SpringUnsynced.GetMouseState() mx = mx + xoffset my = my - 32 + yoffset @@ -1033,7 +1033,7 @@ function LuaShader:Deactivate() end my = my - fontSize - local vsx, vsy = Spring.GetViewGeometry() + local vsx, vsy = SpringUnsynced.GetViewGeometry() local alignment = "" if mx > (vsx - 400) then alignment = "r" diff --git a/modules/graphics/instancevboidtable.lua b/modules/graphics/instancevboidtable.lua index 93120030b85..a91baa188d0 100644 --- a/modules/graphics/instancevboidtable.lua +++ b/modules/graphics/instancevboidtable.lua @@ -14,7 +14,7 @@ local function makeInstanceVBOTable(layout, maxElements, myName, objectTypeAttri end local newInstanceVBO = gl.GetVBO(GL.ARRAY_BUFFER, true) if newInstanceVBO == nil then - Spring.Echo("makeInstanceVBOTable, cannot get VBO for", myName) + SpringShared.Echo("makeInstanceVBOTable, cannot get VBO for", myName) return nil end newInstanceVBO:Define(maxElements, layout) @@ -110,31 +110,31 @@ end local function comparetables(t1, t2, name) for k, v in pairs(t1) do if t2[k] == nil then - Spring.Echo("Key ", k, "with value", v, "existing in t1 does not exist in t2 in ", name) + SpringShared.Echo("Key ", k, "with value", v, "existing in t1 does not exist in t2 in ", name) elseif t2[k] ~= v then - Spring.Echo("Value ", v, "for", k, "existing in t1 does not match value for t2", t2[k], " in ", name) + SpringShared.Echo("Value ", v, "for", k, "existing in t1 does not match value for t2", t2[k], " in ", name) end end for k, v in pairs(t2) do if t1[k] == nil then - Spring.Echo("Key ", k, "with value", v, "existing in t2 does not exist in t1 in ", name) + SpringShared.Echo("Key ", k, "with value", v, "existing in t2 does not exist in t1 in ", name) elseif t1[k] ~= v then - Spring.Echo("Value ", v, "for", k, "existing in t2 does not match value for t1", t1[k], " in ", name) + SpringShared.Echo("Value ", v, "for", k, "existing in t2 does not match value for t1", t1[k], " in ", name) end end end local function dbgt(t, name) name = name or "" - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() local count = 0 local res = "" for k, v in pairs(t) do res = res .. tostring(k) .. ":" .. tostring(v) .. "," count = count + 1 end - Spring.Echo(tostring(gf) .. " " .. name .. " #" .. tostring(count) .. " {" .. res .. "}") + SpringShared.Echo(tostring(gf) .. " " .. name .. " #" .. tostring(count) .. " {" .. res .. "}") return res end @@ -180,8 +180,8 @@ local function resizeInstanceVBOTable(iT) --Spring.Echo("Resize", iT.myName, i, unitID, objecttype) if objecttype == "unitID" then -- Sanity check for unitIDs - if Spring.ValidUnitID(unitID) ~= true then - Spring.Echo("Invalid unitID", unitID, "at", i, "during resizing", iT.myName) + if SpringShared.ValidUnitID(unitID) ~= true then + SpringShared.Echo("Invalid unitID", unitID, "at", i, "during resizing", iT.myName) else iT.instanceVBO:InstanceDataFromUnitIDs(unitID, iT.objectTypeAttribID, i - 1) end @@ -190,8 +190,8 @@ local function resizeInstanceVBOTable(iT) iT.instanceVBO:InstanceDataFromUnitDefIDs(unitID, iT.objectTypeAttribID, nil, i - 1) iT.VAO:AddUnitDefsToSubmission(unitID) elseif objecttype == "featureID" then - if Spring.ValidFeatureID(unitID) ~= true then - Spring.Echo("Invalid featureID", unitID, "at", i, "during resizing", iT.myName) + if SpringShared.ValidFeatureID(unitID) ~= true then + SpringShared.Echo("Invalid featureID", unitID, "at", i, "during resizing", iT.myName) else iT.instanceVBO:InstanceDataFromFeatureIDs(unitID, iT.objectTypeAttribID, i - 1) end @@ -224,13 +224,13 @@ local function pushElementInstance(iT, thisInstance, instanceID, updateExisting, -- noUpload: prevent the VBO from being uploaded, if you feel like you are going to do a lot of ops and wish to manually upload when done instead -- unitID: if given, it will store then unitID corresponding to this instance, and will try to update the InstanceDataFromUnitIDs for this unit -- returns: the index of the instanceID in the table on success, else nil - if (objecttype == "unitID" and (Spring.ValidUnitID(unitID) == false)) or (objecttype == "featureID" and (Spring.ValidFeatureID(unitID) == false)) or (objecttype == "unitDefID" and (UnitDefs[unitID] == nil)) or (objecttype == "featureDefID" and (FeatureDefs[unitID] == nil)) then - Spring.Echo("Tried to push invalid", objecttype, unitID, "into", iT.myName, "with instanceID", instanceID, "returning nil") + if (objecttype == "unitID" and (SpringShared.ValidUnitID(unitID) == false)) or (objecttype == "featureID" and (SpringShared.ValidFeatureID(unitID) == false)) or (objecttype == "unitDefID" and (UnitDefs[unitID] == nil)) or (objecttype == "featureDefID" and (FeatureDefs[unitID] == nil)) then + SpringShared.Echo("Tried to push invalid", objecttype, unitID, "into", iT.myName, "with instanceID", instanceID, "returning nil") return nil end if #thisInstance ~= iT.instanceStep then - Spring.Echo("Trying to upload an oddly sized instance into", iT.myName, #thisInstance, "instead of ", iT.instanceStep) + SpringShared.Echo("Trying to upload an oddly sized instance into", iT.myName, #thisInstance, "instead of ", iT.instanceStep) end local iTusedElements = iT.usedElements local iTStep = iT.instanceStep @@ -254,7 +254,7 @@ local function pushElementInstance(iT, thisInstance, instanceID, updateExisting, isnewid = true else -- pre-existing ID, update or bail if updateExisting == nil then - Spring.Echo("Tried to add existing element to an instanceTable", iT.myName, instanceID) + SpringShared.Echo("Tried to add existing element to an instanceTable", iT.myName, instanceID) return nil else endOffset = (thisInstanceIndex - 1) * iTStep @@ -318,11 +318,11 @@ local function popElementInstance(iT, instanceID, noUpload) end if iT.instanceIDtoIndex[instanceID] == nil then -- if key is instanceID yet does not exist, then warn and bail - Spring.Echo("Tried to remove element ", instanceID, "From instanceTable", iT.myName, "but it does not exist in it") + SpringShared.Echo("Tried to remove element ", instanceID, "From instanceTable", iT.myName, "but it does not exist in it") return nil end if iT.usedElements == 0 then -- Dont remove the last element - Spring.Echo("Tried to remove element ", instanceID, "From instanceTable", iT.myName, "but it should be empty") + SpringShared.Echo("Tried to remove element ", instanceID, "From instanceTable", iT.myName, "but it should be empty") return nil end @@ -388,7 +388,7 @@ local function popElementInstance(iT, instanceID, noUpload) --Spring.Echo("Removing",instanceID,"/",iT.indextoUnitID[oldElementIndex], "Popping back", myunitID, "is it valid?", Spring.ValidUnitID(myunitID), oldElementIndex, lastElementIndex) if iT.debugZombies then - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() --Spring.Echo("Popping", instanceID) if iT.lastpopgameframe == nil then iT.lastpopgameframe = gf @@ -410,7 +410,7 @@ local function popElementInstance(iT, instanceID, noUpload) s = s .. " " .. tostring(zombie) --Spring.SendCommands({"pause 1"}) end - Spring.Echo(s) + SpringShared.Echo(s) Spring.Debug.TraceFullEcho(nil, nil, nil, dbgt(iT.indextoUnitID), dbgt(iT.indextoInstanceID)) iT.zombies = {} iT.numZombies = 0 @@ -438,10 +438,10 @@ local function popElementInstance(iT, instanceID, noUpload) end if objecttype == "unitID" or objecttype == "featureID" then - if objecttype == "unitID" and Spring.ValidUnitID(myunitID) then + if objecttype == "unitID" and SpringShared.ValidUnitID(myunitID) then iT.instanceVBO:InstanceDataFromUnitIDs(myunitID, iT.objectTypeAttribID, oldElementIndex - 1) --iT.VAO:AddUnitDefsToSubmission(unitID) - elseif objecttype == "featureID" and Spring.ValidFeatureID(myunitID) then + elseif objecttype == "featureID" and SpringShared.ValidFeatureID(myunitID) then iT.instanceVBO:InstanceDataFromFeatureIDs(myunitID, iT.objectTypeAttribID, oldElementIndex - 1) else if iT.debugZombies then @@ -449,7 +449,7 @@ local function popElementInstance(iT, instanceID, noUpload) --Spring.Debug.TraceFullEcho() --dbgt(iT.indextoUnitID) --dbgt(iT.indextoInstanceID) - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() if iT.lastpopgameframe == nil or iT.lastpopgameframe ~= gf then -- New gameframe iT.lastpopgameframe = gf iT.zombies = {} @@ -463,7 +463,7 @@ local function popElementInstance(iT, instanceID, noUpload) iT.numZombies = iT.numZombies + 1 end else - Spring.Echo("Tried to pop back an invalid unitID ", myunitID, "from", iT.myName, "while removing instance", instanceID, ". Ensure that you remove invalid units from your instance tables") + SpringShared.Echo("Tried to pop back an invalid unitID ", myunitID, "from", iT.myName, "while removing instance", instanceID, ". Ensure that you remove invalid units from your instance tables") Spring.Debug.TraceFullEcho() end end @@ -502,7 +502,7 @@ end local function dumpAndCompareInstanceData(iT) local gpuContents = iT.instanceVBO:Download(nil, nil, nil, true) for i = 1, iT.usedElements do - Spring.Echo(string.format("%s, instanceID =%s, element %d of %d", iT.myName, tostring(iT.indextoInstanceID[i]), i, iT.usedElements)) + SpringShared.Echo(string.format("%s, instanceID =%s, element %d of %d", iT.myName, tostring(iT.indextoInstanceID[i]), i, iT.usedElements)) local index = 1 local offset = (i - 1) * iT.instanceStep for j, layout in ipairs(iT.layout) do @@ -514,7 +514,7 @@ local function dumpAndCompareInstanceData(iT) index = index + 1 end local layoutstr = string.format(" ID=%d, name = %s, size = %d, type = %d, luaData = {%s}, gpuData={%s}", layout.id, layout.name, layout.size, layout.type or GL.FLOAT, luaData, gpuData) - Spring.Echo(layoutstr) + SpringShared.Echo(layoutstr) end end end @@ -536,8 +536,8 @@ local function uploadAllElements(iT) --Spring.Echo("Resize", iT.myName, i, unitID, objecttype) if objecttype == "unitID" then -- Sanity check for unitIDs - if Spring.ValidUnitID(unitID) ~= true then - Spring.Echo("Invalid unitID", unitID, "at", i, "during resizing", iT.myName) + if SpringShared.ValidUnitID(unitID) ~= true then + SpringShared.Echo("Invalid unitID", unitID, "at", i, "during resizing", iT.myName) else iT.instanceVBO:InstanceDataFromUnitIDs(unitID, iT.objectTypeAttribID, i - 1) end @@ -546,8 +546,8 @@ local function uploadAllElements(iT) iT.instanceVBO:InstanceDataFromUnitDefIDs(unitID, iT.objectTypeAttribID, nil, i - 1) iT.VAO:AddUnitDefsToSubmission(unitID) elseif objecttype == "featureID" then - if Spring.ValidFeatureID(unitID) ~= true then - Spring.Echo("Invalid featureID", unitID, "at", i, "during resizing", iT.myName) + if SpringShared.ValidFeatureID(unitID) ~= true then + SpringShared.Echo("Invalid featureID", unitID, "at", i, "during resizing", iT.myName) else iT.instanceVBO:InstanceDataFromFeatureIDs(unitID, iT.objectTypeAttribID, i - 1) end @@ -566,26 +566,26 @@ local function validateInstanceVBOIDTable(iT, calledfrom) local removethese = {} for i = 1, iT.usedElements do if iT.indextoInstanceID[i] == nil then - Spring.Echo(errorKey, "There is a hole in indextoInstanceID", iT.myName, "at", i, "out of", iT.usedElements, calledfrom) + SpringShared.Echo(errorKey, "There is a hole in indextoInstanceID", iT.myName, "at", i, "out of", iT.usedElements, calledfrom) --Spring.Echo() if iT.indextoUnitID[i] == nil then - Spring.Echo(errorKey, "It is also missing from indextoUnitID") + SpringShared.Echo(errorKey, "It is also missing from indextoUnitID") else - Spring.Echo(errorKey, "But it does exist in indextoUnitID with an unitID of ", iT.indextoUnitID[i]) - Spring.Echo(errorKey, "This is valid?", Spring.GetUnitPosition(iT.indextoUnitID[i])) + SpringShared.Echo(errorKey, "But it does exist in indextoUnitID with an unitID of ", iT.indextoUnitID[i]) + SpringShared.Echo(errorKey, "This is valid?", SpringShared.GetUnitPosition(iT.indextoUnitID[i])) end else local instanceID = iT.indextoInstanceID[i] local objecttype = iT.indextoObjectType[i] if iT.instanceIDtoIndex[instanceID] == nil then - Spring.Echo(errorKey, "There is a hole instanceIDtoIndex", iT.myName, "at", i, " iT.instanceIDtoIndex[instanceID] == nil ") + SpringShared.Echo(errorKey, "There is a hole instanceIDtoIndex", iT.myName, "at", i, " iT.instanceIDtoIndex[instanceID] == nil ") elseif iT.instanceIDtoIndex[instanceID] ~= i then - Spring.Echo(errorKey, "There is a problem in indextoInstanceID", iT.myName, "at i =", i, " iT.indextoInstanceID[instanceID] ~= i, it is instead: ", iT.indextoInstanceID[instanceID]) + SpringShared.Echo(errorKey, "There is a problem in indextoInstanceID", iT.myName, "at i =", i, " iT.indextoInstanceID[instanceID] ~= i, it is instead: ", iT.indextoInstanceID[instanceID]) end if instanceID and objecttype and objecttype == "unitID" then local unitID = iT.indextoUnitID[i] - if Spring.ValidUnitID(unitID) ~= true then + if SpringShared.ValidUnitID(unitID) ~= true then removethese[instanceID] = true end end @@ -597,7 +597,7 @@ local function validateInstanceVBOIDTable(iT, calledfrom) popElementInstance(iT, instanceID) end if string.len(idsremoved) > 1 then - Spring.Echo(errorKey, " removed invalid instanceIDs", idsremoved) + SpringShared.Echo(errorKey, " removed invalid instanceIDs", idsremoved) end --[[ local indextoInstanceIDsize = counttable(iT.indextoInstanceID) diff --git a/modules/graphics/instancevbotable.lua b/modules/graphics/instancevbotable.lua index 52a8bec7452..62e1160a917 100644 --- a/modules/graphics/instancevbotable.lua +++ b/modules/graphics/instancevbotable.lua @@ -1,5 +1,5 @@ local GL_BUFFER = 0x82E0 -local gldebugannotations = (Spring.GetConfigInt("gldebugannotations") == 1) +local gldebugannotations = (SpringUnsynced.GetConfigInt("gldebugannotations") == 1) --Spring.Echo("gldebugannotations", gldebugannotations) local function makeInstanceVBOTable(layout, maxElements, myName, unitIDattribID) -- layout: this must be an array of tables with at least the following specified: {{id = 1, name = 'optional', size = 4}} @@ -15,7 +15,7 @@ local function makeInstanceVBOTable(layout, maxElements, myName, unitIDattribID) end local newInstanceVBO = gl.GetVBO(GL.ARRAY_BUFFER, true) if newInstanceVBO == nil then - Spring.Echo("makeInstanceVBOTable, cannot get VBO for", myName) + SpringShared.Echo("makeInstanceVBOTable, cannot get VBO for", myName) return nil end newInstanceVBO:Define(maxElements, layout) @@ -246,24 +246,24 @@ end local function comparetables(t1, t2, name) for k, v in pairs(t1) do if t2[k] == nil then - Spring.Echo("Key ", k, "with value", v, "existing in t1 does not exist in t2 in ", name) + SpringShared.Echo("Key ", k, "with value", v, "existing in t1 does not exist in t2 in ", name) elseif t2[k] ~= v then - Spring.Echo("Value ", v, "for", k, "existing in t1 does not match value for t2", t2[k], " in ", name) + SpringShared.Echo("Value ", v, "for", k, "existing in t1 does not match value for t2", t2[k], " in ", name) end end for k, v in pairs(t2) do if t1[k] == nil then - Spring.Echo("Key ", k, "with value", v, "existing in t2 does not exist in t1 in ", name) + SpringShared.Echo("Key ", k, "with value", v, "existing in t2 does not exist in t1 in ", name) elseif t1[k] ~= v then - Spring.Echo("Value ", v, "for", k, "existing in t2 does not match value for t1", t1[k], " in ", name) + SpringShared.Echo("Value ", v, "for", k, "existing in t2 does not match value for t1", t1[k], " in ", name) end end end local function dbgt(t, name) name = name or "" - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() local count = 0 local res = "" for k, v in pairs(t) do @@ -272,7 +272,7 @@ local function dbgt(t, name) count = count + 1 end end - Spring.Echo(tostring(gf) .. " " .. name .. " #" .. tostring(count) .. " {" .. res .. "}") + SpringShared.Echo(tostring(gf) .. " " .. name .. " #" .. tostring(count) .. " {" .. res .. "}") return res end @@ -291,21 +291,21 @@ local function validateInstanceVBOTable(iT, calledfrom) -- check that instanceIDtoIndex and indextoInstanceID are valid and contigous: for i = 1, iT.usedElements do if iT.indextoInstanceID[i] == nil then - Spring.Echo("There is a hole in indextoInstanceID", iT.myName, "at", i, "out of", iT.usedElements, calledfrom) + SpringShared.Echo("There is a hole in indextoInstanceID", iT.myName, "at", i, "out of", iT.usedElements, calledfrom) --Spring.Echo() if iT.indextoUnitID[i] == nil then - Spring.Echo("It is also missing from indextoUnitID") + SpringShared.Echo("It is also missing from indextoUnitID") else - Spring.Echo("But it does exist in indextoUnitID with an unitID of ", iT.indextoUnitID[i]) - Spring.Echo("This is valid?", Spring.GetUnitPosition(iT.indextoUnitID[i])) + SpringShared.Echo("But it does exist in indextoUnitID with an unitID of ", iT.indextoUnitID[i]) + SpringShared.Echo("This is valid?", SpringShared.GetUnitPosition(iT.indextoUnitID[i])) end else local instanceID = iT.indextoInstanceID[i] if iT.instanceIDtoIndex[instanceID] == nil then - Spring.Echo("There is a hole instanceIDtoIndex", iT.myName, "at", i, " iT.instanceIDtoIndex[instanceID] == nil ") + SpringShared.Echo("There is a hole instanceIDtoIndex", iT.myName, "at", i, " iT.instanceIDtoIndex[instanceID] == nil ") elseif iT.instanceIDtoIndex[instanceID] ~= i then - Spring.Echo("There is a problem in indextoInstanceID", iT.myName, "at i =", i, " iT.indextoInstanceID[instanceID] ~= i, it is instead: ", iT.indextoInstanceID[instanceID]) + SpringShared.Echo("There is a problem in indextoInstanceID", iT.myName, "at i =", i, " iT.indextoInstanceID[instanceID] ~= i, it is instead: ", iT.indextoInstanceID[instanceID]) end end end @@ -313,7 +313,7 @@ local function validateInstanceVBOTable(iT, calledfrom) local instanceIDtoIndexsize = counttable(iT.instanceIDtoIndex) local indextoUnitID = counttable(iT.indextoUnitID) if (indextoInstanceIDsize ~= instanceIDtoIndexsize) or (instanceIDtoIndexsize ~= indextoUnitID) then - Spring.Echo("Table size mismatch during validation of", iT.myName, indextoInstanceIDsize, instanceIDtoIndexsize, indextoUnitID) + SpringShared.Echo("Table size mismatch during validation of", iT.myName, indextoInstanceIDsize, instanceIDtoIndexsize, indextoUnitID) end end @@ -325,31 +325,31 @@ function locateInvalidUnits(iT) local invalidcount = 0 for i, unitID in ipairs(iT.indextoUnitID) do if iT.featureIDs then - if Spring.ValidFeatureID(unitID) then - local px, py, pz = Spring.GetFeaturePosition(unitID) - local fdefname = FeatureDefs[Spring.GetFeatureDefID(unitID)].name + if SpringShared.ValidFeatureID(unitID) then + local px, py, pz = SpringShared.GetFeaturePosition(unitID) + local fdefname = FeatureDefs[SpringShared.GetFeatureDefID(unitID)].name iT.validinfo[unitID] = { px = px, py = py, pz = pz, fdefname = fdefname } else - Spring.SendCommands({ "pause 1" }) - Spring.Echo("INVALID feature, last seen at", unitID) + SpringUnsynced.SendCommands({ "pause 1" }) + SpringShared.Echo("INVALID feature, last seen at", unitID) local vi = iT.validinfo[unitID] local markertext = tostring(unitID) .. "," .. dbgt(vi) - Spring.MarkerAddPoint(vi.px, vi.py, vi.pz, markertext) + SpringUnsynced.MarkerAddPoint(vi.px, vi.py, vi.pz, markertext) invalidcount = invalidcount + 1 end else - if Spring.ValidUnitID(unitID) then - local px, py, pz = Spring.GetUnitPosition(unitID) - local unitDefID = Spring.GetUnitDefID(unitID) + if SpringShared.ValidUnitID(unitID) then + local px, py, pz = SpringShared.GetUnitPosition(unitID) + local unitDefID = SpringShared.GetUnitDefID(unitID) local unitdefname = (unitDefID and UnitDefs[unitDefID].name) or "unknown:nil" iT.validinfo[unitID] = { px = px, py = py, pz = pz, unitdefname = unitdefname } else - Spring.SendCommands({ "pause 1" }) - Spring.Echo(iT.myName, " INVALID unitID", unitID, "#elements", iT.usedElements, "last seen at tablepos:", i) + SpringUnsynced.SendCommands({ "pause 1" }) + SpringShared.Echo(iT.myName, " INVALID unitID", unitID, "#elements", iT.usedElements, "last seen at tablepos:", i) local vi = iT.validinfo[unitID] local markertext = tostring(unitID) .. "," .. dbgt(vi) - Spring.MarkerAddPoint(vi.px, vi.py, vi.pz, markertext) + SpringUnsynced.MarkerAddPoint(vi.px, vi.py, vi.pz, markertext) invalidcount = invalidcount + 1 end end @@ -388,9 +388,9 @@ local function resizeInstanceVBOTable(iT) for i, objectID in ipairs(iT.indextoUnitID) do local isValidID = false if iT.featureIDs then - isValidID = Spring.ValidFeatureID(objectID) + isValidID = SpringShared.ValidFeatureID(objectID) else - isValidID = Spring.ValidUnitID(objectID) + isValidID = SpringShared.ValidUnitID(objectID) end if isValidID then local offset = new_usedElements * iTStep @@ -406,7 +406,7 @@ local function resizeInstanceVBOTable(iT) --Spring.Echo("Resize:",currentInstanceID, iT.indextoUnitID[i] ) invalidcount = invalidcount + 1 else - Spring.Echo("Warning: Found invalid unit/featureID", objectID, "at", i, "while resizing", iT.myName) + SpringShared.Echo("Warning: Found invalid unit/featureID", objectID, "at", i, "while resizing", iT.myName) end end @@ -465,7 +465,7 @@ local function pushElementInstance(iT, thisInstance, instanceID, updateExisting, -- unitID: if given, it will store then unitID corresponding to this instance, and will try to update the InstanceDataFromUnitIDs for this unit -- returns: the index of the instanceID in the table on success, else nil if #thisInstance ~= iT.instanceStep then - Spring.Echo("Trying to upload an oddly sized instance into", iT.myName, #thisInstance, "instead of ", iT.instanceStep) + SpringShared.Echo("Trying to upload an oddly sized instance into", iT.myName, #thisInstance, "instead of ", iT.instanceStep) Spring.Debug.TraceFullEcho(20, 20, 20, "pushElementInstance Failure:" .. iT.myName) end local iTusedElements = iT.usedElements @@ -489,7 +489,7 @@ local function pushElementInstance(iT, thisInstance, instanceID, updateExisting, iT.indextoInstanceID[thisInstanceIndex] = instanceID else -- pre-existing ID, update or bail if updateExisting == nil then - Spring.Echo("Tried to add existing element to an instanceTable", iT.myName, instanceID) + SpringShared.Echo("Tried to add existing element to an instanceTable", iT.myName, instanceID) return nil else endOffset = (thisInstanceIndex - 1) * iTStep @@ -503,12 +503,12 @@ local function pushElementInstance(iT, thisInstance, instanceID, updateExisting, if unitID ~= nil then local isvalidid if iT.featureIDs then - isvalidid = Spring.ValidFeatureID(unitID) + isvalidid = SpringShared.ValidFeatureID(unitID) else - isvalidid = Spring.ValidUnitID(unitID) + isvalidid = SpringShared.ValidUnitID(unitID) end if isvalidid == false then - Spring.Echo("Error: Attempted to push an invalid unit/featureID", unitID, "into", iT.myName) + SpringShared.Echo("Error: Attempted to push an invalid unit/featureID", unitID, "into", iT.myName) noUpload = true Spring.Debug.TraceFullEcho(20, 20, 20, "invalid unit/featureID in " .. iT.myName) end @@ -541,17 +541,17 @@ local function popElementInstance(iT, instanceID, noUpload) -- noUpload: prevent the VBO from being uploaded, if you feel like you are going to do a lot of ops and wish to manually upload when done instead -- returns nil on failure, the the index of the element on success if instanceID == nil then - Spring.Echo("Tried to remove element with nil instanceID from instanceTable " .. iT.myName) + SpringShared.Echo("Tried to remove element with nil instanceID from instanceTable " .. iT.myName) return nil end if iT.instanceIDtoIndex[instanceID] == nil then -- if key is instanceID yet does not exist, then warn and bail - Spring.Echo("Tried to remove element ", instanceID, "From instanceTable", iT.myName, "but it does not exist in it") + SpringShared.Echo("Tried to remove element ", instanceID, "From instanceTable", iT.myName, "but it does not exist in it") Spring.Debug.TraceFullEcho(10, 10, 3, iT.myName) return nil end if iT.usedElements == 0 then -- Dont remove the last element - Spring.Echo("Tried to remove element ", instanceID, "From instanceTable", iT.myName, "but it should be empty") + SpringShared.Echo("Tried to remove element ", instanceID, "From instanceTable", iT.myName, "but it should be empty") return nil end @@ -583,7 +583,7 @@ local function popElementInstance(iT, instanceID, noUpload) else local lastElementInstanceID = iT.indextoInstanceID[lastElementIndex] if lastElementInstanceID == nil then -- - Spring.Echo("We somehow have a nil element at the back of the array, which is completely invalid, probably about to crash", iT.myName) + SpringShared.Echo("We somehow have a nil element at the back of the array, which is completely invalid, probably about to crash", iT.myName) dbgt(iT.instanceIDtoIndex, "instanceIDtoIndex") dbgt(iT.indextoInstanceID, "indextoInstanceID") dbgt(iT.indextoUnitID, "indextoUnitID") @@ -613,11 +613,11 @@ local function popElementInstance(iT, instanceID, noUpload) --Spring.Echo("popElementInstance,unitID, iT.unitIDattribID, thisInstanceIndex",unitID, iT.unitIDattribID, oldElementIndex) local popunitID = iT.indextoUnitID[lastElementIndex] if popunitID == nil then - Spring.Echo("TODO: what the f is happening here?, how the f could we have popped a nil from the back of?", iT.myName) -- TODO TODO + SpringShared.Echo("TODO: what the f is happening here?, how the f could we have popped a nil from the back of?", iT.myName) -- TODO TODO end if iT.debugZombies then - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() --Spring.Echo("Popping", instanceID) if iT.lastpopgameframe == nil then iT.lastpopgameframe = gf @@ -630,11 +630,11 @@ local function popElementInstance(iT, instanceID, noUpload) local s = "Warning: We have " .. tostring(iT.numZombies) .. " zombie units left over in " .. iT.myName for zombie, gf in pairs(iT.zombies) do s = s .. " " .. tostring(zombie) .. "/" .. tostring(gf) - Spring.Echo("ZOMBIE instanceID", zombie, "gf", gf) + SpringShared.Echo("ZOMBIE instanceID", zombie, "gf", gf) --Spring.SendCommands({"pause 1"}) Spring.Debug.TraceFullEcho(nil, nil, nil, iT.myName) end - Spring.Echo(s) + SpringShared.Echo(s) iT.zombies = {} iT.numZombies = 0 end @@ -651,7 +651,7 @@ local function popElementInstance(iT, instanceID, noUpload) iT.indextoUnitID[oldElementIndex] = popunitID iT.indextoUnitID[lastElementIndex] = nil - if (iT.featureIDs and Spring.ValidFeatureID(popunitID)) or Spring.ValidUnitID(popunitID) then + if (iT.featureIDs and SpringShared.ValidFeatureID(popunitID)) or SpringShared.ValidUnitID(popunitID) then if noUpload ~= true then if iT.featureIDs then iT.instanceVBO:InstanceDataFromFeatureIDs(popunitID, iT.unitIDattribID, oldElementIndex - 1) @@ -663,7 +663,7 @@ local function popElementInstance(iT, instanceID, noUpload) if iT.debugZombies then --Spring.Echo("Warning: Tried to pop back an invalid" .. ((iT.featureIDs and "featureID") or "unitID"), popunitID, "from", iT.myName, "while removing instance", instanceID, counttable(iT.instanceIDtoIndex), counttable(iT.indextoInstanceID), counttable(iT.indextoUnitID)) --Spring.Debug.TraceFullEcho() - local gf = Spring.GetGameFrame() + local gf = SpringShared.GetGameFrame() if iT.lastpopgameframe == nil or iT.lastpopgameframe ~= gf then -- New gameframe iT.lastpopgameframe = gf iT.zombies = {} @@ -690,7 +690,7 @@ local function getElementInstanceData(iT, instanceID, cacheTable) -- instanceID: an optional key given to the item, so it can be easily removed by reference, defaults to the index of the instance in the buffer (1 based) local instanceIndex = iT.instanceIDtoIndex[instanceID] if instanceIndex == nil then - Spring.Echo("Tried to getElementInstanceData from", iT.myName, instanceID, "but it does not exist") + SpringShared.Echo("Tried to getElementInstanceData from", iT.myName, instanceID, "but it does not exist") return nil end local iData = cacheTable or {} @@ -798,9 +798,9 @@ local function countInvalidUnitIDs(iT) for i, objectID in ipairs(iT.indextoUnitID) do local isValidID = false if iT.featureIDs then - isValidID = Spring.ValidFeatureID(objectID) + isValidID = SpringShared.ValidFeatureID(objectID) else - isValidID = Spring.ValidUnitID(objectID) + isValidID = SpringShared.ValidUnitID(objectID) end if isValidID then @@ -809,7 +809,7 @@ local function countInvalidUnitIDs(iT) end end if #invalids > 0 then - Spring.Echo(#invalids, "invalid IDs found in ", iT.myName) + SpringShared.Echo(#invalids, "invalid IDs found in ", iT.myName) end return invalids end diff --git a/modules/i18n/i18n.lua b/modules/i18n/i18n.lua index d79c1a5b1f6..48fb84bc7e8 100644 --- a/modules/i18n/i18n.lua +++ b/modules/i18n/i18n.lua @@ -94,16 +94,16 @@ function i18n.setLanguage(language) -- Manually switching fonts is requred until Spring handles font substitution at the engine level -- LuaUI reload must be invoked for widgets to refresh all their font objects local asianLanguage = language == "zh" - local currentFont = Spring.GetConfigString("bar_font") + local currentFont = SpringUnsynced.GetConfigString("bar_font") if asianLanguage and currentFont ~= asianFont then - Spring.SetConfigString("bar_font", asianFont) - Spring.SetConfigString("bar_font2", asianFont) - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigString("bar_font", asianFont) + SpringUnsynced.SetConfigString("bar_font2", asianFont) + SpringUnsynced.SendCommands("luarules reloadluaui") elseif not asianLanguage and currentFont == asianFont then - Spring.SetConfigString("bar_font", "Poppins-Regular.otf") - Spring.SetConfigString("bar_font2", "Exo2-SemiBold.otf") - Spring.SendCommands("luarules reloadluaui") + SpringUnsynced.SetConfigString("bar_font", "Poppins-Regular.otf") + SpringUnsynced.SetConfigString("bar_font2", "Exo2-SemiBold.otf") + SpringUnsynced.SendCommands("luarules reloadluaui") end end diff --git a/modules/i18n/i18nlib/i18n/init.lua b/modules/i18n/i18nlib/i18n/init.lua index 4fabea33ec8..7daca374225 100644 --- a/modules/i18n/i18nlib/i18n/init.lua +++ b/modules/i18n/i18nlib/i18n/init.lua @@ -145,7 +145,7 @@ function i18n.translate(key, data) local usedLocale = data.locale or locale -- if user elected to use English unit names, force `en` locale when translating a unit name - if (Spring.GetConfigInt("language_english_unit_names", 1) == 1) and key:sub(1, #"units.names.") == "units.names." then + if (SpringUnsynced.GetConfigInt("language_english_unit_names", 1) == 1) and key:sub(1, #"units.names.") == "units.names." then usedLocale = "en" end @@ -161,7 +161,7 @@ function i18n.translate(key, data) end local missingTranslation = missingTranslations[key] if not missingTranslation[fallback] and not (fallback == "en" and data.default) then - Spring.Log("i18n", "notice", '"' .. key .. '" is not translated in ' .. fallback) + SpringShared.Log("i18n", "notice", '"' .. key .. '" is not translated in ' .. fallback) missingTranslation[fallback] = true end end @@ -171,7 +171,7 @@ function i18n.translate(key, data) end local missingTranslation = missingTranslations[key] if not missingTranslation["_all"] and data.default == nil then - Spring.Log("i18n", "notice", 'No translation found for "' .. key .. '"') + SpringShared.Log("i18n", "notice", 'No translation found for "' .. key .. '"') missingTranslation["_all"] = true end return data.default or key @@ -215,8 +215,8 @@ function i18n.loadFile(path) return x() end) if not success then - Spring.Log("i18n", LOG.ERROR, "Failed to parse file " .. path .. ": ") - Spring.Log("i18n", LOG.ERROR, data) + SpringShared.Log("i18n", LOG.ERROR, "Failed to parse file " .. path .. ": ") + SpringShared.Log("i18n", LOG.ERROR, data) return nil end i18n.load(data) diff --git a/modules/lava.lua b/modules/lava.lua index 0a4c30c14fd..bd28c4fba7a 100644 --- a/modules/lava.lua +++ b/modules/lava.lua @@ -1,5 +1,5 @@ local mapName = Game.mapName -Spring.Echo("Lava Mapname", mapName) +SpringShared.Echo("Lava Mapname", mapName) local MAP_CONFIG_PATH = "mapconfig/lava.lua" local GAME_CONFIG_DIR = "common/configs/LavaMaps/" @@ -96,20 +96,20 @@ local function getLavaConfig(mapName) local mapNameNoVersion = trimMapVersion(mapName) if VFS.FileExists(gameConfigPath(mapName)) then gameConfig = VFS.Include(gameConfigPath(mapName)) - Spring.Log("Lava", LOG.INFO, "Loaded map config for", mapName) + SpringShared.Log("Lava", LOG.INFO, "Loaded map config for", mapName) elseif mapName ~= mapNameNoVersion and VFS.FileExists(gameConfigPath(mapNameNoVersion)) then gameConfig = VFS.Include(gameConfigPath(mapNameNoVersion)) - Spring.Log("Lava", LOG.INFO, "Loaded map config for", mapNameNoVersion) + SpringShared.Log("Lava", LOG.INFO, "Loaded map config for", mapNameNoVersion) end end if VFS.FileExists(MAP_CONFIG_PATH) then mapConfig = VFS.Include(MAP_CONFIG_PATH) - Spring.Log("Lava", LOG.INFO, "Loaded map config for", mapNameNoVersion) + SpringShared.Log("Lava", LOG.INFO, "Loaded map config for", mapNameNoVersion) end if mapConfig and gameConfig and gameConfig.overrideMap then -- allow gameconfig to override map config when 'overrideMap' is set mapConfig = gameConfig - Spring.Log("Lava", LOG.INFO, "Game config overrides map") + SpringShared.Log("Lava", LOG.INFO, "Game config overrides map") end return mapConfig or gameConfig end @@ -174,23 +174,23 @@ local function validateTideRhythm(modoptionDataRaw) local partRhythm = {} for value in string.gmatch(tide, "[^,]+") do if not tonumber(value) then - Spring.Echo("Lava Advanced Tide Rhythm data is not valid, non-number value: ", value) + SpringShared.Echo("Lava Advanced Tide Rhythm data is not valid, non-number value: ", value) return false else table.insert(partRhythm, tonumber(value)) end end if #partRhythm ~= 3 then - Spring.Echo("Lava Advanced Tide Rhythm data is not valid, invalid tide definition: ", partRhythm) + SpringShared.Echo("Lava Advanced Tide Rhythm data is not valid, invalid tide definition: ", partRhythm) return false elseif not ((partRhythm[1] >= 0) and (partRhythm[2] > 0) and (partRhythm[3] >= 0)) then - Spring.Echo("Lava Advanced Tide Rhythm data is not valid, negative or zero values: ", partRhythm) + SpringShared.Echo("Lava Advanced Tide Rhythm data is not valid, negative or zero values: ", partRhythm) return false end table.insert(advancedRhythm, partRhythm) end if next(advancedRhythm) == nil then - Spring.Echo("Lava Advanced Tide Rhythm data is empty") + SpringShared.Echo("Lava Advanced Tide Rhythm data is empty") return false else return advancedRhythm @@ -206,7 +206,7 @@ local function lavaModGen(modOptions) level = tideRhythm[1][1] + 1 grow = tideRhythm[1][2] else - Spring.Echo("Lava Advanced Tide Rhythm data is not valid, using default values") + SpringShared.Echo("Lava Advanced Tide Rhythm data is not valid, using default values") if next(tideRhythm) == nil then level = defaultTide[1] tideRhythm = { defaultTide } @@ -229,12 +229,12 @@ end -- Process config local mapLavaConfig = getLavaConfig(mapName) -local modTideRhythm = (Spring.GetModOptions().map_waterislava and Spring.GetModOptions().map_lavatiderhythm) or "default" +local modTideRhythm = (SpringShared.GetModOptions().map_waterislava and SpringShared.GetModOptions().map_lavatiderhythm) or "default" if mapLavaConfig and not voidWaterMap then applyConfig(mapLavaConfig) if modTideRhythm == "enabled" then - lavaModGen(Spring.GetModOptions()) + lavaModGen(SpringShared.GetModOptions()) elseif modTideRhythm == "disabled" then tideRhythm = { tideRhythm[1] } -- only the first (starting) tide level is used tideRhythm[1][3] = 5 * 6000 -- extend the first tide @@ -268,10 +268,10 @@ elseif Game.waterDamage > 0 and not voidWaterMap then -- Waterdamagemaps - keep tideRhythm = { defaultTide } --tideRhythm = { { 1, 7.5, 5*6000 } } -elseif Spring.GetModOptions().map_waterislava and not voidWaterMap then +elseif SpringShared.GetModOptions().map_waterislava and not voidWaterMap then isLavaMap = true if modTideRhythm == "enabled" then - lavaModGen(Spring.GetModOptions()) + lavaModGen(SpringShared.GetModOptions()) elseif modTideRhythm == "disabled" or modTideRhythm == "default" then level = defaultTide[1] tideRhythm = { defaultTide } diff --git a/scripts/Critters/critter_duck.lua b/scripts/Critters/critter_duck.lua index f7455fa210b..88e8a3d4d21 100644 --- a/scripts/Critters/critter_duck.lua +++ b/scripts/Critters/critter_duck.lua @@ -53,5 +53,4 @@ function script.AimWeapon1(heading, pitch) return true end -function script.Shot1() -end +function script.Shot1() end diff --git a/scripts/Critters/critter_goldfish.lua b/scripts/Critters/critter_goldfish.lua index d5e4f74e148..8b8052cdec9 100644 --- a/scripts/Critters/critter_goldfish.lua +++ b/scripts/Critters/critter_goldfish.lua @@ -10,8 +10,7 @@ function script.Create() StartThread(flapFins) end -function script.Killed(recentDamage, maxHealth) -end +function script.Killed(recentDamage, maxHealth) end function flapFins() while true do diff --git a/scripts/Critters/critter_gull.lua b/scripts/Critters/critter_gull.lua index 0c266476762..3a94d2d2165 100644 --- a/scripts/Critters/critter_gull.lua +++ b/scripts/Critters/critter_gull.lua @@ -7,8 +7,7 @@ function script.Create() StartThread(flapWings) end -function script.Killed(recentDamage, maxHealth) -end +function script.Killed(recentDamage, maxHealth) end function flapWings() while true do diff --git a/scripts/Critters/critter_penguin.lua b/scripts/Critters/critter_penguin.lua index 25eaed9664f..385f0171b19 100644 --- a/scripts/Critters/critter_penguin.lua +++ b/scripts/Critters/critter_penguin.lua @@ -10,7 +10,7 @@ local SIG_WALK = 2 local tspeed = math.rad(180) local ta = math.rad(30) -local GetGameFrame = Spring.GetGameFrame +local GetGameFrame = SpringShared.GetGameFrame function script.Create() --Spin (wing2,x_axis, 0.5) end @@ -79,7 +79,7 @@ function jump() Move(body, y_axis, 15, 40) WaitForMove(body, y_axis) Move(body, y_axis, 0, 40) - lastJump = Spring.GetGameFrame() + lastJump = SpringShared.GetGameFrame() end function script.AimFromWeapon1() diff --git a/scripts/Units/armcom_lus.lua b/scripts/Units/armcom_lus.lua index 4ff53f14a92..6d05983324f 100644 --- a/scripts/Units/armcom_lus.lua +++ b/scripts/Units/armcom_lus.lua @@ -46,9 +46,9 @@ local SIG_WALK = 4 local last_primary_heading = -1000000 local function BelowWater(piecename) - local _, y, _ = Spring.GetUnitPiecePosition(unitID, piecename) + local _, y, _ = SpringShared.GetUnitPiecePosition(unitID, piecename) -- this returns unit space, so why does it work for corcom? - local _, py, _ = Spring.GetUnitPosition(unitID) + local _, py, _ = SpringShared.GetUnitPosition(unitID) --Spring.Echo(piecename, 'ypos', y, py) if (y + py) <= 0 then return true @@ -235,7 +235,7 @@ function walk() Sleep((33 * animSpeed) - 1) end if bMoving then --Frame:20 - if not Spring.GetUnitIsCloaked(unitID) then + if not SpringShared.GetUnitIsCloaked(unitID) then UnitScript.EmitSfx(lfootstep, 1024 + 2) end if leftArm then @@ -480,7 +480,7 @@ function walk() Sleep((33 * animSpeed) - 1) end if bMoving then --Frame:44 - if not Spring.GetUnitIsCloaked(unitID) then + if not SpringShared.GetUnitIsCloaked(unitID) then UnitScript.EmitSfx(rfootstep, 1024 + 2) end if leftArm then @@ -1006,11 +1006,11 @@ function TriggerDance() end function UnitSpeed() - maxSpeed = UnitDefs[Spring.GetUnitDefID(unitID)].speed + maxSpeed = UnitDefs[SpringShared.GetUnitDefID(unitID)].speed animFramesPerKeyframe = 4 --we need to calc the frames per keyframe value, from the known animtime maxSpeed = maxSpeed + (maxSpeed / (2 * animFramesPerKeyframe)) -- add fudge while true do - vx, vy, vz, Speed = Spring.GetUnitVelocity(unitID) + vx, vy, vz, Speed = SpringShared.GetUnitVelocity(unitID) currentSpeed = Speed * 30 animSpeed = currentSpeed if animSpeed < 1 then @@ -1213,7 +1213,7 @@ function script.StartBuilding(heading, pitch) Turn(rloarm, 1, rad(-40), rad(390.0000)) -- Turn(rloarm, x-axis, math.rad(-55), math.rad(390)) Turn(ruparm, 1, rad(-55) - pitch, rad(390.0000)) -- Turn(ruparm, x-axis, math.rad(-55) - pitch, math.rad(390)) WaitForTurn(ruparm, 1) - Spring.UnitScript.SetUnitValue(COB.INBUILDSTANCE, true) + SpringSynced.UnitScript.SetUnitValue(COB.INBUILDSTANCE, true) buildHeading = heading buildPitch = pitch StartThread(SprayNano, heading, pitch) @@ -1228,7 +1228,7 @@ function script.StopBuilding() Hide(nano) leftArm = true isBuilding = false - Spring.UnitScript.SetUnitValue(COB.INBUILDSTANCE, false) + SpringSynced.UnitScript.SetUnitValue(COB.INBUILDSTANCE, false) Signal(SIG_AIM) SetSignalMask(SIG_AIM) StartThread(Restore) diff --git a/scripts/Units/armcomhilvl.lua b/scripts/Units/armcomhilvl.lua index aff3e8f1343..91fc29478fd 100644 --- a/scripts/Units/armcomhilvl.lua +++ b/scripts/Units/armcomhilvl.lua @@ -41,19 +41,19 @@ local weapons = { local SIG_AIM = 2 local SIG_WALK = 4 -local GetGameFrame = Spring.GetGameFrame -local spGetUnitStates = Spring.GetUnitStates -local spSetUnitArmored = Spring.SetUnitArmored -local spGetUnitHealth = Spring.GetUnitHealth -local spSetUnitCloak = Spring.SetUnitCloak +local GetGameFrame = SpringShared.GetGameFrame +local spGetUnitStates = SpringShared.GetUnitStates +local spSetUnitArmored = SpringSynced.SetUnitArmored +local spGetUnitHealth = SpringShared.GetUnitHealth +local spSetUnitCloak = SpringSynced.SetUnitCloak -- for the AimPrimary script, to skip wait-for-turn if needed local last_primary_heading = -1000000 local function BelowWater(piecename) - local _, y, _ = Spring.GetUnitPiecePosition(unitID, piecename) + local _, y, _ = SpringShared.GetUnitPiecePosition(unitID, piecename) -- this returns unit space, so why does it work for corcom? - local _, py, _ = Spring.GetUnitPosition(unitID) + local _, py, _ = SpringShared.GetUnitPosition(unitID) --Spring.Echo(piecename, 'ypos', y, py) if (y + py) <= 0 then return true @@ -240,7 +240,7 @@ function walk() Sleep((33 * animSpeed) - 1) end if bMoving then --Frame:20 - if not Spring.GetUnitIsCloaked(unitID) then + if not SpringShared.GetUnitIsCloaked(unitID) then UnitScript.EmitSfx(lfootstep, 1024 + 2) end if leftArm then @@ -485,7 +485,7 @@ function walk() Sleep((33 * animSpeed) - 1) end if bMoving then --Frame:44 - if not Spring.GetUnitIsCloaked(unitID) then + if not SpringShared.GetUnitIsCloaked(unitID) then UnitScript.EmitSfx(rfootstep, 1024 + 2) end if leftArm then @@ -1011,11 +1011,11 @@ function TriggerDance() end function UnitSpeed() - maxSpeed = UnitDefs[Spring.GetUnitDefID(unitID)].speed + maxSpeed = UnitDefs[SpringShared.GetUnitDefID(unitID)].speed animFramesPerKeyframe = 4 --we need to calc the frames per keyframe value, from the known animtime maxSpeed = maxSpeed + (maxSpeed / (2 * animFramesPerKeyframe)) -- add fudge while true do - vx, vy, vz, Speed = Spring.GetUnitVelocity(unitID) + vx, vy, vz, Speed = SpringShared.GetUnitVelocity(unitID) currentSpeed = Speed * 30 animSpeed = currentSpeed if animSpeed < 1 then @@ -1138,7 +1138,7 @@ function script.AimWeapon(weapon, heading, pitch) StartThread(StopDance1) end --Spring.Echo("Armcom aiming:",weapons[weapon]) - local reloadingFrameTach = Spring.GetUnitWeaponState(unitID, 4, "reloadFrame") + local reloadingFrameTach = SpringShared.GetUnitWeaponState(unitID, 4, "reloadFrame") if weapons[weapon] == "laser" then if isAimingDgun == true or isAimingTach == true then return false @@ -1271,7 +1271,7 @@ function script.StartBuilding(heading, pitch) Turn(rloarm, 1, rad(-40), rad(390.0000)) -- Turn(rloarm, x-axis, math.rad(-55), math.rad(390)) Turn(ruparm, 1, rad(-55) - pitch, rad(390.0000)) -- Turn(ruparm, x-axis, math.rad(-55) - pitch, math.rad(390)) WaitForTurn(ruparm, 1) - Spring.UnitScript.SetUnitValue(COB.INBUILDSTANCE, true) + SpringSynced.UnitScript.SetUnitValue(COB.INBUILDSTANCE, true) buildHeading = heading buildPitch = pitch StartThread(SprayNano, heading, pitch) @@ -1286,7 +1286,7 @@ function script.StopBuilding() Hide(nano) leftArm = true isBuilding = false - Spring.UnitScript.SetUnitValue(COB.INBUILDSTANCE, false) + SpringSynced.UnitScript.SetUnitValue(COB.INBUILDSTANCE, false) Signal(SIG_AIM) SetSignalMask(SIG_AIM) StartThread(Restore) diff --git a/scripts/Units/armdecom.lua b/scripts/Units/armdecom.lua index 432733e9388..3561c0ed7e8 100644 --- a/scripts/Units/armdecom.lua +++ b/scripts/Units/armdecom.lua @@ -97,7 +97,7 @@ function script.Create() StandStance() end -- should do this instead of query nano piece - Spring.SetUnitNanoPieces(unitID, { nano }) + SpringSynced.SetUnitNanoPieces(unitID, { nano }) end ----------------------------------------------------------------------- @@ -161,7 +161,7 @@ function script.AimWeapon(weaponID, heading, pitch) -- Spring.Echo("AimWeapon " .. weaponID) -- weapon2 is supposed to only fire underwater, check for it. if weaponID == 2 then - local _, basepos, _ = Spring.GetUnitPosition(unitID) + local _, basepos, _ = SpringShared.GetUnitPosition(unitID) if basepos > -16 then return false end @@ -224,7 +224,7 @@ end function script.StartBuilding(heading, pitch) Show(nano) -- Spring.Echo("StartBuilding") - Spring.SetUnitNanoPieces(unitID, { nano }) + SpringSynced.SetUnitNanoPieces(unitID, { nano }) isBuilding = true Turn(base, x_axis, 0, math.rad(395)) diff --git a/scripts/Units/armmar_lus.lua b/scripts/Units/armmar_lus.lua index 516a4f3d265..939a617c21b 100644 --- a/scripts/Units/armmar_lus.lua +++ b/scripts/Units/armmar_lus.lua @@ -14,7 +14,7 @@ timedMove = function(piece, axis, goal, amount, t) Move(piece, axis, goal, speed) end -unitDefID = Spring.GetUnitDefID(unitID) +unitDefID = SpringShared.GetUnitDefID(unitID) defs = UnitDefs[unitDefID] unitName = UnitDefs[unitDefID].name @@ -88,7 +88,7 @@ end function ypos() while true do - local _, y = Spring.GetUnitPosition(unitID) + local _, y = SpringShared.GetUnitPosition(unitID) isUW = (y < -60) Sleep(500) end @@ -186,7 +186,7 @@ function script.Create() end function LastCallCheck(weaponID) - local f = Spring.GetGameFrame() + local f = SpringShared.GetGameFrame() if not weapons[weaponID].lastCall then weapons[weaponID].lastCall = f end diff --git a/scripts/Units/armmar_lus/setup.lua b/scripts/Units/armmar_lus/setup.lua index f604754162c..cdc33f3648f 100644 --- a/scripts/Units/armmar_lus/setup.lua +++ b/scripts/Units/armmar_lus/setup.lua @@ -26,5 +26,4 @@ lleg = piece("lleg") lfoot = piece("lfoot") currentSpeed = 100 -function InitialPiecesSetup() -end +function InitialPiecesSetup() end diff --git a/scripts/Units/corcom_lus.lua b/scripts/Units/corcom_lus.lua index 163c2a66414..29b755c3e01 100644 --- a/scripts/Units/corcom_lus.lua +++ b/scripts/Units/corcom_lus.lua @@ -41,9 +41,9 @@ local SIG_AIM = 2 local SIG_WALK = 4 local function BelowWater(piecename) - local _, y, _ = Spring.GetUnitPiecePosition(unitID, piecename) + local _, y, _ = SpringShared.GetUnitPiecePosition(unitID, piecename) -- this returns unit space, so why does it work for corcom? - local _, py, _ = Spring.GetUnitPosition(unitID) + local _, py, _ = SpringShared.GetUnitPosition(unitID) if (y + py) <= 0 then return true else @@ -224,7 +224,7 @@ function walk() Sleep((33 * animSpeed) - 1) end if bMoving then --Frame:24 - if not Spring.GetUnitIsCloaked(unitID) then + if not SpringShared.GetUnitIsCloaked(unitID) then UnitScript.EmitSfx(r_foot, 1024 + 2) end if rightArm then @@ -419,7 +419,7 @@ function walk() Sleep((33 * animSpeed) - 1) end if bMoving then --Frame:48 - if not Spring.GetUnitIsCloaked(unitID) then + if not SpringShared.GetUnitIsCloaked(unitID) then UnitScript.EmitSfx(l_foot, 1024 + 2) end if rightArm then @@ -606,11 +606,11 @@ function bigfire() end function UnitSpeed() - maxSpeed = UnitDefs[Spring.GetUnitDefID(unitID)].speed + maxSpeed = UnitDefs[SpringShared.GetUnitDefID(unitID)].speed animFramesPerKeyframe = 6 --we need to calc the frames per keyframe value, from the known animtime maxSpeed = maxSpeed + (maxSpeed / (2 * animFramesPerKeyframe)) -- add fudge while true do - vx, vy, vz, Speed = Spring.GetUnitVelocity(unitID) + vx, vy, vz, Speed = SpringShared.GetUnitVelocity(unitID) currentSpeed = Speed * 30 animSpeed = currentSpeed if animSpeed < 1 then @@ -771,7 +771,7 @@ function script.StartBuilding(heading, pitch) Turn(aimy1, 2, heading, rad(300.000000)) Turn(aimx1, 1, rad(-5.000000) - pitch, rad(250.000000)) WaitForTurn(aimy1, 2) - Spring.UnitScript.SetUnitValue(COB.INBUILDSTANCE, true) + SpringSynced.UnitScript.SetUnitValue(COB.INBUILDSTANCE, true) buildHeading = heading buildPitch = pitch StartThread(SprayNano, heading, pitch) @@ -781,7 +781,7 @@ end function script.StopBuilding() leftArm = true isBuilding = false - Spring.UnitScript.SetUnitValue(COB.INBUILDSTANCE, false) + SpringSynced.UnitScript.SetUnitValue(COB.INBUILDSTANCE, false) Signal(SIG_AIM) SetSignalMask(SIG_AIM) StartThread(Restore) diff --git a/scripts/animation.lua b/scripts/animation.lua index c58e0c966ea..1b79acb1ee7 100644 --- a/scripts/animation.lua +++ b/scripts/animation.lua @@ -7,7 +7,7 @@ function animSpin(getid, getpiece, getaxis, getspeed) local last_inbuilt = true while true do - local inProgress = Spring.GetUnitIsBeingBuilt(id) + local inProgress = SpringShared.GetUnitIsBeingBuilt(id) if inProgress ~= last_inbuilt then last_inbuilt = inProgress if inProgress then @@ -28,7 +28,7 @@ function animSmoke(getid, getpiece) local last_inbt = true while true do - local inProgress = Spring.GetUnitIsBeingBuilt(id) + local inProgress = SpringShared.GetUnitIsBeingBuilt(id) if inProgress ~= last_inbt then last_inbt = inProgress if inProgress then @@ -51,7 +51,7 @@ function animBurn(getid, getpiece) local last_inb = true while true do - local inProgress = Spring.GetUnitIsBeingBuilt(id) + local inProgress = SpringShared.GetUnitIsBeingBuilt(id) if inProgress ~= last_inb then last_inb = inProgress if inProgress then diff --git a/scripts/bots_lus.lua b/scripts/bots_lus.lua index 8dab91853be..241f011e5b3 100644 --- a/scripts/bots_lus.lua +++ b/scripts/bots_lus.lua @@ -14,7 +14,7 @@ timedMove = function(piece, axis, goal, amount, t) Move(piece, axis, goal, speed) end -unitDefID = Spring.GetUnitDefID(unitID) +unitDefID = SpringShared.GetUnitDefID(unitID) defs = UnitDefs[unitDefID] unitName = UnitDefs[unitDefID].name @@ -157,7 +157,7 @@ function script.Create() end function LastCallCheck(weaponID) - local f = Spring.GetGameFrame() + local f = SpringShared.GetGameFrame() if not weapons[weaponID].lastCall then weapons[weaponID].lastCall = f end diff --git a/scripts/headers/common_includes_lus.lua b/scripts/headers/common_includes_lus.lua index 53a71e9d2be..3c0c93fb5d8 100644 --- a/scripts/headers/common_includes_lus.lua +++ b/scripts/headers/common_includes_lus.lua @@ -2,9 +2,9 @@ common = { CustomEmitter = function(pieceName, effectName) --Spring.Echo(pieceName, effectName) - local x, y, z, dx, dy, dz = Spring.GetUnitPiecePosDir(unitID, pieceName) + local x, y, z, dx, dy, dz = SpringShared.GetUnitPiecePosDir(unitID, pieceName) - Spring.SpawnCEG(effectName, x, y, z, dx, dy, dz) + SpringSynced.SpawnCEG(effectName, x, y, z, dx, dy, dz) end, HbotLift = function() diff --git a/scripts/include/util.lua b/scripts/include/util.lua index 2ed92dd40ab..0fdc70b837b 100644 --- a/scripts/include/util.lua +++ b/scripts/include/util.lua @@ -1,10 +1,10 @@ function still_building() - return Spring.GetUnitIsBeingBuilt(unitID) + return SpringShared.GetUnitIsBeingBuilt(unitID) end function get_health_percent() - local health, maxHealth = Spring.GetUnitHealth(unitID) + local health, maxHealth = SpringShared.GetUnitHealth(unitID) return ((health / maxHealth) * 100) end @@ -21,7 +21,7 @@ function smoke_unit(emit_piece) if math.random(1, 66) < health_percent then smoketype = 257 end - Spring.UnitScript.EmitSfx(emit_piece, smoketype) + SpringSynced.UnitScript.EmitSfx(emit_piece, smoketype) end local sleep_time = health_percent * 50 diff --git a/scripts/mines_lus.lua b/scripts/mines_lus.lua index 3cf1343806c..a55c8534657 100644 --- a/scripts/mines_lus.lua +++ b/scripts/mines_lus.lua @@ -1,6 +1,6 @@ local base = piece("base") -local unitDefID = Spring.GetUnitDefID(unitID) +local unitDefID = SpringShared.GetUnitDefID(unitID) local triggerRange = tonumber(UnitDefs[unitDefID].customParams.detonaterange) or 64 local math_sqrt = math.sqrt @@ -10,9 +10,9 @@ local math_sqrt = math.sqrt -- Possible enhancements: Use GetUnitsInCylinder(or sphere) of detonaterange and check for any restriction on target units function GetClosestEnemyDistance() - targetID = Spring.GetUnitNearestEnemy(unitID, triggerRange) + targetID = SpringShared.GetUnitNearestEnemy(unitID, triggerRange) if targetID then - local tx, ty, tz = Spring.GetUnitPosition(targetID) + local tx, ty, tz = SpringShared.GetUnitPosition(targetID) local dis = distance(ux, uy, uz, tx, ty, tz) return dis else @@ -43,15 +43,15 @@ end function script.FireWeapon() end function script.Create() - ux, uy, uz = Spring.GetUnitPosition(unitID) + ux, uy, uz = SpringShared.GetUnitPosition(unitID) StartThread(EnemyDetect) end function EnemyDetect() while true do - local inProgress = Spring.GetUnitIsBeingBuilt(unitID) - local firestate = Spring.GetUnitStates(unitID, false) - local stunned = Spring.GetUnitIsStunned(unitID) + local inProgress = SpringShared.GetUnitIsBeingBuilt(unitID) + local firestate = SpringShared.GetUnitStates(unitID, false) + local stunned = SpringShared.GetUnitIsStunned(unitID) if not inProgress and firestate and firestate > 0 and GetClosestEnemyDistance() <= triggerRange and not stunned then StartThread(Detonate) break @@ -63,7 +63,7 @@ end function Detonate() Sleep(500) - Spring.DestroyUnit(unitID, false, false) + SpringSynced.DestroyUnit(unitID, false, false) end function script.Killed() diff --git a/shaders/GLSL/infoLOS.lua b/shaders/GLSL/infoLOS.lua index d7fae7c1cf5..b1ffb099157 100644 --- a/shaders/GLSL/infoLOS.lua +++ b/shaders/GLSL/infoLOS.lua @@ -1,9 +1,9 @@ local Spring = Spring -local alwaysColor, losColor, radarColor, jamColor, radarColor2 = Spring.GetLosViewColors() +local alwaysColor, losColor, radarColor, jamColor, radarColor2 = SpringUnsynced.GetLosViewColors() return { definitions = { - Spring.GetConfigInt("HighResInfoTexture") and "#define HIGH_QUALITY" or "", + SpringUnsynced.GetConfigInt("HighResInfoTexture") and "#define HIGH_QUALITY" or "", }, vertex = [[#version 130 varying vec2 texCoord; diff --git a/shaders/GLSL/infoMetal.lua b/shaders/GLSL/infoMetal.lua index 7a149ac4156..c2c366029b0 100644 --- a/shaders/GLSL/infoMetal.lua +++ b/shaders/GLSL/infoMetal.lua @@ -25,8 +25,8 @@ end return { definitions = { - Spring.GetConfigInt("HighResInfoTexture") and "#define HIGH_QUALITY\n" or "", - "#define MetalViewBrightness " .. tostring(Spring.GetConfigFloat("MetalViewBrightness", 1.0) or 1.0), + SpringUnsynced.GetConfigInt("HighResInfoTexture") and "#define HIGH_QUALITY\n" or "", + "#define MetalViewBrightness " .. tostring(SpringUnsynced.GetConfigFloat("MetalViewBrightness", 1.0) or 1.0), }, vertex = [[#version 130 varying vec2 texCoord; diff --git a/singleplayer/scenarios/scenarioscripts/Begin06.lua b/singleplayer/scenarios/scenarioscripts/Begin06.lua index 05e6413830f..85d18366ad3 100644 --- a/singleplayer/scenarios/scenarioscripts/Begin06.lua +++ b/singleplayer/scenarios/scenarioscripts/Begin06.lua @@ -585,18 +585,18 @@ local objectiveUnitsAlive = {} local function Fail() GG.wipeoutAllyTeam(0) -- kill all units when failed - GameOver = Spring.GameOver({ 2 }) --winningAllyTeamN where N is Ally ID + GameOver = SpringSynced.GameOver({ 2 }) --winningAllyTeamN where N is Ally ID end local function Loadout() for k, unit in pairs(loadout) do if UnitDefNames[unit.name] then -- Spring.Echo("trying to spawn a unit, synced is", Script.GetSynced()) - local unitID = Spring.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) + local unitID = SpringSynced.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) for i = 1, #unit.queue do local order = unit.queue[i] local position = { order.position["px"], order.position["py"], order.position["pz"] } - Spring.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) + SpringSynced.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) end end end @@ -606,14 +606,14 @@ function ObjectiveLoadout() for i, unitGroup in ipairs(objectiveUnits) do for j, unit in ipairs(unitGroup) do if UnitDefNames[unit.name] then - local unitID = Spring.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) + local unitID = SpringSynced.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) objectiveUnitsAlive[unitID] = true if unit.objectiveUnitID then objectiveUnits[unitID] = unit.objectiveUnitID end for k, order in ipairs(unit.queue) do local position = { order.position["px"], order.position["py"], order.position["pz"] } - Spring.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) + SpringSynced.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) end end end @@ -627,7 +627,7 @@ function gadget:UnitDestroyed(unitID, unitDefID) for j, unit in ipairs(unitGroup) do if unit.objectiveUnitID == 2 then Fail() - Spring.Echo("\n\n\nYOU LOST CRITICAL BUILDING!!\nMISSION FAILED!!!") + SpringShared.Echo("\n\n\nYOU LOST CRITICAL BUILDING!!\nMISSION FAILED!!!") objectiveUnits[unitID] = nil return end @@ -640,11 +640,11 @@ local function BackupOne() for k, unit in pairs(backupOne) do if UnitDefNames[unit.name] then -- Spring.Echo("trying to spawn a unit, synced is", Script.GetSynced()) - local unitID = Spring.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) + local unitID = SpringSynced.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) for i = 1, #unit.queue do local order = unit.queue[i] local position = { order.position["px"], order.position["py"], order.position["pz"] } - Spring.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) + SpringSynced.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) end end end @@ -654,11 +654,11 @@ local function BackupTwo() for k, unit in pairs(backupTwo) do if UnitDefNames[unit.name] then -- Spring.Echo("trying to spawn a unit, synced is", Script.GetSynced()) - local unitID = Spring.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) + local unitID = SpringSynced.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) for i = 1, #unit.queue do local order = unit.queue[i] local position = { order.position["px"], order.position["py"], order.position["pz"] } - Spring.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) + SpringSynced.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) end end end @@ -668,11 +668,11 @@ local function Timed() for k, unit in pairs(timed) do if UnitDefNames[unit.name] then -- Spring.Echo("trying to spawn a unit, synced is", Script.GetSynced()) - local unitID = Spring.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) + local unitID = SpringSynced.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) for i = 1, #unit.queue do local order = unit.queue[i] local position = { order.position["px"], order.position["py"], order.position["pz"] } - Spring.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) + SpringSynced.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) end end end @@ -682,11 +682,11 @@ local function Special() for k, unit in pairs(special) do if UnitDefNames[unit.name] then -- Spring.Echo("trying to spawn a unit, synced is", Script.GetSynced()) - local unitID = Spring.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) + local unitID = SpringSynced.CreateUnit(unit.name, unit.x, unit.y, unit.z, unit.rot, unit.teamID) for i = 1, #unit.queue do local order = unit.queue[i] local position = { order.position["px"], order.position["py"], order.position["pz"] } - Spring.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) + SpringSynced.GiveOrderToUnit(unitID, order.cmdID, position, CMD.OPT_SHIFT) end end end diff --git a/spec/builders/spring_synced_builder.lua b/spec/builders/spring_synced_builder.lua index ba92ea172a2..3776022d187 100644 --- a/spec/builders/spring_synced_builder.lua +++ b/spec/builders/spring_synced_builder.lua @@ -864,13 +864,13 @@ function SB:WithRealUnitDefs() -- Load alldefs_post first to ensure UnitDef_Post is available local alldefsSuccess, alldefsError = pcall(require, "gamedata.alldefs_post") if not alldefsSuccess then - Spring.Log("UNITDEFS", LOG.ERROR, "Failed to load alldefs_post: " .. tostring(alldefsError)) + SpringShared.Log("UNITDEFS", LOG.ERROR, "Failed to load alldefs_post: " .. tostring(alldefsError)) end -- Run post-processing to normalize unit definitions local postSuccess, postError = pcall(require, "gamedata.unitdefs_post") if not postSuccess then - Spring.Log("UNITDEFS", LOG.ERROR, "Failed to run unitdefs post-processing: " .. tostring(postError)) + SpringShared.Log("UNITDEFS", LOG.ERROR, "Failed to run unitdefs post-processing: " .. tostring(postError)) end -- Simulate engine-level field renames (C++ does these before Lua sees UnitDefs at runtime) diff --git a/spec/spec_helper.lua b/spec/spec_helper.lua index b63e2a1a199..439e78bca92 100644 --- a/spec/spec_helper.lua +++ b/spec/spec_helper.lua @@ -38,6 +38,10 @@ _G.Spring.Echo = _G.Spring.Echo or function(...) print(...) end +_G.SpringSynced = _G.SpringSynced or _G.Spring +_G.SpringUnsynced = _G.SpringUnsynced or _G.Spring +_G.SpringShared = _G.SpringShared or _G.Spring + _G.GG = _G.GG or {} _G.unpack = _G.unpack or table.unpack or function(t, i, j) diff --git a/units/Legion/Legion EvoCom/legcomlvl10.lua b/units/Legion/Legion EvoCom/legcomlvl10.lua index 9080eebb0ae..565ede6eb3f 100644 --- a/units/Legion/Legion EvoCom/legcomlvl10.lua +++ b/units/Legion/Legion EvoCom/legcomlvl10.lua @@ -42,7 +42,7 @@ return { movementclass = "COMMANDERBOT", nochasecategory = "ALL", objectname = "Units/legevocom3.s3o", - pushresistant = Spring.GetModOptions().pushresistant, + pushresistant = SpringShared.GetModOptions().pushresistant, radardistance = 1200, radaremitheight = 54, reclaimable = false, diff --git a/units/Legion/Legion EvoCom/legcomlvl2.lua b/units/Legion/Legion EvoCom/legcomlvl2.lua index 0fc71a3fb45..6ca12363e5a 100644 --- a/units/Legion/Legion EvoCom/legcomlvl2.lua +++ b/units/Legion/Legion EvoCom/legcomlvl2.lua @@ -41,7 +41,7 @@ return { movementclass = "COMMANDERBOT", nochasecategory = "ALL", objectname = "Units/legevocom1.s3o", - pushresistant = Spring.GetModOptions().pushresistant, + pushresistant = SpringShared.GetModOptions().pushresistant, radardistance = 800, radaremitheight = 44, reclaimable = false, diff --git a/units/Legion/Legion EvoCom/legcomlvl3.lua b/units/Legion/Legion EvoCom/legcomlvl3.lua index e4caee976b6..ad658ca7d4d 100644 --- a/units/Legion/Legion EvoCom/legcomlvl3.lua +++ b/units/Legion/Legion EvoCom/legcomlvl3.lua @@ -42,7 +42,7 @@ return { movementclass = "COMMANDERBOT", nochasecategory = "ALL", objectname = "Units/legevocom1.s3o", - pushresistant = Spring.GetModOptions().pushresistant, + pushresistant = SpringShared.GetModOptions().pushresistant, radardistance = 900, radaremitheight = 49, reclaimable = false, diff --git a/units/Legion/Legion EvoCom/legcomlvl4.lua b/units/Legion/Legion EvoCom/legcomlvl4.lua index c55789a94e8..d7924927129 100644 --- a/units/Legion/Legion EvoCom/legcomlvl4.lua +++ b/units/Legion/Legion EvoCom/legcomlvl4.lua @@ -42,7 +42,7 @@ return { movementclass = "COMMANDERBOT", nochasecategory = "ALL", objectname = "Units/legevocom2.s3o", - pushresistant = Spring.GetModOptions().pushresistant, + pushresistant = SpringShared.GetModOptions().pushresistant, radardistance = 1000, radaremitheight = 54, reclaimable = false, diff --git a/units/Legion/Legion EvoCom/legcomlvl5.lua b/units/Legion/Legion EvoCom/legcomlvl5.lua index d679372fac3..c1810e1d04f 100644 --- a/units/Legion/Legion EvoCom/legcomlvl5.lua +++ b/units/Legion/Legion EvoCom/legcomlvl5.lua @@ -42,7 +42,7 @@ return { movementclass = "COMMANDERBOT", nochasecategory = "ALL", objectname = "Units/legevocom2.s3o", - pushresistant = Spring.GetModOptions().pushresistant, + pushresistant = SpringShared.GetModOptions().pushresistant, radardistance = 1000, radaremitheight = 54, reclaimable = false, diff --git a/units/Legion/Legion EvoCom/legcomlvl6.lua b/units/Legion/Legion EvoCom/legcomlvl6.lua index c326401d2cb..7a36bcbddc7 100644 --- a/units/Legion/Legion EvoCom/legcomlvl6.lua +++ b/units/Legion/Legion EvoCom/legcomlvl6.lua @@ -42,7 +42,7 @@ return { movementclass = "COMMANDERBOT", nochasecategory = "ALL", objectname = "Units/legevocom3.s3o", - pushresistant = Spring.GetModOptions().pushresistant, + pushresistant = SpringShared.GetModOptions().pushresistant, radardistance = 1000, radaremitheight = 54, reclaimable = false, diff --git a/units/Legion/Legion EvoCom/legcomlvl7.lua b/units/Legion/Legion EvoCom/legcomlvl7.lua index bf24f7d00a4..9423f64d4d6 100644 --- a/units/Legion/Legion EvoCom/legcomlvl7.lua +++ b/units/Legion/Legion EvoCom/legcomlvl7.lua @@ -42,7 +42,7 @@ return { movementclass = "COMMANDERBOT", nochasecategory = "ALL", objectname = "Units/legevocom3.s3o", - pushresistant = Spring.GetModOptions().pushresistant, + pushresistant = SpringShared.GetModOptions().pushresistant, radardistance = 1200, radaremitheight = 54, reclaimable = false, diff --git a/units/Legion/Legion EvoCom/legcomlvl8.lua b/units/Legion/Legion EvoCom/legcomlvl8.lua index d465fd8d7d9..316b8252696 100644 --- a/units/Legion/Legion EvoCom/legcomlvl8.lua +++ b/units/Legion/Legion EvoCom/legcomlvl8.lua @@ -42,7 +42,7 @@ return { movementclass = "COMMANDERBOT", nochasecategory = "ALL", objectname = "Units/legevocom3.s3o", - pushresistant = Spring.GetModOptions().pushresistant, + pushresistant = SpringShared.GetModOptions().pushresistant, radardistance = 1200, radaremitheight = 54, reclaimable = false, diff --git a/units/Legion/Legion EvoCom/legcomlvl9.lua b/units/Legion/Legion EvoCom/legcomlvl9.lua index 3570c9a8796..47b1ffe682c 100644 --- a/units/Legion/Legion EvoCom/legcomlvl9.lua +++ b/units/Legion/Legion EvoCom/legcomlvl9.lua @@ -42,7 +42,7 @@ return { movementclass = "COMMANDERBOT", nochasecategory = "ALL", objectname = "Units/legevocom3.s3o", - pushresistant = Spring.GetModOptions().pushresistant, + pushresistant = SpringShared.GetModOptions().pushresistant, radardistance = 1200, radaremitheight = 54, reclaimable = false, diff --git a/units/Scavengers/Boss/scavengerbossv4.lua b/units/Scavengers/Boss/scavengerbossv4.lua index d671f8c99c8..b78037d789b 100644 --- a/units/Scavengers/Boss/scavengerbossv4.lua +++ b/units/Scavengers/Boss/scavengerbossv4.lua @@ -1,6 +1,6 @@ local playerCountScale = 1 if Spring.Utilities.Gametype.IsScavengers() then - playerCountScale = math.min(1, (#Spring.GetTeamList() - 2) / 8) -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline + playerCountScale = math.min(1, (#SpringShared.GetTeamList() - 2) / 8) -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline end local baseValues = { --format: {value, multiplier} diff --git a/units/armassistdrone.lua b/units/armassistdrone.lua index a14b3b70a2b..c01ab764b83 100644 --- a/units/armassistdrone.lua +++ b/units/armassistdrone.lua @@ -31,7 +31,7 @@ return { terraformspeed = 225, turninplaceanglelimit = 360, turnrate = 740, - workertime = 100 * Spring.GetModOptions().assistdronesbuildpowermultiplier, + workertime = 100 * SpringShared.GetModOptions().assistdronesbuildpowermultiplier, buildoptions = { "armsolar", "armadvsol", diff --git a/units/armassistdrone_land.lua b/units/armassistdrone_land.lua index 7b5e1e28f73..9e178868118 100644 --- a/units/armassistdrone_land.lua +++ b/units/armassistdrone_land.lua @@ -35,7 +35,7 @@ return { turninplaceanglelimit = 90, turninplacespeedlimit = 0.9834, turnrate = 1000, - workertime = 100 * Spring.GetModOptions().assistdronesbuildpowermultiplier, + workertime = 100 * SpringShared.GetModOptions().assistdronesbuildpowermultiplier, buildoptions = { [1] = "armsolar", [2] = "armwin", diff --git a/units/armcomnew.lua b/units/armcomnew.lua index 75e07e800a8..18c9a8a3bd4 100644 --- a/units/armcomnew.lua +++ b/units/armcomnew.lua @@ -38,7 +38,7 @@ return { movementclass = "COMMANDERBOT", movestate = 0, nochasecategory = "ALL", - objectname = "Units/ARMCOM" .. (Spring.GetModOptions().xmas and "-XMAS" or "") .. ".s3o", + objectname = "Units/ARMCOM" .. (SpringShared.GetModOptions().xmas and "-XMAS" or "") .. ".s3o", radardistance = 700, radaremitheight = 40, reclaimable = false, diff --git a/units/corassistdrone.lua b/units/corassistdrone.lua index 7b746e56713..e06965654ce 100644 --- a/units/corassistdrone.lua +++ b/units/corassistdrone.lua @@ -31,7 +31,7 @@ return { terraformspeed = 225, turninplaceanglelimit = 360, turnrate = 740, - workertime = 100 * Spring.GetModOptions().assistdronesbuildpowermultiplier, + workertime = 100 * SpringShared.GetModOptions().assistdronesbuildpowermultiplier, buildoptions = { "corsolar", "coradvsol", diff --git a/units/corassistdrone_land.lua b/units/corassistdrone_land.lua index 350ceda4687..bfcf6ee64e9 100644 --- a/units/corassistdrone_land.lua +++ b/units/corassistdrone_land.lua @@ -36,7 +36,7 @@ return { turninplaceanglelimit = 90, turninplacespeedlimit = 0.9504, turnrate = 1000, - workertime = 100 * Spring.GetModOptions().assistdronesbuildpowermultiplier, + workertime = 100 * SpringShared.GetModOptions().assistdronesbuildpowermultiplier, buildoptions = { [1] = "corsolar", [2] = "corwin", diff --git a/units/legassistdrone.lua b/units/legassistdrone.lua index d893751fb17..566d0f95bc8 100644 --- a/units/legassistdrone.lua +++ b/units/legassistdrone.lua @@ -31,7 +31,7 @@ return { terraformspeed = 225, turninplaceanglelimit = 360, turnrate = 740, - workertime = 100 * Spring.GetModOptions().assistdronesbuildpowermultiplier, + workertime = 100 * SpringShared.GetModOptions().assistdronesbuildpowermultiplier, buildoptions = { "legsolar", "legadvsol", diff --git a/units/legassistdrone_land.lua b/units/legassistdrone_land.lua index 8aef5b924b3..b86b7a8163b 100644 --- a/units/legassistdrone_land.lua +++ b/units/legassistdrone_land.lua @@ -36,7 +36,7 @@ return { turninplaceanglelimit = 90, turninplacespeedlimit = 0.9504, turnrate = 1000, - workertime = 100 * Spring.GetModOptions().assistdronesbuildpowermultiplier, + workertime = 100 * SpringShared.GetModOptions().assistdronesbuildpowermultiplier, buildoptions = { "legsolar", "legwin", diff --git a/units/other/armrespawn.lua b/units/other/armrespawn.lua index 3e3cfe7f75e..d2c7b17f51b 100644 --- a/units/other/armrespawn.lua +++ b/units/other/armrespawn.lua @@ -1,4 +1,4 @@ -local range = Spring.GetModOptions().commanderbuildersrange +local range = SpringShared.GetModOptions().commanderbuildersrange return { armrespawn = { maxacc = 0, @@ -39,7 +39,7 @@ return { turnrate = 1, upright = true, waterline = 0, - workertime = Spring.GetModOptions().commanderbuildersbuildpower, + workertime = SpringShared.GetModOptions().commanderbuildersbuildpower, customparams = { usebuildinggrounddecal = false, buildinggrounddecaltype = "decals/armnanotc_aoplane.dds", diff --git a/units/other/correspawn.lua b/units/other/correspawn.lua index 7879e10b28b..bcd23567ee5 100644 --- a/units/other/correspawn.lua +++ b/units/other/correspawn.lua @@ -1,4 +1,4 @@ -local range = Spring.GetModOptions().commanderbuildersrange +local range = SpringShared.GetModOptions().commanderbuildersrange return { correspawn = { maxacc = 0, @@ -39,7 +39,7 @@ return { turnrate = 1, upright = true, waterline = 0, - workertime = Spring.GetModOptions().commanderbuildersbuildpower, + workertime = SpringShared.GetModOptions().commanderbuildersbuildpower, customparams = { usebuildinggrounddecal = false, buildinggrounddecaltype = "decals/cornanotc_aoplane.dds", diff --git a/units/other/evocom/armcomlvl2.lua b/units/other/evocom/armcomlvl2.lua index 3646edf5b94..1723811bd89 100644 --- a/units/other/evocom/armcomlvl2.lua +++ b/units/other/evocom/armcomlvl2.lua @@ -41,7 +41,7 @@ return { mincloakdistance = 50, movementclass = "COMMANDERBOT", nochasecategory = "ALL", - objectname = "Units/ARMCOM" .. (Spring.GetModOptions().xmas and "-XMAS" or "") .. ".s3o", + objectname = "Units/ARMCOM" .. (SpringShared.GetModOptions().xmas and "-XMAS" or "") .. ".s3o", radardistance = 700, radaremitheight = 40, reclaimable = false, diff --git a/units/other/evocom/corcomlvl2.lua b/units/other/evocom/corcomlvl2.lua index 49c4e9beb1f..76b3a49fb08 100644 --- a/units/other/evocom/corcomlvl2.lua +++ b/units/other/evocom/corcomlvl2.lua @@ -42,7 +42,7 @@ return { mincloakdistance = 50, movementclass = "COMMANDERBOT", nochasecategory = "ALL", - objectname = "Units/CORCOM" .. (Spring.GetModOptions().xmas and "-XMAS" or "") .. ".s3o", + objectname = "Units/CORCOM" .. (SpringShared.GetModOptions().xmas and "-XMAS" or "") .. ".s3o", radardistance = 700, radaremitheight = 40, reclaimable = false, diff --git a/units/other/legnanotcbase.lua b/units/other/legnanotcbase.lua index 173320540a7..7cd316cb873 100644 --- a/units/other/legnanotcbase.lua +++ b/units/other/legnanotcbase.lua @@ -1,4 +1,4 @@ -local range = Spring.GetModOptions().commanderbuildersrange +local range = SpringShared.GetModOptions().commanderbuildersrange return { legnanotcbase = { maxacc = 0, @@ -39,7 +39,7 @@ return { turnrate = 1, upright = true, waterline = 0, - workertime = Spring.GetModOptions().commanderbuildersbuildpower, + workertime = SpringShared.GetModOptions().commanderbuildersbuildpower, customparams = { usebuildinggrounddecal = false, buildinggrounddecaltype = "decals/legnanotcbase_aoplane.dds", diff --git a/units/other/raptors/Queens/raptor_queen_easy.lua b/units/other/raptors/Queens/raptor_queen_easy.lua index a332b5f3d18..ff953128282 100644 --- a/units/other/raptors/Queens/raptor_queen_easy.lua +++ b/units/other/raptors/Queens/raptor_queen_easy.lua @@ -1,6 +1,6 @@ local playerCountScale = 1 if Spring.Utilities.Gametype.IsRaptors() then - playerCountScale = (#Spring.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline + playerCountScale = (#SpringShared.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline end return { diff --git a/units/other/raptors/Queens/raptor_queen_epic.lua b/units/other/raptors/Queens/raptor_queen_epic.lua index 674248e7733..bb6f49c4094 100644 --- a/units/other/raptors/Queens/raptor_queen_epic.lua +++ b/units/other/raptors/Queens/raptor_queen_epic.lua @@ -1,6 +1,6 @@ local playerCountScale = 1 if Spring.Utilities.Gametype.IsRaptors() then - playerCountScale = (#Spring.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline + playerCountScale = (#SpringShared.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline end return { diff --git a/units/other/raptors/Queens/raptor_queen_hard.lua b/units/other/raptors/Queens/raptor_queen_hard.lua index 0ab1b498535..fd42445b296 100644 --- a/units/other/raptors/Queens/raptor_queen_hard.lua +++ b/units/other/raptors/Queens/raptor_queen_hard.lua @@ -1,6 +1,6 @@ local playerCountScale = 1 if Spring.Utilities.Gametype.IsRaptors() then - playerCountScale = (#Spring.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline + playerCountScale = (#SpringShared.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline end return { diff --git a/units/other/raptors/Queens/raptor_queen_normal.lua b/units/other/raptors/Queens/raptor_queen_normal.lua index dc834b20b0e..4af232f2b2b 100644 --- a/units/other/raptors/Queens/raptor_queen_normal.lua +++ b/units/other/raptors/Queens/raptor_queen_normal.lua @@ -1,6 +1,6 @@ local playerCountScale = 1 if Spring.Utilities.Gametype.IsRaptors() then - playerCountScale = (#Spring.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline + playerCountScale = (#SpringShared.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline end return { diff --git a/units/other/raptors/Queens/raptor_queen_veryeasy.lua b/units/other/raptors/Queens/raptor_queen_veryeasy.lua index 6e88ae24baf..3ada246dd25 100644 --- a/units/other/raptors/Queens/raptor_queen_veryeasy.lua +++ b/units/other/raptors/Queens/raptor_queen_veryeasy.lua @@ -1,6 +1,6 @@ local playerCountScale = 1 if Spring.Utilities.Gametype.IsRaptors() then - playerCountScale = (#Spring.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline + playerCountScale = (#SpringShared.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline end return { diff --git a/units/other/raptors/Queens/raptor_queen_veryhard.lua b/units/other/raptors/Queens/raptor_queen_veryhard.lua index 354071bc74b..6094e57ddfe 100644 --- a/units/other/raptors/Queens/raptor_queen_veryhard.lua +++ b/units/other/raptors/Queens/raptor_queen_veryhard.lua @@ -1,6 +1,6 @@ local playerCountScale = 1 if Spring.Utilities.Gametype.IsRaptors() then - playerCountScale = (#Spring.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline + playerCountScale = (#SpringShared.GetTeamList() - 2) / 8 -- -2 because scavs and gaia shouldn't count, divided by 8 because we use 8 player games as a baseline end return {