distribution of units from a host?
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: distribution of units from a host?
It looks the main asset of your trick is you can use custom names of unit types. (Conquest uses core types (e.g. Spearman), and must use unit names for names of Conquest types (Militia).)Anonymissimus wrote:There is probably not much additional cleverness in the structure over what your addon already has; I'm using an overlay for the image as well.
Or ... is this not an asset of your trick, but it is a lua's functionality?
(btw do you use the variable sow_units en block, or do you work with every key individually? I wonder why you use [unit_type], but then you still must use the Fog Clearer. Is your 'unit_type' just a fake, and any name for this tag could be used?)
Your trick might also allow to use custom images for clients that have the addon (#ifhave image), and core images for clients that don't have it? It looks like a better solution than overlays.
Do you think WML allows an access to [unit]'s keys type= and image= ?Anonymissimus wrote:Most of the code should be doable in wml as well but I would expect it to become a lot more complicated.
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: distribution of units from a host?
I need to, since it can also be played with every client having the addon, which means that the real custom types are used without image replacements.SlowThinker wrote:It looks the main asset of your trick is you can use custom names of unit types.
The type shows still up as Fog Clearer in the UI and :inspect of course, I also can only change the unit's name to match what it should be. It would cause unknown unit type errors.
No.SlowThinker wrote:Or ... is this not an asset of your trick, but it is a lua's functionality?
I dunno what you mean. If you refer to the lua code, that variable could have any name. It's called unit_type since it contains the wml block describing one of my custom units. I can use all of the data from that except for the type= (and image=) atribute value. For instance, it retrieves how many hitpoints my custom unit should have and then sets the new Fog Clearer's hitpoints to that.SlowThinker wrote:(btw do you use the variable sow_units en block, or do you work with every key individually? I wonder why you use [unit_type], but then you still must use the Fog Clearer. Is your 'unit_type' just a fake, and any name for this tag could be used?)
No, there is no way to detect whether a remote client has a certain image (or addon). Anyway, you can't use custom images on one client and core ones on another. That would be OOS since the [unit]image= (or [unit]overlays=) is part of the gamestate.SlowThinker wrote: Your trick might also allow to use custom images for clients that have the addon (#ifhave image), and core images for clients that don't have it? It looks like a better solution than overlays
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: distribution of units from a host?
Yes, I meant your lua code.Anonymissimus wrote:If you refer to the lua code, that variable could have any name. It's called unit_type since it contains the wml block describing one of my custom units. I can use all of the data from that except for the type= (and image=) atribute value.
Oh

I think there is a way. (edit: Maybe there is a way, but has no real effect, as require_era=yes must be used. /edit) During turn 1 each client can "check whether side.controller equals human" (http://forums.wesnoth.org/viewtopic.php?f=21&t=34516) and so find out its side, then use #ifhave on the image file. In the beginning of turn 2 all the needed information is gathered.Anonymissimus wrote:No, there is no way to detect whether a remote client has a certain image (or addon).
edit: But I am not sure how to save the information (whether the local client has / doesn't have the file) and not to cause an OOS. Maybe the only way how to send the information to other clients is to create a one-option dialogue and to ask the player to hit Enter; the need of a human interaction is painful though.
And I am not sure about this point: if [era] require_era=yes then each client preprocesses his own era code (and so #ifhave reflects local situation)?/edit
******************************************
I don't understand one point: you use Fog Clearer + overlay, so how will players without the SoW download see anything?
Last edited by SlowThinker on January 1st, 2012, 8:15 pm, edited 1 time in total.
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: distribution of units from a host?
Fog Clearer itself is a core unit; and it's just that core unit which seems most suitable for the task. So there is no problem with it in the first place.SlowThinker wrote:I don't understand one point: you use Fog Clearer + overlay, so how will players without the SoW download see anything?
All modifications to it, including the overlay, are done by action wml or action lua which has been sent to the remote clients from the host after the host has preprocessed the scenario. And the image which is overlayed is a core one so that again works on clients which don't have the image as well.
No.SlowThinker wrote:And I am not sure about this point: if [era] require_era=no then each client preprocesses his own era code (and so #ifhave reflects local situation)
Understand how #ifhave works: The condition is evaluated only on the host since the scenario is preprocessed only on the host. Thus, all other clients act (at wml event execution time) due to the #ifhave result from the host, not due to whether they actually have the file (which may or may not be). Furthermore, I wouldn't expect #ifhave to work with a binary file such as an image.
Now, if your addon *does* require people to have it downloaded, there is an easy way to make sure nobody can get kicked: Include a [era]require_era=yes in your addon and choose this era when the game is created. This checks all players who want to join whether they have the era (and thus have the addon). It is also easy to check whether the right era is used, and both can be done wml-only. See also: http://forums.wesnoth.org/viewtopic.php ... 12#p484412
Now, if we have require_era=no, then that just means: "Trust me, engine, this era does not require people to have it downloaded. It does not use any toplevel tags which don't get sent to the remote clients such as unit_type and terrain_type."
I think there is a way to do the check you want; it needs a side turn event executed for each side during the first game turn, wesnoth.synchronize_choice, wesnoth.dofile, pcall and a dummy custom lua file which you try to load. If the load doesn't succeed the currently active client doesn't have the addon, if it does, it has, and the result will be synched due to synchronize_choice. It is similar to the code I use in SoW to check that all the clients have the same addon version.
untested:
Code: Select all
[event]
name=side turn
first_time_only=no
[filter_condition]
[variable]
name=turn_number
equals=1
[/variable]
[/filter_condition]
[lua]
code=<<
local has_addon = wesnoth.synchronize_choice(function()
--dummy.lua can be completely empty but must exist
local has_addon = pcall(wesnoth.dofile, "~add-ons/Addon/dummy.lua")
return { result = has_addon }
end).result
wesnoth.set_variable("side_" .. tostring(wesnoth.current.side) .. "_has_addon", has_addon)
>>
[/lua]
[/event]
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: distribution of units from a host?
It is strange, Conquest works differently: Boat (a core unit) + overlay is used, and the overlay image of Dhow is in the Conquest package. People that don't have the overlay image see Boat only.Anonymissimus wrote:Fog Clearer itself is a core unit; and it's just that core unit which seems most suitable for the task. So there is no problem with it in the first place.
All modifications to it, including the overlay, are done by action wml or action lua which has been sent to the remote clients from the host after the host has preprocessed the scenario. And the image which is overlayed is a core one so that again works on clients which don't have the image as well.
So I expected that people who played SoW without downloading saw Fog Clearer's empty image only.
I am sorry, I wanted to write [era] require_era=yes [/era]. This way the era should not be distributed, and every client should use (and preprocess) his own era code.Anonymissimus wrote:No.SlowThinker wrote:And I am not sure about this point: if [era] require_era=no then each client preprocesses his own era code (and so #ifhave reflects local situation)
Understand how #ifhave works: The condition is evaluated only on the host since the scenario is preprocessed only on the host. Thus, all other clients act (at wml event execution time) due to the #ifhave result from the host, not due to whether they actually have the file (which may or may not be). Furthermore, I wouldn't expect #ifhave to work with a binary file such as an image.
(But with require_era=yes there is no reason to check the presence of files)
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: distribution of units from a host?
No. I don't use the custom image at all if any of the clients isn't guaranteed to have it. The overlay image is a core one as I said.SlowThinker wrote:It is strange, Conquest works differently: Boat (a core unit) + overlay is used, and the overlay image of Dhow is in the Conquest package. People that don't have the overlay image see Boat only.
So I expected that people who played SoW without downloading saw Fog Clearer's empty image only
If I'd use the custom image, remote clients without the addon are spammed with "image not found" stderr messages, that's not acceptable. Of course this has the disadvantage of people who have the addon still seeing the replacement image even though they have the better "real" image.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: distribution of units from a host?
Thank you for all the elucidations.
I misunderstood you and didn't know that you use a core image for the overlay. That explains everything.
But Conquest must use a custom image for the overlay, since there is no additional boat image in the core (I didn't know this solution produces "image not found" in stderr.txt, but I can live with it)
I misunderstood you and didn't know that you use a core image for the overlay. That explains everything.
But Conquest must use a custom image for the overlay, since there is no additional boat image in the core (I didn't know this solution produces "image not found" in stderr.txt, but I can live with it)
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: distribution of units from a host?
For those who didn't read all this thread:
This way in order to play Conq-, a player must have Ageless Era or Conq- installed.
Will it work without any bad side effects?
My add-on (Conquest Minus, next Conq-) requires Ageless Era for some maps. But some people don't like to download Ageless Era, also because it may cause "too much WML" problem.
So my idea is to copy the code for required types of units (including images etc.) from Ageless era to Conq-:Code: Select all
#ifnhave ~add-ons/Ageless_Era/units/EE_units/kalifa/1c-Elite_Ghazi.cfg
[unit_type]
id=AE Kalifa Elite Ghazi
...
[unit_type]
#endif
...
Will it work without any bad side effects?
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: distribution of units from a host?
I don't think I understand what you think.
The #ifnhave doesn't make much sense there if you copy wml definitions and according images anyway I guess. It could perhaps cause some OOS errors if some clients use the definitions from AE and others your custom ones.
The #ifnhave doesn't make much sense there if you copy wml definitions and according images anyway I guess. It could perhaps cause some OOS errors if some clients use the definitions from AE and others your custom ones.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: distribution of units from a host?
Yes, I know later the AE definitions may change, while my custom definitions will stay unchanged.
So if the unit types are checked for sync errors then it won't work.
But if only individual unit instances are checked for sync errors then it might work, because Conq- will rewrite all possible unit's attributes (i.e. all attributes except id, name, image, the sounds ...) immediately after any unit will be created. Therefore the interval in which units will be different on different clients will be very short.
So if the unit types are checked for sync errors then it won't work.
But if only individual unit instances are checked for sync errors then it might work, because Conq- will rewrite all possible unit's attributes (i.e. all attributes except id, name, image, the sounds ...) immediately after any unit will be created. Therefore the interval in which units will be different on different clients will be very short.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: distribution of units from a host?
Most critical is everything that can influence the outcome of combat I think. The engine does AFAIK never check "immediately" for OOS, not currently at least.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign