Author Topic: Improved place building cursor  (Read 1582 times)

pziko

  • Guest
Improved place building cursor
« on: 25 February 2008, 17:12:10 »
Every RTS I've ever played shows whether a potential building site is allowed  by making the transparent building red if it can't be built there. In Glest the worker has to walk all the way to the building site before the player is told "Building can't be placed there".

This simple change will make it so that if a building site is illegal (on top of a rock for example) the transparent building will be red.

* Open "renderer.cpp"

* Find the following routine: Renderer::renderMouse3d

* Find the "if(gui->isPlacingBuilding()){" clause

* Replace "color= Vec4f(1.f, 1.f, 1.f, 0.5f);"

with:

Code: [Select]
        if(map->isFreeCells(pos, building->getSize(), fLand)){
 color= Vec4f(1.f, 1.f, 1.f, 0.5f);
} else color= Vec4f(1.f, 0.f, 0.f, 0.5f);



That's it. Note that although this will let the player know if the building is allowed or not, it won't stop him attempting to place a building there like any other RTS would: that's a slightly bigger problem.
« Last Edit: 1 January 1970, 00:00:00 by pziko »

daniel.santos

  • Guest
(No subject)
« Reply #1 on: 26 February 2008, 20:45:17 »
w00t! this bugged me for a while.  I steal code :)
« Last Edit: 1 January 1970, 00:00:00 by daniel.santos »

ttsmj

  • Guest
(No subject)
« Reply #2 on: 26 February 2008, 20:54:55 »
thank you, useful feature indeed!  8)
« Last Edit: 1 January 1970, 00:00:00 by ttsmj »

martiño

  • Behemoth
  • *******
  • Posts: 1,095
    • View Profile
(No subject)
« Reply #3 on: 26 February 2008, 21:24:06 »
I will add that to the our codebase so it is there for next version.
« Last Edit: 1 January 1970, 00:00:00 by martiño »

 

anything