name = pVehicleData->pCarInfo[pEntrantData->pEntrants.chassis].name;
for(j = 0; j < gNumberOfChassis; j++)
{
if (name == gStringTable[ST_Chassis+j])
{
goto donechassis;
}
}
gStringTable[ST_Chassis+gNumberOfChassis] = name;
Chassis2ChassisIdMap[gNumberOfChassis] = pEntrantData->pEntrants.chassis;
gNumberOfChassis++;
donechassis:
name = pVehicleData->pEngineInfo[pEntrantData->pEntrants.engine].name;
for(j = 0; j < gNumberOfEngines; j++)
{
if (name == gStringTable[ST_Engines+j])
{
goto doneengine;
}
}
gStringTable[ST_Engines+gNumberOfEngines] = name;
Engine2EngineIdMap[gNumberOfEngines] = pEntrantData->pEntrants.engine;
gNumberOfEngines++;
doneengine:
name = pVehicleData->pTyreInfo[pEntrantData->pEntrants.tyre].name;
for(j = 0; j < gNumberOfTyres; j++)
{
if (name == gStringTable[ST_Tyres+j])
{
goto donetyre;
}
}
gStringTable[ST_Tyres+gNumberOfTyres] = name;
Tyre2TyreIdMap[gNumberOfTyres] = pEntrantData->pEntrants.tyre;
gNumberOfTyres++;
donetyre:
cut large code to smaller code
I am using C and windows, i have the following code , this is just a snipit there is loads more all in the same format, can i make a function to handle all this
could i not do something like
but i get an error for
gStringTable[sID+iSize] = cName;
error = error C2107: illegal index, indirection not allowed
[Edited by - Prog101 on September 19, 2007 5:38:18 AM]
void SetArrayMaps(const char* cName, int iNum, int *iSize, _StringID sID, int* iArray){ int i; for(i = 0; i < iSize; i++) { if (cName == gStringTable[sID+i]) { return; } } gStringTable[sID+iSize] = cName; iArray[iSize] = iNum; iSize++;}
but i get an error for
gStringTable[sID+iSize] = cName;
error = error C2107: illegal index, indirection not allowed
[Edited by - Prog101 on September 19, 2007 5:38:18 AM]
It's because iSize is a pointer to an integer.
Don't you mean something like
gStringTable[sID+(*iSize)] = cName;
Don't you mean something like
gStringTable[sID+(*iSize)] = cName;
Quote:Original post by Prog101
I am using C and windows, i have the following code , this is just a snipit there is loads more all in the same format, can i make a function to handle all this
*** Source Snippet Removed ***
Uh... what the hell are you doing?
Why would you build a "string table" using strings that are already stored within the objects? (Keeping in mind that your table doesn't really store the strings, but simply copies the pointers?)
Why would you merge all the names into one "string table" - using some magic offsets - instead of separate ones?
As for your attempt - why would you pass 'iSize' by pointer?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement