From 17870a0fe0d96cfc0a80a16760a85f3fcd4a194c Mon Sep 17 00:00:00 2001 From: RollanzMushing <39258026+RollanzMushing@users.noreply.github.com> Date: Mon, 7 Jun 2021 20:38:15 -0400 Subject: [PATCH 1/5] GMCP_mapper.xml - empty info check Use environment colour if the info entry is empty string - For Achaea, the details subfield of `Room.Info` GMCP message is always sent even if it's just an empty array - Results in a `got_info("")` call, which overwrites a `NULL` value in the `info` column with a blank string --- GMCP_Mapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GMCP_Mapper.xml b/GMCP_Mapper.xml index 52e1b5e..38deaee 100644 --- a/GMCP_Mapper.xml +++ b/GMCP_Mapper.xml @@ -893,7 +893,7 @@ function get_room (uid) -- special room fill colours - if room.info then + if room.info and string.len(room.info) > 0 then if string.match (room.info, "shop") then room.fillcolour = config.SHOP_FILL_COLOUR.colour room.fillbrush = 8 From 7cf28c77726ee2087482301407b9bde09c1ac55c Mon Sep 17 00:00:00 2001 From: RollanzMushing Date: Tue, 8 Jun 2021 21:57:37 -0400 Subject: [PATCH 2/5] # Terrain colour - Add `mapper skipSpecial` alias to ignore rooms in Area 0 - Area 0 is for special rooms such as wilderness, ships, etc. - Remove coercion of `terrain_colours` entries to numbers - Add `__index` metamethod to `colour_lookup` to convert to RGB if needed - Strip standard elevation string (e.g."Flying above") from room name - Add default colours to terrains I have on record --- GMCP_Mapper.xml | 91 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 6 deletions(-) diff --git a/GMCP_Mapper.xml b/GMCP_Mapper.xml index 38deaee..58fe12d 100644 --- a/GMCP_Mapper.xml +++ b/GMCP_Mapper.xml @@ -195,7 +195,16 @@ mapper resume --> resume last speedwalk or hyperlinked speedwalk > - + + + + + = 0 and ind <= 15 then + return rawget(t, ind) + elseif type(k) == "string" then + return ColourNameToRGB(k) + elseif ind then + return ind + end -- if + end -- function + }) -- here when location changes, eg. : Room.Num 7476 function got_room_number (s) @@ -1489,6 +1544,10 @@ end -- got_room_number function got_room_name (s) local brief = s + --Flying above and In the Trees above + brief = brief:match("Flying above (.+)") or brief + brief = brief:match("In the Trees above (.+)") or brief + if not current_room then return end -- don't have room @@ -1642,6 +1701,16 @@ handlers = { function gotRoomInfo (info) + -- option to skip wilderness rooms pending more robust handling + if skipSpecial then + if info.area and info.area then + local areaID = tonumber(info.area:match("(%d+),%d+,%d+,%d+")) + if not areaID or areaID == 0 then + return + end + end + end + if info.num then got_room_number (info.num) end -- if @@ -1982,6 +2051,16 @@ function map_areas (name, line, wildcards) end -- map_areas +function mapper_toggleSkipSp() + if skipSpecial then + skipSpecial = false + SetVariable("skipSpecial", "0") + else + skipSpecial = true + SetVariable("skipSpecial", "1") + end + mapper.mapprint ("mapper skipSpecial set to " .. tostring(skipSpecial)) +end valid_direction = { n = "n", From 0aefe991e61b8d064cdfbff65b969e4df973caa7 Mon Sep 17 00:00:00 2001 From: RollanzMushing Date: Tue, 8 Jun 2021 22:14:03 -0400 Subject: [PATCH 3/5] # Bug fixes - default colours --- GMCP_Mapper.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GMCP_Mapper.xml b/GMCP_Mapper.xml index 58fe12d..744b5cb 100644 --- a/GMCP_Mapper.xml +++ b/GMCP_Mapper.xml @@ -1462,7 +1462,7 @@ terrain_colours = { Ausafoss = "#00CCFF", Reef = "#33CCCC", Ocean = "#0000CC", - ["Deep Ocean"] = #00008E", + ["Deep Ocean"] = "#00008E", Hills = "#777400", Mountains = "#824100", Vessel = "#5E4320", @@ -1473,8 +1473,8 @@ terrain_colours = { Trees = "#009600", Swamps = "#52670D", Jungle = "#006C00", - Constructed underground = "#8C8C8C", - Natural underground = "#4D4D4D", + ["Constructed underground"] = "#8C8C8C", + ["Natural underground"] = "#4D4D4D", Ruins = "#DDDDDD", Urban = "#FC4AFC", Valley = "#BA00E6", From bd17ff4421221745210086b737ab89e9a13b84bf Mon Sep 17 00:00:00 2001 From: RollanzMushing Date: Wed, 9 Jun 2021 00:58:25 -0400 Subject: [PATCH 4/5] # Area name tracking - automatically add area uid/name information to the `areas` table - this uses __newindex metamethod - parsing rows from `areas` SQL table into `areas` Lua table now uses rawset - explicitly parse current area id from coords into `current_areaid` - `areas` table now indexed with `current_areaid` to ensure uniform behaviour - fix skipSpecial logic - change room colouring logic - use terrain colours if didn't already set colour based on `room.info` --- GMCP_Mapper.xml | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/GMCP_Mapper.xml b/GMCP_Mapper.xml index 744b5cb..b1c857e 100644 --- a/GMCP_Mapper.xml +++ b/GMCP_Mapper.xml @@ -467,6 +467,15 @@ default_config = { local rooms = {} local areas = {} + +setmetatable(areas, {__newindex = function(t, k, v) + if tonumber(k) then + db:execute (string.format ([[INSERT INTO AREAS(uid, name, date_added) VALUES (%s, %s, DATETIME('NOW'));]], fixsql(k), fixsql(v))) + end + rawset(t, k, v) + end + }) + local environments = {} local user_terrain_colour = {} local skipSpecial = GetVariable("skipSpecial") == "1" or false @@ -846,7 +855,7 @@ function get_room (uid) room.area = areas [room.area] or string.format ("%s", room.area or "") if uid == current_room then - current_area = room.area + current_area = room.area -- string by default end -- if -- build hover message @@ -902,22 +911,29 @@ function get_room (uid) room.fillbrush = 1 -- no fill -- special room fill colours - + local infoColour = false if room.info and string.len(room.info) > 0 then if string.match (room.info, "shop") then room.fillcolour = config.SHOP_FILL_COLOUR.colour room.fillbrush = 8 + infoColour = true elseif string.match (room.info, "postoffice") then room.fillcolour = config.POSTOFFICE_FILL_COLOUR.colour room.fillbrush = 8 + infoColour = true elseif string.match (room.info, "bank") then room.fillcolour = config.BANK_FILL_COLOUR.colour room.fillbrush = 8 + infoColour = true elseif string.match (room.info, "newsroom") then room.fillcolour = config.NEWSROOM_FILL_COLOUR.colour room.fillbrush = 8 + infoColour = true end -- if - else + end -- if + + -- not coloured using room.info + if not infoColour then -- use terrain colour if environmentname then if user_terrain_colour [environmentname] then @@ -1326,7 +1342,7 @@ function add_area (room, uid) mapper.draw (tostring (current_room)) -end -- add_area +end -- add_area function room_click (uid, flags) @@ -1415,7 +1431,8 @@ function OnPluginInstall () -- grab all area names for row in db:nrows("SELECT * FROM areas") do - areas [row.uid] = row.name + -- areas [row.uid] = row.name + rawset(areas, row.uid, row.name) end -- finding areas -- grab all user terrain info @@ -1451,7 +1468,7 @@ function OnPluginSaveState () mapper.save_state () SetVariable ("config", "config = " .. serialize.save_simple (config)) end -- OnPluginSaveState - + terrain_colours = { Abstract = "#363F03", Nothing = "#000000", @@ -1487,7 +1504,6 @@ terrain_colours = { Stars = "#EFFFFF", } - -- ANSI colours lookup (for terrain_colours) colour_lookup = { @@ -1659,6 +1675,8 @@ function got_coordinates (s) room = load_room_from_database (current_room) end -- not in cache + current_areaid = string.match (s, "^(.-),[%d-]+,[%d-]+,[%d-]+") + if room and (room.area == nil or tonumber (room.area) == 0) then save_coordinates_to_database (current_room, s) mapper.draw (tostring (current_room) ) -- redraw room with area @@ -1700,14 +1718,12 @@ handlers = { } function gotRoomInfo (info) - + current_areaid = nil -- option to skip wilderness rooms pending more robust handling + --print("info area: "..tostring(info.area=="")) if skipSpecial then - if info.area and info.area then - local areaID = tonumber(info.area:match("(%d+),%d+,%d+,%d+")) - if not areaID or areaID == 0 then - return - end + if info.area and info.area == "" then + return end end @@ -1740,8 +1756,8 @@ function gotRoomInfo (info) got_info (table.concat (info.details, ",")) end -- if - if info.area then - areas [current_area] = info.area:sub (1, 1):upper () .. info.area:sub (2) + if info.area and current_areaid then + areas [current_areaid] = info.area:sub (1, 1):upper () .. info.area:sub (2) end -- if end -- gotRoomInfo From e3f602aaf06200828cee3d994fbf55f1acfd6c91 Mon Sep 17 00:00:00 2001 From: RollanzMushing Date: Wed, 9 Jun 2021 01:03:56 -0400 Subject: [PATCH 5/5] # Bug fix - capitalization --- GMCP_Mapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GMCP_Mapper.xml b/GMCP_Mapper.xml index b1c857e..7e48f92 100644 --- a/GMCP_Mapper.xml +++ b/GMCP_Mapper.xml @@ -1562,7 +1562,7 @@ function got_room_name (s) --Flying above and In the Trees above brief = brief:match("Flying above (.+)") or brief - brief = brief:match("In the Trees above (.+)") or brief + brief = brief:match("In the trees above (.+)") or brief if not current_room then return