Jump to content

madmax

Community Members
  • Posts

    165
  • Joined

  • Last visited

Everything posted by madmax

  1. Zoot, How were you able to pull your changes into your repo as it was changed in mine, I guess OK, so when I add a <attacked> sound to any unit template, I guess the simplest way to check if it works is to add the unit in Atlas and place a enemy unit in front and run the game for this Atlas map ?
  2. Should be like this : OK, so I ll start adding the attacked sound to other unit templates. What are the units tests which need to be added or run after this change? For the record, from this commit, https://github.com/l...ccefcab23ed206e I was trying to make the following function inline : void CMiniMap::AddPing(entity_id_t entityId) { ... } But I was getting a AddPing undefined reference error. It should be possible to hint to the compiler to make it inline like this : inline void CMiniMap::AddPing(entity_id_t entityId) { ... } I also think this should be inlined : float CMiniMap::GetAngle() Does the compiler automatically do this for us without having to drop it any hints ?
  3. yeah stupid mistake that, wasnt caught on windows as its case insensitive. Should be #include "gui/MiniMap.h" Committing. OK, lets go again.
  4. done : https://github.com/laxmax/0ad/commit/5f22b02625bd8efe8ebe5072419c359aa809b4a1
  5. ok will switch to #include <boost/unordered_map.hpp>
  6. 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.
  7. Ah a git push now...sigh ! ok 2 more to go. Ok all 4 modified files committed : https://github.com/l...54e7060954d5958 Should work now if you update & build.
  8. 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-notification nothing to commit, working directory clean abhi@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.h abhi@ABHI-PC /f/Code/0ad/0ad (attack-notification) $ git commit -m "Just Testing" [attack-notification f482178] Just Testing 1 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.cpp abhi@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 CMin iMap code 1 file changed, 75 insertions(+), 3 deletions(-) abhi@ABHI-PC /f/Code/0ad/0ad (attack-notification) $
  9. 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 !!
  10. 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 ?
  11. 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 ! ?
  12. 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 OOP Or rather I should call CGUIManager::FindObjectByName() which wraps the current CGUI object.
  13. ok, Ping got from E:35 Seems 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); or guiManager->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.
  14. How do I like my code...the lesser the better.

  15. 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 functions scriptInterface.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:0 Wonder 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 from void 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.
  16. 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.
  17. What are the other options, how do I start the game windowed ? ---------- ok discovered the config file. Guess there is no command line option.
  18. OK, yeah I seem to be showing the dot on the minimap square outside the circle. There were some handy commands to start pyrogenesis in windowed mode with a particular map, skipping the starting screen. There was even one for starting 2 AIs against each other. Can anyone point me to that list of useful commands ? --------------- Got one : pyrogenesis -quickstart -autostart="Isthmus" -autostart-ai=1:qbot-wc -autostart-ai=2:qbot-wc ok, to gain control over 1 player, I just leave it out in the command line. pyrogenesis -quickstart -autostart="Isthmus" -autostart-ai=2:qbot-wc What other options are there ? Does -quickstart have sound suppressed ? Also I dont see a directory for aegis-bot in the ai folder. Where is it located. How is the engine finding the code for it ?
  19. ok thanks. So on noticing carefully I see a little red line does show up on the bottom left corner of the minimap, Its not within the circle region of the minimap but I guess for that I just need get the proper co-ordinates.
  20. Ah thanks, that works. Prints inside the game. I guess stdout/stderr is suppressed somehow.
  21. I tried to print a large red blob on the minimap using this : //----------------------------------------- // Don't enable GL_POINT_SMOOTH because it's far too slow // (~70msec/frame on a GF4 rendering a thousand points) glPointSize(6.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(1); MinimapUnitVertex v; v.a = 255; v.x = 10*sx; v.y = 10*sy; v.r = 255; v.g = 100; v.b = 100; vertexArray.push_back(v); std::cout << "Hallo\n"; debug_printf(L"Hello"); 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); } //----------------------------------------- It doesnt work. I am also having a hard time debugging as debug_warn() immediately breaks to the debugger. cout does not work but I would like to be able to print to the console every frame for now(for debugging only). Nor does debug_printf() . Do I need to run pyrogenesis_dbg.exe ? If I run pyrogenesis_dbg.exe it says MSVCRT90D.dll is missing or something.
  22. yes right. ok, now for the rendering code in the minimap, Someone who has worked on it can please confirm my conjecture here : So the units are rendered in this part of the code in CMiniMap::Draw() 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.a = 255; v.x = posX.ToFloat()*sx; v.y = -posZ.ToFloat()*sy; vertexArray.push_back(v); } } } 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 guess something similar needs to be done for rendering blinking dots in the minimap for the attack positions. So I pack all the required pinging locations into a vertexarray inside a large for loop and then send it for rendering via shader->VertexPointer(2, GL_FLOAT, sizeof(MinimapUnitVertex), &vertexArray[0].x); shader->ColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MinimapUnitVertex), &vertexArray[0].r); .... glDrawArrays(GL_POINTS, 0, (GLsizei)vertexArray.size()); in the shader render path ? From what I understand in the code is that the for-loop fetches the minimap component for each entity/thing visible in the 0ad world and then uses the minimap component to fetch the rendering data (colors, position) to be used to display that entity in the minimap.
  23. ok so when execution reaches messages.js , into function handleNotifications() then what we want is to have this in there : else if (notification.type == "attack") { if (notification.player == Engine.GetPlayerID()) Engine.GuiInterfaceCall("PlaySound", { "name":"attacked", "entity": notification.message.target }); Engine.PingMinimap({ "entity": notification.message.target }); } That means PingMinimap() should be declared as a global function in GuiScriptingInit And this function needs to get the position info from the passed entity and blink the correct position in the minimap. Or the position can be retrieved in JS itself and passed to PingMinimap(). Please tell me if I am hopelessly wrong here
  24. So how exactly is zoot already going from the simulation to the gui code. Is messages.js part of gui code ? Not exactly sure what executes in what context here. ------------ oh ok, I guess it is since it is in gui/session So he is going from the simulation/components/AttackDetection.js which is simulation code to the gui code in message.js Thats what you meant ?
  25. Hmm, not sure what you mean. messages.js would call PingMiniMap(x, z) . This function will be implemented in C++. probably in CCmpMinimap.cpp. So to tie the Javascript call to the C++ function, I would need to probably add a line in ICmpMinimap as follows : BEGIN_INTERFACE_WRAPPER(Minimap) DEFINE_INTERFACE_METHOD_2("PingMiniMap", int, ICmpMinimap, PingMiniMap, int, int) END_INTERFACE_WRAPPER(Minimap) -------------- Oh ok, I guess I can add it as a global function too so that the Minimap component does not have to be retrieved each time. I am not sure which approach is followed when. But I guess since there is just 1 minimap, therefore there is no minimap component as such. So it makes sense to register it as a global function.
×
×
  • Create New...