System Replace Terrain

Troll-Brain

You can change this now in User CP.
Reaction score
85
You can change them when needed though.
So if all players enter some dungeon or something, change the terrain type in there. Then change it back to dirt and stuff.

Does anyone know if changing terrain types desyncs if used with GetLocalPlayer()?

Well i'm to lazy to test your solution.
About the GetLocalPlayer it should desycn with blight for some obvious reasons.
For the others i dunno but at least noobs users would be able to make desync code.
 

Flare

Stops copies me!
Reaction score
662
My guess is yes (or, at least it could cause a desync from other stuff)

1) Terrain-type comparisons, not sure if they will directly cause a desync or not, but it's likely that it could be caused by something else later

2) What if you replaced unbuildable terrain with buildable terrain for a local player? Not sure of result, but it doesn't sound like it's going to end well :p
 

Viikuna

No Marlo no game.
Reaction score
265
Yes. If something affects gameplay, it will desync when used with GetLocalPlayer.
 
Reaction score
91
JASS:
library TTs

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//-=-=-= List of Terrain Types =-=-=-
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//-=-=-=-= Thanks to Romek  -=-=-=-=-
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
scope LORDAERONSUMMER
// Lordaeron Summer
globals
    public constant integer DIRT = 'Ldrt'
    public constant integer ROUGH_DIRT = 'Ldro'
    public constant integer GRASSY_DIRT = 'Ldrg'
    public constant integer ROCK = 'Lrok'
    public constant integer GRASS = 'Lgrs'
    public constant integer DARK_GRASS = 'Lgrd'
    public constant integer DIRT_CLIFF = 'cLc2'
    public constant integer GRASS_CLIFF = 'cLc1'
endglobals

endscope

scope LORDAERONFALL
// Lordaeron Fall
globals
    public constant integer DIRT = 'Fdrt'
    public constant integer ROUGH_DIRT = 'Fdro'
    public constant integer GRASSY_DIRT = 'Fdrg'
    public constant integer ROCK = 'Frok'
    public constant integer GRASS = 'Fgrs'
    public constant integer DARK_GRASS = 'Fgrd'
    public constant integer DIRT_CLIFF = 'cFc2'
    public constant integer GRASS_CLIFF = 'cFc1'
endglobals

endscope

scope LORDAERONWINTER
// Lordaeron Winter
globals
    public constant integer DIRT = 'Wdrt'
    public constant integer ROUGH_DIRT = 'Wdro'
    public constant integer GRASSY_SNOW = 'Wsng'
    public constant integer ROCK = 'Wrok'
    public constant integer GRASS = 'Wgrs'
    public constant integer SNOW = 'Wsnw'
    public constant integer GRASS_CLIFF = 'cWc2'
    public constant integer SNOW_CLIFF = 'cWc1'
endglobals

endscope

scope BARRENS
// Barrens
globals
    public constant integer DIRT = 'Bdrt'
    public constant integer ROUGH_DIRT = 'Bdrh'
    public constant integer PEBBLES = 'Bdrr'
    public constant integer GRASSY_DIRT = 'Bdrg'
    public constant integer DESERT = 'Bdsr'
    public constant integer DARK_DESERT = 'Bdsd'
    public constant integer ROCK = 'Bflr'
    public constant integer GRASS = 'Bgrr'
    public constant integer DESERT_CLIFF = 'cBc2'
    public constant integer GRASS_CLIFF = 'cBc1'
endglobals

endscope

scope ASHENVALE
// Ashenvale
globals
    public constant integer DIRT = 'Adrt'
    public constant integer ROUGH_DIRT = 'Adrd'
    public constant integer GRASS = 'Agrs'
    public constant integer ROCK = 'Arck'
    public constant integer LUMPY_GRASS = 'Agrd'
    public constant integer VINES = 'Avin'
    public constant integer GRASSY_DIRT = 'Adrg'
    public constant integer LEAVES = 'Alvd'
    public constant integer DIRT_CLIFF = 'cAc2'
    public constant integer GRASS_CLIFF = 'cAc1'
endglobals

endscope

scope FELWOOD
// Felwood
globals
    public constant integer DIRT = 'Cdrt'
    public constant integer ROUGH_DIRT = 'Cdrd'
    public constant integer POISON = 'Cpos'
    public constant integer ROCK = 'Crck'
    public constant integer VINES = 'Cvin'
    public constant integer GRASS = 'Cgrs'
    public constant integer LEAVES = 'Clvg'
    public constant integer DIRT_CLIFF = 'cCc2'
    public constant integer GRASS_CLIFF = 'cCc1'
endglobals

endscope

scope NORTHREND
// Northrend
globals
    public constant integer DIRT = 'Ndrt'
    public constant integer DARK_DIRT = 'Ndrd'
    public constant integer ROCK = 'Nrck'
    public constant integer GRASS = 'Ngrs'
    public constant integer ICE = 'Nice'
    public constant integer SNOW = 'Nsnw'
    public constant integer ROCKY_SNOW = 'Nsnr'
    public constant integer DIRT_CLIFF = 'cNc2'
    public constant integer SNOW_CLIFF = 'cNc1'
endglobals

endscope

scope CITYSCAPE
// Cityscape
globals
    public constant integer DIRT = 'Ydrt'
    public constant integer ROUGH_DIRT = 'Ydtr'
    public constant integer BLACK_MARBLE = 'Yblm'
    public constant integer BRICK = 'Ybtl'
    public constant integer SQUARE_TILES = 'Ysqd'
    public constant integer ROUND_TILES = 'Yrtl'
    public constant integer GRASS = 'Ygsb'
    public constant integer GRASS_TRIM = 'Yhdg'
    public constant integer WHITE_MARBLE = 'Ywmb'
    public constant integer DIRT_CLIFF = 'cYc2'
    public constant integer SQUARE_TILES_CLIFF = 'cYc1'
endglobals

endscope

scope VILLAGE
// Village
globals
    public constant integer DIRT = 'Vdrt'
    public constant integer ROUGH_DIRT = 'Vdrr'
    public constant integer CROPS = 'Vcrp'
    public constant integer COBBLE_PATH = 'Vcbp'
    public constant integer STONE_PATH = 'Vstp'
    public constant integer SHORT_GRASS = 'Vgrs'
    public constant integer ROCKS = 'Vrck'
    public constant integer THICK_GRASS = 'Vgrt'
    public constant integer DIRT_CLIFF = 'cVc2'
    public constant integer GRASS_THICK_CLIFF = 'cVc1'
endglobals

endscope

scope VILLAGEFALL
// Village Fall
globals
    public constant integer DIRT = 'Qdrt'
    public constant integer ROUGH_DIRT = 'Qdrr'
    public constant integer CROPS = 'Qcrp'
    public constant integer COBBLE_PATH = 'Qcbp'
    public constant integer STONE_PATH = 'Qstp'
    public constant integer SHORT_GRASS = 'Qgrs'
    public constant integer ROCKS = 'Qrck'
    public constant integer THICK_GRASS = 'Qgrt'
    public constant integer DIRT_CLIFF = 'cQc2'
    public constant integer GRASS_THICK_CLIFF = 'cQc1'
endglobals

endscope

scope DALARAN
// Dalaran
globals
    public constant integer DIRT = 'Xdrt'
    public constant integer ROUGH_DIRT = 'Xdtr'
    public constant integer BLACK_MARBLE = 'Xblm'
    public constant integer BRICK_TILES = 'Xbtl'
    public constant integer SQUARE_TILES = 'Xsqd'
    public constant integer ROUND_TILES = 'Xrtl'
    public constant integer GRASS = 'Xgsb'
    public constant integer TRIM_GRASS = 'Xhdg'
    public constant integer WHITE_MARBLE = 'Xwmb'
    public constant integer DIRT_CLIFF = 'cXc2'
    public constant integer SQUARE_TILES_CLIFF = 'cXc1'
endglobals

endscope

scope DUNGEON
// Dungeon
globals
    public constant integer DIRT = 'Ddrt'
    public constant integer BRICK = 'Dbrk'
    public constant integer RED_STONES = 'Drds'
    public constant integer LAVA_CRACKS = 'Dlvc'
    public constant integer LAVA = 'Dlav'
    public constant integer DARK_ROCKS = 'Ddkr'
    public constant integer GREY_STONES = 'Dgrs'
    public constant integer SQUARE_TILES = 'Dsqd'
    public constant integer DIRT_CLIFF = 'cDc2'
    public constant integer SQUARE_TILES_CLIFF = 'cDc1'
endglobals

endscope

scope UNDERGROUND
// Underground
globals
    public constant integer DIRT = 'Gdrt'
    public constant integer BRICK = 'Gbrk'
    public constant integer RED_STONES = 'Grds'
    public constant integer LAVA_CRACKS = 'Glvc'
    public constant integer LAVA = 'Glav'
    public constant integer DARK_ROCKS = 'Gdkr'
    public constant integer GREY_STONES = 'Ggrs'
    public constant integer SQUARE_TILES = 'Gsqd'
    public constant integer DIRT_CLIFF = 'cGc2'
    public constant integer SQUARE_TILES_CLIFF = 'cGc1'
endglobals

endscope

scope SUNKENRUINS
// Sunken Ruins
globals
    public constant integer DIRT = 'Zdrt'
    public constant integer ROUGH_DIRT = 'Zdtr'
    public constant integer GRASSY_DIRT = 'Zdrg'
    public constant integer SMALL_BRICKS = 'Zbks'
    public constant integer SAND = 'Zsan'
    public constant integer LARGE_BRICKS = 'Zbkl'
    public constant integer ROUND_TILES = 'Ztil'
    public constant integer GRASS = 'Zgrs'
    public constant integer DARK_GRASS = 'Zvin'
    public constant integer DIRT_CLIFF = 'cZc2'
    public constant integer LARGE_BRICKS_CLIFF = 'cZc1'
endglobals

endscope

scope ICECROWNGLACIER
// Icecrown Glacier
globals
    public constant integer DIRT = 'Idrt'
    public constant integer ROUGH_DIRT = 'Idtr'
    public constant integer DARK_ICE = 'Idki'
    public constant integer BLACK_BRICKS = 'Ibkb'
    public constant integer RUNE_BRICKS = 'Irbk'
    public constant integer TILED_BRICKS = 'Itbk'
    public constant integer ICE = 'Iice'
    public constant integer BLACK_SQUARES = 'Ibsq'
    public constant integer SNOW = 'Isnw'
    public constant integer RUNE_BRICKS_CLIFF = 'cIc2'
    public constant integer SNOW_CLIFF = 'cIc1'
endglobals

endscope

scope OUTLAND
// Outland
globals
    public constant integer DIRT = 'Odrt'
    public constant integer LIGHT_DIRT = 'Odtr'
    public constant integer ROUGH_DIRT = 'Osmb'
    public constant integer CRACKED_DIRT = 'Ofst'
    public constant integer FLAT_STONES = 'Olgb'
    public constant integer ROCK = 'Orok'
    public constant integer LIGHT_FLAT_STONES = 'Ofsl'
    public constant integer ABYSS = 'Oaby'
    public constant integer ABYSS_CLIFF = 'cOc1'
    public constant integer ROUGH_DIRT_CLIFF = 'cOc2'
endglobals

endscope

scope BLACKCITADEL
// Black Citadel
globals
    public constant integer DIRT = 'Kdrt'
    public constant integer LIGHT_DIRT = 'Kfsl'
    public constant integer ROUGH_DIRT = 'Kdtr'
    public constant integer FLAT_STONES = 'Kfst'
    public constant integer SMALL_BRICKS = 'Ksmb'
    public constant integer LARGE_BRICKS = 'Klgb'
    public constant integer SQUARE_TILES = 'Ksqt'
    public constant integer DARK_TILES = 'Kdkt'
    public constant integer DIRT_CLIFF = 'cKc1'
    public constant integer DARK_TILES_CLIFF = 'cKc2'
endglobals

endscope

scope DALARANRUINS
// Dalaran Ruins
globals
    public constant integer DIRT = 'Jdrt'
    public constant integer ROUGH_DIRT = 'Jdtr'
    public constant integer BLACK_MARBLE =  'Jblm'
    public constant integer BRICK_TILES = 'Jbtl'
    public constant integer SQUARE_TILES = 'Jsqd'
    public constant integer ROUND_TILES = 'Jrtl'
    public constant integer GRASS = 'Jgsb'
    public constant integer TRIM_GRASS = 'Jhdg'
    public constant integer WHITE_MARBLE = 'Jwmb'
    public constant integer DIRT_CLIFF = 'cJc2'
    public constant integer SQUARE_TILES_CLIFF = 'cJc1'
endglobals

endscope

endlibrary
You can't nest scopes in libraries. :p No big deal, the user could just remove the library/endlibrary keywords. Very neat system, I'm using it at the moment for my map.
 

Azlier

Old World Ghost
Reaction score
461
You can't nest scopes in libraries.
What? Of course you can! You can even nest scopes inside other scopes. But what you can't do is nest libraries.
 
Reaction score
91
> What? Of course you can!
Line X: Scopes with initializers cannot allow nested scopes

> You can even nest scopes inside other scopes.
That I know, however it seems like you can't nest scopes in libraries.
 

Romek

Super Moderator
Reaction score
963
I will if/when I update this.
It's not coded to my standards at the moment anyway.

(See my archive)
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
You leak a rect each time you use GetWorldsBound() you should use a private global rect initialized to GetWorldsBound() instead.

But anyway instead of using this rect you should use bj_mapInitialPlayableArea, because correct me if i'm wrong but you can't change the terrain type outside the playable map area, right ?
I didn't test, but war3 doesn't crash when you try it (probably not, i hope you test your functions :p) ?
Because it crash when you try to change the pathing outside the playable map area, however it isn't the same thing i know.
You will win efficiency, since this rect is always smaller than GetWorldsBound()

EDIT : Oh and about change the terrain locally for a player, i think it's a bad idea it can easily make a desynchronisation (pathing of the terrain type, allow or not flying/ground units and so one)

EDIT 2 :

About the lag issue, can you reduce the number of execute or will it fail if you do something like that :
JASS:
globals
    private integer I = 0
    private constant integer maxIterations = 10
endglobals

function ReplaceTerrainTypeEx takes integer OldTerrain, integer NewTerrain, rect WhichRect returns nothing
        local real MinX = GetRectMinX(WhichRect)
        local real MaxX = GetRectMaxX(WhichRect)
        local real MinY = GetRectMinY(WhichRect)
        local real MaxY = GetRectMaxY(WhichRect)       
        loop
            set I = I+1
            exitwhen MinY > MaxY
                if I == I/maxIterations*maxIterations then
                    call RT1.execute(MinX, MaxX, MinY, OldTerrain, NewTerrain)
                else
                    call RT1(MinX, MaxX, MinY, OldTerrain, NewTerrain) // but it should be a textmacro instead, or directly the code, imho
                endif
            set MinY = MinY + 128
        endloop
endfunction


And plz don't talk about overflow the max value of an integer is pretty huge
 

Romek

Super Moderator
Reaction score
963
I'm aware of all the problems with this code, as well as the desynchronisation problem that could be related to locally changing terrain.
As I said, this is a Navy link on my archive, which means it's not up to scratch. It was back when I made it, but my standards are much higher now.

UAC recently became a black link from a navy link.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
UAC means ?

Also it should be graveyard for the moment so.
What about reduce the number of execute calling ?
Is it possible or will it fail ? I could test it myself ofc, but maybe you have more knowledge about that than me.
 

Romek

Super Moderator
Reaction score
963
It's still approval worthy I think.
It's just not up to scratch.

And, really, no need to comment on the code and such any more.
I know one of the functions is useless, I know it leaks.

> And plz don't talk about overflow the max value of an integer is pretty huge
The op. limit however, isn't.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Hmm you didn't answer my question, i guess i will test it myself :p

Something with a leak that can be easily solved have no place in a submission forum in my mind, but i'm a simple user of this forum anyway, so don't listen me.
 

Romek

Super Moderator
Reaction score
963
> Hmm you didn't answer my question, i guess i will test it myself :p
Here:
"I know one of the functions is useless" - (-1 exec call)
"The op. limit however, isn't." - Can't get any less.

I'll fix the leak in a few minutes as you're obsessing about it.
Though I'd rather fix it all at once. =|
 

Romek

Super Moderator
Reaction score
963
Updated.
This is now a Black Link on my archive.

Fixed the leak, made the Global functions more efficient, and it now starts a completely new thread when called.
I also think it may be a little faster.

Next up for fixing: Panda Roll. :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top