Map preview of randomly generated Shoppa maps

10 replies [Last post]
awilhelmscream
User offline. Last seen 4 years 37 weeks ago. Offline
Joined: 2013-05-31
Posts: 9

Hi,

why is there no preview for randomyl generated Shoppa maps, when there is one for "normal" randomly generated maps? Is this something that would be doable?

Thanks!

glum reaper
glum reaper's picture
User offline. Last seen 1 year 5 weeks ago. Offline
Joined: 2011-03-24
Posts: 56

awilhelmscream allegedly wrote:

Hi,

why is there no preview for randomyl generated Shoppa maps, when there is one for "normal" randomly generated maps? Is this something that would be doable?

Thanks!

To my (limited) knowledge the custom shoppa maps use a script to generate custom landforms. Since scripts run on mission load, it's impossible to create a preview image.

Proud member of Death's Angels for 3 billion years.

nemo
nemo's picture
User offline. Last seen 3 weeks 17 hours ago. Offline
Joined: 2009-01-28
Posts: 1861

Yep, that's pretty much it.
Well, preview image generation could run the script I guess...

Someone would have to teach it how to do this safely.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

awilhelmscream
User offline. Last seen 4 years 37 weeks ago. Offline
Joined: 2013-05-31
Posts: 9

OK, I still don't get it, but I guess I'll just believe you Big Grin
Thanks!

nemo
nemo's picture
User offline. Last seen 3 weeks 17 hours ago. Offline
Joined: 2009-01-28
Posts: 1861

awilhelmscream allegedly wrote:

OK, I still don't get it, but I guess I'll just believe you Big Grin
Thanks!

Normal map generation is using code inside the hedgewars game itself to make a map. This code is run twice. Once to make a preview image, then once again when the game is launched. All within the engine, so preview knows 'sactly what to do.

The shoppa map generation is, at present, a lua script that hooks into game on startup, and sends a bunch of draw commands using:
https://code.google.com/p/hedgewars/wiki/LuaDrawing

But, that's on actual startup, not preview startup. So the preview code does not get this drawing.
For it to work, we'd either have to call the normal startup lua hook in preview, which could be problematic, or add a preview hook that lua could use.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

nemo
nemo's picture
User offline. Last seen 3 weeks 17 hours ago. Offline
Joined: 2009-01-28
Posts: 1861

https://code.google.com/p/hedgewars/source/detail?r=fa5c83fd0ad9b6b87a3ee4961e25d6bf1b85ee3a

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

awilhelmscream
User offline. Last seen 4 years 37 weeks ago. Offline
Joined: 2013-05-31
Posts: 9

OK, thanks for the explanation!
Anyways, if it's ever possible that would be a nice feature! It's annoying when you want to play a quick Shoppa game, but you get a map without any water and the game takes forever.

nemo
nemo's picture
User offline. Last seen 3 weeks 17 hours ago. Offline
Joined: 2009-01-28
Posts: 1861

Uuuummmm...
That revision commit above added it, if you'd followed the link it had a comment mentioning this.

http://m8y.org/hw/luamap.png

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Wuzzy
Wuzzy's picture
User offline. Last seen 3 weeks 2 days ago. Offline
Joined: 2012-06-20
Posts: 1301

Oh, cool. But this also has a slight regression: Whenever you change the script, the preview image reloads, weather it invokes onPreviewInit() or not. Which is slightly annoying, as the game re-calculates the same pseudorandom map again and again.

From the commits I can see that onPreviewInit is new here. But I don’t see the point of this function, if the game updates the preview anyways.

Wouldn’t it make more sense to only update the preview image if onPreviewInit is actually called?

Hi, I am a Hedgewars developer. Smile

nemo
nemo's picture
User offline. Last seen 3 weeks 17 hours ago. Offline
Joined: 2009-01-28
Posts: 1861

Would be interesting if you could describe how that engine/frontend interaction should occur, Wuzzy, keeping in mind that the engine is, at present a separate execution per preview launch. Best guess I can figure is you are proposing frontend loading lua, which it doesn't do right now.

I was considering adding a line to the lua cfg to inform of lua doing terrain gen, but not doing it right now. The cost isn't too terribly high.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

unC0Rr
unC0Rr's picture
User offline. Last seen 1 year 5 weeks ago. Offline
Joined: 2006-11-27
Posts: 576

I think simple regexp could be enough for frontend to check if script messes with map generation.

User login

Copyright © 2004-2024 Hedgewars Project. All rights reserved. [ contact ]