#1589 closed enhancement (fixed)
[PATCH] Add access to entity templates for RMGEN/RMS
Reported by: | FeXoR | Owned by: | Itms |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 17 |
Component: | Core engine | Keywords: | patch |
Cc: | Patch: |
Description
Untill now there is no way to access the entity templates data from RMGEN area of code. Some things could be done much more tidy if there where (like placing walls, avoid placing chickens inside the civil centres obstruction etc.). I have really no idea how to do this so I open a ticket for it.
Attachments (2)
Change History (16)
comment:2 by , 12 years ago
Keywords: | RMGEN RMS added |
---|---|
Summary: | Add access to entity templates for RMS → Add access to entity templates for RMGEN/RMS |
comment:3 by , 11 years ago
I'm not having enough time to work on that, but I think the code could be added to MapGenerator.cpp (probably in "Run()"). Interesting code in CcmpAImanager is "LoadEntityTemplates()" and "StartLoadEntityTemplates()" which calls the template manager to get the templates. Note that the AI doesn't get actor templates, while the map generator probably should.
The only trouble to actually implementing this is that the map generator is not part of the simulation code, so calling the 'FindAllTemplates' function (from CcmpTemplateManager) is not possible, which might require rewriting the code.
comment:4 by , 11 years ago
The units/entities/actors in random maps are stored in g_map.terrainObjects and g_map.objects. So finding what units/entities/actors are in the map should not be a problem but accessing their template by there name is. So a function similar to "FindAllTemplates"
can easily be added to the javascript code. The main problem is to access the templates values for e.g. footprint.
I guess that is what you mean.
comment:5 by , 11 years ago
Assuming what you need here is a function, what arguments should it take and what should it return?
comment:6 by , 11 years ago
Aswer to the last comment: http://www.wildfiregames.com/forum/index.php?showtopic=16242&st=120#entry262357
Link to the forum requesting suggestions how to do this properly: http://www.wildfiregames.com/forum/index.php?showtopic=17052
comment:7 by , 10 years ago
Related tickets:
Less related tickets that can be fixed with this as well (Mainly entities obstructed by terrain) though some might be fixed without it (e.g. by enlarging the players space at start locations):
comment:8 by , 10 years ago
Keywords: | review patch added; RMGEN RMS removed |
---|---|
Milestone: | Backlog → Alpha 17 |
Owner: | set to |
Summary: | Add access to entity templates for RMGEN/RMS → [PATCH] Add access to entity templates for RMGEN/RMS |
Ok, I created a patch to implement this.
Basically, I split CCmpTemplateManager's logic in two parts:
- loading and parsing of xml template files is handled by a TemplateLoader class
- handling of entities and simulation-dependent systems remain in CCmpTemplateManager
Then, it is possible for rms to have a dedicated TemplateLoader object capable of accessing all game templates.
I provide two patch files:
- The first one (template_loader) is just the implementation of TemplateLoader. I'd need a developer review of this part, to have feedback about my code and possible performance/memory issues. I am also wondering whether I should add tests for my new files? If I should, which ones?
- The second one (rms_interface) depends on the first one to work. I just created a FindAllTemplates function, usable in the js rmgen code, but my system allows more possibilities, so what you (rmgen users, FeXoR, Spahbod) could need? From your input I can develop this part to suit your needs!
Thanks :)
comment:9 by , 10 years ago
I tweaked the TemplateManager and added some functions to RMS.
comment:10 by , 10 years ago
One thing: you can't print std::string in a LOGERROR as %s. You first need to convert it to by using string.c_str()
Apart from that, it looks good to me.
comment:11 by , 10 years ago
I updated some bits of the code to take in account comments by sanderd17 and leper.
comment:12 by , 10 years ago
"Rebased" template_manager with r15289.
Also corrected a string formatting in rms_interface, pointed out by leper on IRC.
by , 10 years ago
Attachment: | template_manager.patch added |
---|
by , 10 years ago
Attachment: | rms_interface.patch added |
---|
comment:14 by , 10 years ago
Keywords: | review removed |
---|
After the templates data can be accessed (especially obstruction/footprint/bounding box) by RMGEN I'd try to better the wall_builder.js entity placement so a ticket might be opened afterwards (or right now if one sees fit). To realy do this well in addition an entity obstruction map whould have to be added to RMGEN as well including impassible terrain and areas obstructed by other entities.