madmax Posted April 4, 2013 Report Share Posted April 4, 2013 (edited) What are the other options, how do I start the game windowed ?----------ok discovered the config file. Guess there is no command line option. Edited April 4, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
madmax Posted April 4, 2013 Report Share Posted April 4, 2013 (edited) Ok this is how I am planning to modifiy the unit rendering code in the minimap :PROFILE_START("minimap units");// Don't enable GL_POINT_SMOOTH because it's far too slow// (~70msec/frame on a GF4 rendering a thousand points)glPointSize(3.f);float sx = (float)m_Width / ((m_MapSize - 1) * TERRAIN_TILE_SIZE);float sy = (float)m_Height / ((m_MapSize - 1) * TERRAIN_TILE_SIZE);CSimulation2::InterfaceList ents = sim->GetEntitiesWithInterface(IID_Minimap);std::vector<MinimapUnitVertex> vertexArray;vertexArray.reserve(ents.size());for (CSimulation2::InterfaceList::const_iterator it = ents.begin(); it != ents.end(); ++it){ MinimapUnitVertex v; ICmpMinimap* cmpMinimap = static_cast<ICmpMinimap*>(it->second); entity_pos_t posX, posZ; if (cmpMinimap->GetRenderData(v.r, v.g, v.b, posX, posZ)) { ICmpRangeManager::ELosVisibility vis = cmpRangeManager->GetLosVisibility(it->first, g_Game->GetPlayerID()); if (vis != ICmpRangeManager::VIS_HIDDEN) { v.x = posX.ToFloat()*sx; v.y = -posZ.ToFloat()*sy; // try to find the entity id in it->first in the hashmap of unit ids to ping and set pingUnit to true if found if ( pingUnit && m_Dim > 50) { v.a = 255; v.r = 255; v.g = 100; v.b = 100; } vertexArray.push_back(v); } }}m_Dim = (m_Dim + 1) > 100 ? 0 : (m_Dim + 1);if (!vertexArray.empty()){ glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); if (g_Renderer.GetRenderPath() == CRenderer::RP_SHADER) { shader->VertexPointer(2, GL_FLOAT, sizeof(MinimapUnitVertex), &vertexArray[0].x); shader->ColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MinimapUnitVertex), &vertexArray[0].r); } else { glVertexPointer(2, GL_FLOAT, sizeof(MinimapUnitVertex), &vertexArray[0].x); glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MinimapUnitVertex), &vertexArray[0].r); } glDrawArrays(GL_POINTS, 0, (GLsizei)vertexArray.size()); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);}PROFILE_END("minimap units");I ll m_Dim a member of class Minimap. Figuring out right now how to get the attacked entities across from zoot's JS code. Edited April 4, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
madmax Posted April 4, 2013 Report Share Posted April 4, 2013 (edited) How can I get the current turn number of the sim in C++ ?g_Game->GetTurnManager() or something similar I guess.I need the turn number to switch off attacked units being pinged after say 100 turns. That way units that are under attack are not pinged forever.---------------------ok so I did this change today in messages.js :function handleNotifications(){..........if (notification.player == Engine.GetPlayerID()) { Engine.GuiInterfaceCall("PlaySound", { "name":"attacked", "entity": notification.message.target }); Engine.PingMinimap({ "entity": notification.message.target }); }.....}Also in C++, in ScriptedFunctions.cpp I added to GuiScriptingInit() the following line...// Minimap functionsscriptInterface.RegisterFunction<void, entity_id_t, &PingMinimap>("PingMinimap");....Then above GuiScriptingInit() added :/*** Ping the minimap at the location of the passed entity to indicate something* (currently an attack)* @param entityid unit id to ping*/void PingMinimap(void* UNUSED(cbdata), entity_id_t entityid){g_Console->InsertMessage(L"Ping received from %d", entityid);LOGWARNING(L"Ping got from E:%d", entityid);}But I get a Javascript warning in the log :WARNING: JavaScript warning: gui/session/messages.js line 86 Script value conversion check failed: JSVAL_IS_NUMBER(v) (got type object)WARNING: Ping got from E:0Wonder why this error is coming. I dont think the entity id would be 0 if this warning can be fixed.Also how do I access the minimap fromvoid PingMinimap(void* UNUSED(cbdata), entity_id_t entityid).This is to add the pinged entity to some kind of list/map so while rendering I can blink it. Edited April 4, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 (edited) That error is because you are passing an object from JS:Engine.PingMinimap({ "entity": notification.message.target });The stuff in curly braces is an object literal. You should probably just pass the entity ID directly:Engine.PingMinimap(notification.message.target); Edited April 4, 2013 by zoot Quote Link to comment Share on other sites More sharing options...
madmax Posted April 4, 2013 Report Share Posted April 4, 2013 (edited) ok, Ping got from E:35Seems good. Now to access the minimap from the function in ScriptedFunctions.Hmm most functions there seem to use something like :g_Game->GetWorld()->GetTerrain()->GetHeightMipmap().DumpToDisk(filename);orguiManager->GetScriptInterface().GetContext()or static cast some passed cbdata :CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);I ll check the functions in for guiManager since ps/Game.h doesnt have any minimap, so apparently the minimap object is not part of the game. Probably only the gui. Edited April 4, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 The minimap UI 'type' is initialized here: https://github.com/0ad/0ad/blob/master/source/gui/CGUI.cpp#L442 Quote Link to comment Share on other sites More sharing options...
madmax Posted April 4, 2013 Report Share Posted April 4, 2013 (edited) Yes, and calling CGUI::FindObjectByName("minimap") should return a IGUIObject* which I can static cast to CMiniMap* and access a function there.I guess static casts should be fine, dynamic_casts are supposed to be bad in OOPOr rather I should call CGUIManager::FindObjectByName() which wraps the current CGUI object. Edited April 4, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 The actual in-game minimap is instantiated from XML: https://github.com/0ad/0ad/blob/master/binaries/data/mods/public/gui/session/session.xml#L744 Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 Yes, and calling CGUI::FindObjectByName("minimap") should return a IGUIObject* which I can static cast to CMiniMap* and access a function there.Sounds right Quote Link to comment Share on other sites More sharing options...
madmax Posted April 4, 2013 Report Share Posted April 4, 2013 (edited) ok, yeah so the circle and square are sprites stretched across the screen for drawing the minimap.<action on="WorldClick">handleMinimapEvent(arguments[0]);</action>Responds to clicks anywhere on the screen and I guess it will check if the click was inside it. Whats the library being used which can construct the GUI from XML ! ? Edited April 4, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 There is no library, to my knowledge. The XML parsing and rendering is done by the engine itself. Quote Link to comment Share on other sites More sharing options...
madmax Posted April 4, 2013 Report Share Posted April 4, 2013 (edited) ah ok So I am planning to make it such that entities will be pinged for a certain number of turns and then removed from the list of entities to be pinged. Unless its added again which means it was attacked again. This would keep the minimap clean.Maybe I should also stop blinking the attacked entity a few turns before its removed and the entity is rendered with normal colors again.------------ok got a basic implementation going : The size of the blinking dot is the same size as the unit being attacked. Maybe I should make it a bit bigger ? Also the pinging occurs only as long as the entity is alive. Also since its just one unit which is reported, the size of the dot is quite small. If neighbouring units were also reported as being attacked then we would get a better blinking blob !I need to place a global constant called MAX_PING_TURNS after which the entity will no longer be pinged. Is there some header where all global constants are placed or can I just plop it into Minimap.h ? Maybe it can be made a configurable parameter later on for players who want the attack notifications to be around longer ? Or maybe it does not need to be changeable ? Edited April 4, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 (edited) Very cool Maybe make the blinking slightly faster / higher frequency.(Don't know the answer to your question, unfortunately.) Edited April 4, 2013 by zoot Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 (edited) Also the pinging occurs only as long as the entity is alive.There is a small problem with this; if we have a clump of units, and the one that was 'pinged' dies, the blinking will presumably stop even though the skirmish continues for the other units. I'm not quite sure how to address that? Edited April 4, 2013 by zoot Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 It may turn out that we need to move much of the attack detection / suppression logic into messages.js, so we can treat sound and ping differently from each other. Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 If you are still working from the clone from GitHub, is there chance you can push your changes so far back to your repo on GitHub: https://help.github.com/articles/pushing-to-a-remoteThen I can try and see if I can move the attack 'suppression' logic into messages.js in some way. Quote Link to comment Share on other sites More sharing options...
madmax Posted April 4, 2013 Report Share Posted April 4, 2013 Yes, I will do that, just adding the ping timeout thing where the pinging stops after some time. Do I make a new branch and then modify the files ? Or I ll put in the changes in attack-notification branch and commit. Can you tell me a few quick commands to commit ....lazy !! Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 (edited) You can just use the existing 'attack-notification' branch, since the branch in your repo is seperate from the one in mine.You need to "git add" all the files you have modified and/or created. Then "git commit" or:git commit -m "Some helpful commit message here."Once you've committed to your local repo, you should be able to push as described in the link above. Edited April 4, 2013 by zoot Quote Link to comment Share on other sites More sharing options...
alpha123 Posted April 4, 2013 Report Share Posted April 4, 2013 The size of the blinking dot is the same size as the unit being attacked. Maybe I should make it a bit bigger ?Wow, that's very cool. I would probably make it a bit bigger and blink faster. But you're definitely on the right track. Also the pinging occurs only as long as the entity is alive.That seems like a fairly bit issue, but I have no idea how to solve it. Also since its just one unit which is reported, the size of the dot is quite small. If neighbouring units were also reported as being attacked then we would get a better blinking blob !Yes, it probably should scale to the size of the attack, but oddly enough I don't think that's all that critical, although it would be very nice to have. Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 That seems like a fairly bit issue, but I have no idea how to solve it. Shouldn't be too big, we just reorganize things a bit. Quote Link to comment Share on other sites More sharing options...
madmax Posted April 4, 2013 Report Share Posted April 4, 2013 (edited) Ok this is what I did, but I still dont see my commit in github I have committed just 2 files, 2 more to do but the commit should appear.abhi@ABHI-PC /f/Code/0ad/0ad (attack-notification)$ git commit -m "Just Testing"# On branch attack-notificationnothing to commit, working directory cleanabhi@ABHI-PC /f/Code/0ad/0ad (attack-notification)$ git commit -m "Just Testing"# On branch attack-notification# Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: source/gui/MiniMap.h#no changes added to commit (use "git add" and/or "git commit -a")abhi@ABHI-PC /f/Code/0ad/0ad (attack-notification)$ git add source/gui/MiniMap.habhi@ABHI-PC /f/Code/0ad/0ad (attack-notification)$ git commit -m "Just Testing"[attack-notification f482178] Just Testing1 file changed, 33 insertions(+), 1 deletion(-)abhi@ABHI-PC /f/Code/0ad/0ad (attack-notification)$ git commit -m "Just Testing"# On branch attack-notification# Your branch is ahead of 'origin/attack-notification' by 1 commit.## Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: source/gui/MiniMap.cpp#no changes added to commit (use "git add" and/or "git commit -a")abhi@ABHI-PC /f/Code/0ad/0ad (attack-notification)$ git add source/gui/MiniMap.cppabhi@ABHI-PC /f/Code/0ad/0ad (attack-notification)$ git commit -m "Commit the ping minimap function added to the CMiniMap code"[attack-notification 768cf71] Commit the ping minimap function added to the CMiniMap code1 file changed, 75 insertions(+), 3 deletions(-)abhi@ABHI-PC /f/Code/0ad/0ad (attack-notification)$ Edited April 4, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
madmax Posted April 4, 2013 Report Share Posted April 4, 2013 (edited) Ah a git push now...sigh !ok 2 more to go.Ok all 4 modified files committed : https://github.com/l...54e7060954d5958Should work now if you update & build. Edited April 4, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 Great. I get errors when building, though:$ make -j9==== Building mocks_real (release) ======== Building network (release) ======== Building simulation2 (release) ======== Building scriptinterface (release) ======== Building engine (release) ======== Building graphics (release) ======== Building gui (release) ======== Building mongoose (release) ======== Building atlas (release) ======== Building lowlevel (release) ======== Building mocks_test (release) ======== Building AtlasObject (release) ======== Building AtlasScript (release) ======== Building Collada (release) ======== Building AtlasUI (release) ====MiniMap.cppCGUI.cppScriptFunctions.cpp==== Building ActorEditor (release) ====In file included from /usr/include/c++/4.7/unordered_map:35:0, from ../../../source/gui/MiniMap.h:22, from ../../../source/gui/MiniMap.cpp:22:/usr/include/c++/4.7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.In file included from /usr/include/c++/4.7/unordered_map:35:0, from ../../../source/gui/MiniMap.h:22, from ../../../source/gui/CGUI.cpp:41:/usr/include/c++/4.7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.../../../source/gui/scripting/ScriptFunctions.cpp:26:25: fatal error: gui/Minimap.h: No such file or directorycompilation terminated.In file included from ../../../source/gui/CGUI.cpp:41:0:../../../source/gui/MiniMap.h:34:9: error: ‘unordered_map’ in namespace ‘std’ does not name a type../../../source/gui/MiniMap.h:111:2: error: ‘map_Ping’ does not name a typeIn file included from ../../../source/gui/MiniMap.cpp:22:0:../../../source/gui/MiniMap.h:34:9: error: ‘unordered_map’ in namespace ‘std’ does not name a type../../../source/gui/MiniMap.h:111:2: error: ‘map_Ping’ does not name a type../../../source/gui/MiniMap.cpp: In member function ‘void CMiniMap::AddPing(entity_id_t)’:../../../source/gui/MiniMap.cpp:257:2: error: ‘m_EntitiesToPing’ was not declared in this scope../../../source/gui/MiniMap.cpp: In member function ‘virtual void CMiniMap::Draw()’:../../../source/gui/MiniMap.cpp:488:5: error: ‘map_Ping’ has not been declared../../../source/gui/MiniMap.cpp:488:24: error: expected ‘;’ before ‘pingIter’../../../source/gui/MiniMap.cpp:490:10: error: ‘pingIter’ was not declared in this scope../../../source/gui/MiniMap.cpp:490:22: error: ‘m_EntitiesToPing’ was not declared in this scope../../../source/gui/MiniMap.cpp:524:5: error: ‘map_Ping’ has not been declared../../../source/gui/MiniMap.cpp:524:24: error: expected ‘;’ before ‘pingIter’../../../source/gui/MiniMap.cpp:526:10: error: ‘pingIter’ was not declared in this scope../../../source/gui/MiniMap.cpp:526:22: error: ‘m_EntitiesToPing’ was not declared in this scope../../../source/gui/MiniMap.cpp:544:32: error: ‘m_EntitiesToPing’ was not declared in this scope../../../source/gui/MiniMap.cpp: In member function ‘virtual void CMiniMap::Destroy()’:../../../source/gui/MiniMap.cpp:704:2: error: ‘m_EntitiesToPing’ was not declared in this scopemake[1]: *** [obj/gui_Release/ScriptFunctions.o] Error 1make[1]: *** Waiting for unfinished jobs....make[1]: *** [obj/gui_Release/MiniMap.o] Error 1make[1]: *** [obj/gui_Release/CGUI.o] Error 1make: *** [gui] Error 2 Quote Link to comment Share on other sites More sharing options...
madmax Posted April 4, 2013 Report Share Posted April 4, 2013 (edited) ok, this is in linux. Strange I thought that std::unordered_map would work without any issues.I compiled on Windows.Looking into it. If it says unordered_map is in C++ 2011, then I ll change it to std::map even though std::unordered_map is faster. Edited April 4, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 4, 2013 Author Report Share Posted April 4, 2013 Yeah, I guess ISO C++ 2011 only has experimental support in GCC. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.