Question : Basic XML Advice

Hello Experts!

I was wondering if i could have some advice. I am creating a basic XML that represents a file that i have made for a project. I have developed an application, its basic, its a form that has different attributes on it, which can be filled out and submitted. Once submitted, it creates SVG Shapes. I am now looking into making a basic XML file to display the different fields involved.

I have been reading on W3Schools about XML etc and i have started to make my XML code for my file. I have attached the code that i have done. I was just wondering if i could get some advice to see that i am going about it the correct way. As you can see there are shapes and within the shapes there are different attributes. The one thing that confuses me is that different shapes have different attributes eg a square does not have a radius. How does this affect my XML file? From examples i have seen each one has the same attributes included e.g a CD Collection Name, Year Released etc. But my shapes depending on which one they are all different?#. Is what i have attached correct or do you guys have any advice on what i could do to change it.
 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
<shape>
  <shapetype>Circle</shapetype>
  <xaxis>50</xaxis>
  <yaxis>50</yaxis>
  <radius>70</radius>
</shape>

<shape>
  <shapetype>Rectangle</shapetype>
  <xaxis>50</xaxis>
  <yaxis>50</yaxis>
  <width>70</width>
  <height>70</height>
</shape>

Answer : Basic XML Advice

Side: You other project has probably implemented SummonGameObject as a static method in the WorldObject class.

GameObject* WorldObject::SummonGameobject(uint32 id, float x, float y, float z, float angle, uint32 despwtime)

This line however gives the impression that it's non-static, but my rough guess is that it should be static because it seems to take GameObject's Id as first parameter GO_ICE_WALL stands for game object ice_wall. This method is the usual Global lookup method that locates register game objects and therefore makes sense to be static, unless ofcourse a worldobject is a composite game object composed of other game objects.

if(GameObject* pGate = m_creature->SummonGameObject(GO_ICE_WALL, 5540.39f, 2086.48f, 731.066f, 1.00057f, 0))

 Maybe you can check with the other project and see how they have done it. BTW, if SummonGameobject can return a GameObject that may not always be WorldGameObject then the return type should be a bit more stricter to avoid further unnessary typecasting and make subsequent code more typesafe. Otherwise it probably makes more sense to put it in GameObject rather than WorldGameObject.

It could be as simple as copying to Worldobject.h/cpp (if those are the names). Otherwise you should try to have your own design as you may see fit. Start by just defining it in Creature, if you need it elsewhere you can move it to the base class and refactor accordingle.

Would have been less of a guess game, had you have posted the source code ...

Random Solutions  
 
programming4us programming4us