FontHandler - Page 2

FontHandler

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

1.

Code: Select all

/home/mingw_cross_env-mingw_gcc440/usr/bin/../lib/gcc/i386-mingw32msvc/4.4.0/include/c++/bits/stl_tree.h:986 [CGroundBlockingObjectMap::RemoveGroundBlockingObject(CSolidObject*)]
rts/Sim/Objects/SolidObject.cpp:84 [CSolidObject::UnBlock()]
rts/Sim/Objects/SolidObject.cpp:95 [CSolidObject::Block()]
rts/Sim/MoveTypes/GroundMoveType.cpp:349 [CGroundMoveType::Update()]
rts/Sim/Units/Unit.cpp:531 [CUnit::Update()]
/home/mingw_cross_env-mingw_gcc440/usr/bin/../lib/gcc/i386-mingw32msvc/4.4.0/include/c++/bits/stl_list.h:143 [CUnitHandler::Update()]
rts/Game/Game.cpp:3173 [CGame::SimFrame()]
rts/Game/Game.cpp:3477 [CGame::ClientReadNet()]
rts/Game/Game.cpp:2520 [CGame::Update()]
rts/System/SpringApp.cpp:839 [SpringApp::Update()]
rts/System/SpringApp.cpp:1087 [SpringApp::Run(int, char**)]
rts/System/Main.cpp:63 [Run(int, char**)]
rts/System/Main.cpp:137 [WinMain@16]
crash has nothing to do with the fonthandler ...

2. use inlined colorcodes:

Code: Select all

font:Print("\255\255\255\001" .. "foo" .. "\255\001\255\255" .. "bar", x,y)  --// the string concations are redundant, the should just emphasize what's going on
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

It didn't crash on startup, until I used your code. Spring doesn't crash until the game starts and it attempts to start the UI.

I've just reverted using your code, and now it's stable and working again.

Here's the Lua- I went for a quickie modification of the Chickens UI, which I was hoping to make easier to edit for more custom single-player games down the road. I thought that would be a reasonable first test, since it's using fontHandler and I've wanted an alternative that worked better for some time now.

If I'm just using it incorrectly, that's fine, but I'd like to know why it's crashing Spring.
Attachments
gui_chicken.txt
(14.1 KiB) Downloaded 123 times
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

panelFont:Print(techLevel, PanelRow(1))
panelFont:Print(gameInfo.unitCounts, PanelRow(2))
panelFont:Print(gameInfo.unitKills, PanelRow(3))
panelFont:Print("Spawners: "..gameInfo.roostCount, PanelRow(4))
panelFont:Print("Spawner Kills: "..gameInfo.roostKills, PanelRow(5))
...
waveFont:Print(message, viewSizeX/2, waveY-WaveRow(i),"c")
font:Print( text, x, y, size, options ) -> nil
no comment ...
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

PanelRow?

local function PanelRow(n)
return panelMarginX, h-panelMarginY-(n-1)*(panelFontSize+panelSpacingY)
end

And I see your point on waveFont, but that still should not result in a crash.
Last edited by Argh on 26 Jul 2009, 07:32, edited 1 time in total.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

learn to count
k, PanelRow shouldn't be a prob if it returns 2 numbers.
and as i have said it doesn't crash in the fonthandler
Last edited by jK on 26 Jul 2009, 07:37, edited 1 time in total.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

What? Is the size or options not... optional? PanelRow returns two variables.

And none of that explains why it crashes Spring, anyhow.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

luaL_error(L,"Incorrect arguments to font:Print(msg, x, y [,size [ \"options\"] ]");

size is optional, but it doesn't mean you can access the options param w/o it ...
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

Yeah, I fixed that.

However... written like this, it ran briefly then caused Spring to crash:

local myX, myY = PanelRow(1)
panelFont:Print(techLevel, myX, myY)
myX, myY = PanelRow(2)
panelFont:Print(gameInfo.unitCounts, myX, myY)
myX, myY = PanelRow(3)
panelFont:Print(gameInfo.unitKills, myX, myY)
myX, myY = PanelRow(4)
panelFont:Print("Spawners: "..gameInfo.roostCount, myX, myY)
myX, myY = PanelRow(5)
panelFont:Print("Spawner Kills: "..gameInfo.roostKills, myX, myY)

I'll take all of that out, and see if the waveFont works now.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

No dice.

I think it's crashing if it hits any values that are nil. I'll try an experiment.

<tests>

Nope. Still crashes after a second or so. Code is attached. I fixed the display-list stuff, and commented out everything but one use of your code. The panel shows up, and it briefly flashes "just testing" several times before it crashes.
Attachments
gui_chicken.lua
(14.53 KiB) Downloaded 122 times
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

use SetTextColor({r,b,g[,a]}) for now seems gcc has problems of the type:
float4* color = new float4(); *color[3] = (double)1.0;
(or me didn't know that gcc would treat it as an array of float4s -_-)

and the flickering erm you know what a DisplayList is?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

use SetTextColor({r,b,g[,a]}) for now seems gcc has problems of the type: float4* color = new float4(); *color[3] = (double)1.0;
Lemme try that, and see if it resolves the crashing issue.
and the flickering erm you know what a DisplayList is?
Yes. But why's that relevant? I thought this was like gl.Text- just stick it into your main draw loop, and it works. Not so?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

Commenting out:

panelFont:SetTextColor(1.0,1.0,1.0,1.0)

Results in no flashing, and Spring no longer crashes.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

Argh wrote:
and the flickering erm you know what a DisplayList is?
Yes. But why's that relevant? I thought this was like gl.Text- just stick it into your main draw loop, and it works. Not so?

Code: Select all

local function CreatePanelDisplayList()
...
	panelFont:Print("Your Score: ", 88, h-170)
...
end


local function Draw()
...
  if (updatePanel) then
    if (guiPanel) then gl.DeleteList(guiPanel); guiPanel=nil end
    CreatePanelDisplayList() <<<<<<<<<<<<<<< you removed here something very very important
    updatePanel = false
  end

  if (guiPanel) then
    gl.CallList(guiPanel)
  end
...
end
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

I have the offsets fixed, the text is now displaying where it should, lol. That wasn't terribly important, with the engine crashing.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

that's not what i meant
(also the comment is not in CreatePanelDisplayList)

tip:

Code: Select all

  if (guiPanel) then
    gl.CallList(guiPanel)
  end
is never true
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

All fixed up. Final script attached. I'll work on doing some slightly-fancier stuff with this when I've had some sleep.
Attachments
gui_chicken.lua
(14.27 KiB) Downloaded 138 times
Post Reply

Return to “Engine”