Loading...
  OR  Zero-K Name:    Password:   

Improved (tracking) unit marker widget

7 posts, 481 views
Post comment
Filter:    Player:  
sort

20 months ago
1. For unfinished units/building, upon subsequent scout/spotting, updates the marker with the current building progress. Adds game time at which the info was acquired (e.g., "Antinuke (10% at 08:17)", then on the next scout replaces with "Antinuke (20% at 12:15)"), or, if finished, with simply "Antinuke").

2. For moving units, if spotted in a new location, removes the old marker, and places a new marker in the new location.

3. If a unit/building destroyed, removes its marker.

Upon installing, one needs to uncheck the original unit marker widget, and to select the desired units/buildings in "Settings->Interface->Tracking Unit Marker"

Widget code:

[Spoiler]

The following part is for people having some experience with widgets:

Since it is my first widget, and actually first anything Spring-related and first Lua code, I suspect it can be improved. Particularly, I had the following issue: to update marker of a building in progress, I tried to issue
spMarkerErasePosition(position)
and then
spMarkerAddPoint(same postion, new text)


What happened is the old marker gone, but the new marker appeared just for half a second or so, then disappeared. Seems to me both commands were issued in the same drawing frame or something like that. To solve this I made an (ugly) hack: to defer the creation of the new marker for 15 game frames. Seems to work, but I think there should be some more elegant (native) solution. I commented the code, so if one wants to see how it works, it should be relatively easy.

More generally, I'm confused with the relationships between the following concepts: "game frame", "drawing frame", "sim frame", FPS.
For example, as mentioned in https://springrts.com/wiki/Lua:Callins:
addon.Update(dt)

    Called for every draw frame (including when the game is paused) and at least once per sim frame except when catching up. The parameter is the time since the last update.

addon.GameFrame(frame)

    Called for every game simulation frame (30 per second). Starts at frame 0 in 101.0+ and 1 in previous versions.


I'll be glad if someone could point to the explanation of these terms and how they are related to the issue I had.
+7 / -0
quote:
More generally, I'm confused with the relationships between the following concepts: "game frame", "drawing frame", "sim frame", FPS.

The game tries to run simulation (actual physics) at 30 frames per second while drawing the interpolated visuals (eg what you see) of what happens at as many frames as possible.

A sim frame is the same thing as a game frame, a discrete simulation step. A draw frame is each time the engine redraws the screen. Usually there are a lot more drawframes than simframes per second.

Simulation frames are never skipped, because skipping them would break sync. Drawframes can be skipped altogether with nothing too bad happening (besides nothing being drawn, but who needs pixels anyway).

--

Markers get saved in replays, so i'm not sure they are exactly user-only non-sync objects. They have to be sent over the network and afaict that happens on a frame-by-frame basis.

But sending new marker creation just one simframe (33ms) after deletion of previous ones should be safe.
+1 / -0

20 months ago
The widget this is based off 100% doesn't send pings over the network, but I have seen widgets which do(shaman deved a widget to ping build progress to the team I think)
+0 / -0

20 months ago
Thanks, some questions to see if I got it right:

1. So FPS is drawing frames per sec?

2. Sim frames equal for all players, draw frames could be different?

3. Server lag and personal lag are 2 different things? If server lags, it can't do 30 sim frames per sec, so game is slower for all? If a person lags, his CPU cant do 30 per sec?

4. Sim frame rate and lag depend mostly on network and CPU, while draw frames (FPS) depend on GPU?




quote:
Markers get saved in replays


Sure it includes private markers? I don't remember I've seen my private markers in replays.

quote:
But sending new marker creation just one simframe (33ms) after deletion of previous ones should be safe.

I tried to defer by 5 frames and it didn't work, so switched to 15.
+0 / -0
quote:
1. So FPS is drawing frames per sec?

yes

quote:
2. Sim frames equal for all players, draw frames could be different?

yes; if you can't run 30 simframes per second you will start to fall back.

quote:
3. Server lag and personal lag are 2 different things? If server lags, it can't do 30 sim frames per sec, so game is slower for all? If a person lags, his CPU cant do 30 per sec?

"Server lag" and "personal lag" are kinda not very useful terms.

Server is most of the time an instance of `spring-dedicated` and does not run any simulation at all. It just relays packets between each client. Then each and every client runs their own instance of the game world, and injects player commands into this simulation every simframe.

The closest meaningful thing related to "server lag" is perhaps the communication lag, that is, how much time it takes for your network to transport your commands to the server, and for the server to transmit the other players' commands to you. This is kind of personal though: it does not depend on the server but on the connection between you and the server.

The other kind of "lag" then is the simulation compute cost, see previous answer. But this is also "personal".

quote:
4. Sim frame rate and lag depend mostly on network and CPU, while draw frames (FPS) depend on GPU?

yes
+0 / -0


19 months ago
quote:
The widget this is based off 100% doesn't send pings over the network, but I have seen widgets which do(shaman deved a widget to ping build progress to the team I think)


Not just ping build progress but estimate in fog of war even.
+0 / -0


18 months ago
Looks good. Merged https://github.com/ZeroK-RTS/Zero-K/commit/9e286d552c0ceefb61c356adca624003a971a289
+0 / -0