[wesnoth-commits] [wesnoth/wesnoth] a14151: Add some utility functions to help clarify the mer...

Celtic Minstrel noreply at github.com
Fri Feb 19 06:46:40 UTC 2021


  Branch: refs/heads/lua_gamemap
  Home:   https://github.com/wesnoth/wesnoth
  Commit: a14151ea01e53f6fcf572f0dbffb471a7a9b6c77
      https://github.com/wesnoth/wesnoth/commit/a14151ea01e53f6fcf572f0dbffb471a7a9b6c77
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-02-19 (Fri, 19 Feb 2021)

  Changed paths:
    M data/lua/core.lua

  Log Message:
  -----------
  Add some utility functions to help clarify the merge mode being used when assigning terrains


  Commit: d09cf994391c2fb4f58f585a3fd6950d47f69b92
      https://github.com/wesnoth/wesnoth/commit/d09cf994391c2fb4f58f585a3fd6950d47f69b92
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-02-19 (Fri, 19 Feb 2021)

  Changed paths:
    M data/lua/core.lua

  Log Message:
  -----------
  Add a utility function to extract a location from the front of a variadic parameter pack

The purpose of this is to make it easy for functions implemented in Lua to handle locations
in the same way as functions implemented in C++.

Usage example:

Imagine a function foo with the following signature:

foo(bar : string, home : location, mode : string, target : location, moo : boolean) -> boolean

With the new read_lcation function it could be implemented as follows:

function foo(...)
	-- First argument goes in bar
	local bar = ...
	-- Read location starting at the second argument
	local home, n = wesnoth.read_location(select(2, ...))
	-- note: n will be 0 if a location wasn't found at that position
	-- This could be an error, or it could be handled as an optional parameter
	-- Next argument after that goes in mode
	local mode = select(n + 2, ...)
	-- Then read a location into target
	local target, m = wesnoth.read_location(select(n + 2, ...))
	-- Finally, read a parameter into moo
	local moo = select(m + n + 2, ...)
	-- Do stuff with all these parameters
	return true
end

With that code, all the following invocations of foo work:

foo('a', 'b', true) -- both optional locations omitted
foo('a', 1, 2, 'q', 5, 6, false) -- locations given as separate integer parameters
foo('a', 'm', {1, 7},  true) -- first location omitted, second given as 2-element array
foo('a', some_unit, 'z', {x = 5, y = 10}, false) -- a unit also functions as a location
foo('a', 7, 12, 'q', my_leader, true) -- mixing different forms also works


  Commit: c88f9b7c89820407d12fea578e0f6a157130b340
      https://github.com/wesnoth/wesnoth/commit/c88f9b7c89820407d12fea578e0f6a157130b340
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-02-19 (Fri, 19 Feb 2021)

  Changed paths:
    M data/lua/core.lua

  Log Message:
  -----------
  Fix the implementations of the deprecated get|set_terrain functions


  Commit: d48d537cc54d3fdbee31100dfd5838c7354c0de1
      https://github.com/wesnoth/wesnoth/commit/d48d537cc54d3fdbee31100dfd5838c7354c0de1
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-02-19 (Fri, 19 Feb 2021)

  Changed paths:
    M data/lua/core.lua

  Log Message:
  -----------
  Fix the implementations for assigning base|overlay_terrain on get_hex()


  Commit: 0467d2d311b59a1955c7279b72b65e97e1ea7e50
      https://github.com/wesnoth/wesnoth/commit/0467d2d311b59a1955c7279b72b65e97e1ea7e50
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-02-19 (Fri, 19 Feb 2021)

  Changed paths:
    M data/lua/core.lua

  Log Message:
  -----------
  Fix deprecation messages


  Commit: c0dd7b4c18fc2fb00d248db390749048637e1cce
      https://github.com/wesnoth/wesnoth/commit/c0dd7b4c18fc2fb00d248db390749048637e1cce
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-02-19 (Fri, 19 Feb 2021)

  Changed paths:
    M data/ai/lua/ai_helper.lua
    M data/ai/lua/battle_calcs.lua
    M data/ai/lua/ca_castle_switch.lua
    M data/ai/lua/ca_spread_poison.lua
    M data/ai/lua/generic_recruit_engine.lua
    M data/ai/lua/retreat.lua
    M data/ai/micro_ais/cas/ca_assassin_move.lua
    M data/ai/micro_ais/cas/ca_fast_attack_utils.lua
    M data/ai/micro_ais/cas/ca_goto.lua
    M data/ai/micro_ais/cas/ca_healer_move.lua
    M data/ai/micro_ais/cas/ca_protect_unit_move.lua
    M data/ai/micro_ais/cas/ca_recruit_random.lua
    M data/ai/micro_ais/cas/ca_stationed_guardian.lua
    M data/ai/micro_ais/cas/ca_zone_guardian.lua
    M data/campaigns/Descent_Into_Darkness/scenarios/04_Spring_of_Reprisal.cfg
    M data/campaigns/Heir_To_The_Throne/scenarios/13_The_Dwarven_Doors.cfg
    M data/campaigns/Two_Brothers/ai/ca_muff_toras_move.lua
    M data/campaigns/World_Conquest/lua/campaign/enemy_themed.lua
    M data/campaigns/World_Conquest/lua/game_mechanics/bonus.lua
    M data/campaigns/World_Conquest/lua/game_mechanics/supply.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/1A_Start.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/2A_Springs.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/2C_Glaciers.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/2D_Provinces.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/2E_Paradise.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/3C_Delta.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/3F_Wetland.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/4A_Thermal.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/4B_Volcanic.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/4C_Mines.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/6A_Rural.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/6B_Maritime.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration/6C_Industrial.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration_utils/engine.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration_utils/events.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration_utils/noise.lua
    M data/campaigns/World_Conquest/lua/map/postgeneration_utils/utilities.lua
    M data/campaigns/World_Conquest/lua/map/scenario_utils/bonus_points.lua
    M data/campaigns/World_Conquest/lua/optional_mechanics/destruction.lua
    M data/lua/wml-tags.lua
    M data/lua/wml/find_path.lua
    M data/lua/wml/random_placement.lua
    M data/modifications/pick_advance/main.lua

  Log Message:
  -----------
  Fix references to the now-removed get|set_terrain


  Commit: 00d990c120e2c33cefb84ee5456a0250b7bc10ee
      https://github.com/wesnoth/wesnoth/commit/00d990c120e2c33cefb84ee5456a0250b7bc10ee
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-02-19 (Fri, 19 Feb 2021)

  Changed paths:
    M src/scripting/lua_terrainmap.cpp

  Log Message:
  -----------
  Set __metatable on the replace_if_failed helper


Compare: https://github.com/wesnoth/wesnoth/compare/04541e1959c9...00d990c120e2



More information about the Commits mailing list