Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#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)

template_manager.patch (39.8 KB) - added by Itms 5 years ago.
rms_interface.patch (4.2 KB) - added by Itms 5 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 Changed 7 years ago by FeXoR

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.

Last edited 7 years ago by FeXoR (previous) (diff)

comment:2 Changed 7 years ago by FeXoR

Keywords: RMGEN RMS added
Summary: Add access to entity templates for RMSAdd access to entity templates for RMGEN/RMS

comment:3 Changed 7 years ago by wraitii

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 Changed 6 years ago by FeXoR

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 Changed 6 years ago by zoot

Assuming what you need here is a function, what arguments should it take and what should it return?

comment:6 Changed 6 years ago by FeXoR

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

Last edited 6 years ago by FeXoR (previous) (diff)

comment:7 Changed 6 years ago by FeXoR

Related tickets:

#1901 #2192

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):

#1565 #1449

Last edited 6 years ago by FeXoR (previous) (diff)

comment:8 Changed 5 years ago by Itms

Keywords: review patch added; RMGEN RMS removed
Milestone: BacklogAlpha 17
Owner: set to Itms
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 Changed 5 years ago by Itms

I tweaked the TemplateManager? and added some functions to RMS.

I will also see if I can separate XML validation from simulation (actually validation is performed via the ComponentManager?)

Last edited 5 years ago by Itms (previous) (diff)

comment:10 Changed 5 years ago by sanderd17

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 Changed 5 years ago by Itms

I updated some bits of the code to take in account comments by sanderd17 and leper.

comment:12 Changed 5 years ago by Itms

"Rebased" template_manager with r15289.

Also corrected a string formatting in rms_interface, pointed out by leper on IRC.

Changed 5 years ago by Itms

Attachment: template_manager.patch added

Changed 5 years ago by Itms

Attachment: rms_interface.patch added

comment:13 Changed 5 years ago by sanderd17

Resolution: fixed
Status: newclosed

In 15306:

Give RMS access to the simulation templates. Fixes #1589. Patch by Itms.

comment:14 Changed 5 years ago by sanderd17

Keywords: review removed
Note: See TracTickets for help on using tickets.