HomePortalFAQSearchMemberlistUsergroupsRegisterLog in
Meet the new KITO admins & hear their plans here.
You can use google search to find threads and posts here now. Example

Share | 
 

 .character file description

Go down 
AuthorMessage
RedEye
Retired
avatar

Game username : -redeye-
Server : KITO
Male Posts : 2578
Join date : 2011-07-24
Age : 30

PostSubject: .character file description   Mon Feb 13, 2012 3:16 pm

In replacing large potions of code have I now stumbled upon the need to actually really describe what the hell these files are about since reading them is a pain.
This is not meant to be a easy read just yet.
Code:
      const vector<String> tString = StringUtil::split(data,"|\n",2);
      //Loaded successfully
      if(tString.size()>0)
      {
         const vector<String> tParam = StringUtil::split(tString[0],";");
         if(tParam.size()>=7 && tParam.size()<=12)
         {
            setName(tParam[0]);

            float tScale = 0;
            bool tHasNewMeshes = false;
            if(tParam.size()==8)tScale = StringConverter::parseReal(tParam[7]);
            else if(tParam.size()==9)tScale = StringConverter::parseReal(tParam[8]);
            else if(tParam.size()==12)tScale = StringConverter::parseReal(tParam[11]);
            if(tParam.size()>8 || tParam.size()==8&&tScale<0.0000005)tHasNewMeshes = true;

            mUnit->createUnit(1,mSceneMgr,tParam[1],tParam[2],tParam[3],tParam[4],tParam[5],tParam[6],(tHasNewMeshes?tParam[7]:mDef->tuftMesh[0]));
            
            if(tScale>0.0000005 && tScale<10)mUnit->getObjectNode()->setScale(tScale,tScale,tScale);
            if(tParam[6]=="CustomMat")
            {
               if(tHasNewMeshes)mUnit->setMarkings(StringConverter::parseInt(tParam[8]),StringConverter::parseInt(tParam[9]),StringConverter::parseInt(tParam[10]));
               if(tString.size()==2)mUnit->setColours(tString[1]);
            }
            positionUnitForSelect();

            return;
         }
      }
      //no data
      setName("");

The file is read as:
Code:
inFile.getline(tData,512);
inFile.getline(tAdminToken,16);

tData
The line is first split in 2 parts
Code:
split(data,"|\n",2)

Part 1 (tString[0])
This is between 8 or 13 params.

1 params
Code:
setName(tParam[0]);

2-8 params
Code:
mUnit->createUnit(1,mSceneMgr,tParam[1],tParam[2],tParam[3],tParam[4],tParam[5],tParam[6],(tHasNewMeshes?tParam[7]:mDef->tuftMesh[0]));

More than 8 params
In the case there's more than 8 params
Code:
mUnit->setMarkings(StringConverter::parseInt(tParam[8]),StringConverter::parseInt(tParam[9]),StringConverter::parseInt(tParam[10]));

Scaling when 8, 9 or 12 params
Code:
if(tParam.size()==8)tScale = StringConverter::parseReal(tParam[7]);
else if(tParam.size()==9)tScale = StringConverter::parseReal(tParam[8]);
else if(tParam.size()==12)tScale = StringConverter::parseReal(tParam[11]);


Part 2 (tString[1])
Sets the colors:
Code:
mUnit->setColours(tString[1])
Back to top Go down
RedEye
Retired
avatar

Game username : -redeye-
Server : KITO
Male Posts : 2578
Join date : 2011-07-24
Age : 30

PostSubject: Re: .character file description   Mon Feb 13, 2012 3:50 pm

Code:
tString: const vector<String> tString = StringUtil::split(data,"|\n",2);
tParam: const vector<String> tParam = StringUtil::split(tString[0],";");
tParam[0]: Character Name
tParam[1]: Body Mesh (string) -- ("Body1", tParam[1]+".mesh");
tParam[2]: Head Mesh (string) -- ("Head1", tParam[2]+".mesh");
tParam[3]: Mane Mesh (string) -- if(tParam[3]!="Maneless") ("Mane1", tParam[3]+".mesh");
tParam[4]: Tail Mesh (string) -- ("Tail1", tParam[4]+".mesh");
tParam[5]: Wing Mesh (string) -- if(tParam[5]!="Wingless") ("Wing1", tParam[5]+".mesh");
tParam[6]: Material (string), preset -- setMaterial(tParam[6]); ("CustomMat" for non-preset)
tParam[7]: Tuft Mesh (string) -- if(tParam[7]!="Tuftless") ("Tuft1", tParam[7]+".mesh");

if(tHasNewMeshes) (if its preset)
tParam[8]: bodyID (unsigned char)
tParam[9]: headID (unsigned char)
tParam[10]: tailID (unsigned char)
tParam[7,8,11]: Character Scale (7, 8 or 11 depends on other data)

if(tString.size()==2)
tString[1]: mUnit->setColours(tString[1]);
Back to top Go down
RedEye
Retired
avatar

Game username : -redeye-
Server : KITO
Male Posts : 2578
Join date : 2011-07-24
Age : 30

PostSubject: Re: .character file description   Mon Feb 13, 2012 4:34 pm

setColours is a string that is split with ";".

Code:
   void setColours(const String &colourString)
   {
      std::vector<String> tParam = StringUtil::split(colourString,";",11);
      if(tParam.size()==10 || tParam.size()==11)
      {
         setColours(StringConverter::parseColourValue(tParam[0]),
            StringConverter::parseColourValue(tParam[1]),
            StringConverter::parseColourValue(tParam[2]),
            StringConverter::parseColourValue(tParam[3]),
            StringConverter::parseColourValue(tParam[4]),
            StringConverter::parseColourValue(tParam[5]),
            StringConverter::parseColourValue(tParam[6]),
            StringConverter::parseColourValue(tParam[7]),
            StringConverter::parseColourValue(tParam[8]),
            StringConverter::parseColourValue(tParam[9]),
            (tParam.size()==11?StringConverter::parseColourValue(tParam[10]):ColourValue(0,0,0)));
      }
   }

Code:
StringConverter::parseColourValue("r g b a")

SetColours:
tParam[0]: Pelt
tParam[1]: Underfur
tParam[2]: Mane
tParam[3]: Nose
tParam[4]: Eye Top
tParam[5]: Eye Bottom
tParam[6]: Ears
tParam[7]: Tailtip
tParam[8]: Eyes
tParam[9]: Wing
tParam[10]: Markings

All of these when reversing:
Code:
   const String vect4ToString(Vector4 vect, const unsigned short &tDeci)
   {
      unsigned short deci = 1;
      for(int i=0;i<tDeci;i++)deci *= 10;
      vect.x *= deci; vect.x = (int)vect.x; vect.x /= deci;
      vect.y *= deci; vect.y = (int)vect.y; vect.y /= deci;
      vect.z *= deci; vect.z = (int)vect.z; vect.z /= deci;
      vect.w *= deci; vect.w = (int)vect.w; vect.w /= deci;

      return (StringConverter::toString(vect.x) + " " +
            StringConverter::toString(vect.y) + " " +
            StringConverter::toString(vect.z) + " " +
            StringConverter::toString(vect.w));
   }


________________________________
Retired
Back to top Go down
Sponsored content




PostSubject: Re: .character file description   

Back to top Go down
 
.character file description
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Keeping I.T. Open :: START HERE :: KITO's IT Source Code :: Guides & FAQs-
Jump to: