PDA

View Full Version : Reset enum variables


Killer#Mummy
09/08/2012, 06:58 AM
Hello!

I have this enum:


enum MapData
{
mName[24],
mAuthor[64],
mCommand[24],
mWorld,
mLevel,

mCount_Objects,
mCount_Vehicles,
mCount_AutoFixers,
mCount_SpeedBoosters,
mCount_Hoppers,
mCount_Nitrous,
mCount_Changers,
mCount_Garages,
mCount_Pickups,
mCount_Spawns,
mCount_Spawn_Weapons,
mCount_Cameras,
mCount_Elevators,
mCount_Triggers,

mExist,
mError,
mObjects,
mVehicles,
mSpawns,
mMission,
mElevators,
mTeleports,
mChangers,
mAutoFixers,
mSpeedBoosters,
mHoppers,
mNitrous,
mPickups,
mAutoFix,
mSpeedBoost,
mHopping,
mRace,
mDeathmatch,
mGarages,
mTriggers,

mSpawn_Skin[MAX_SPAWNS],
mSpawn_Vehicle[MAX_SPAWNS],
Float: mSpawn_xPos[MAX_SPAWNS],
Float: mSpawn_yPos[MAX_SPAWNS],
Float: mSpawn_zPos[MAX_SPAWNS],
Float: mSpawn_Ang[MAX_SPAWNS],
mSpawn_Weapon_Model[MAX_WEAPONS],
mSpawn_Weapon_Ammo[MAX_WEAPONS],

Float: mCamera_xPos[MAX_CAMERAS],
Float: mCamera_yPos[MAX_CAMERAS],
Float: mCamera_zPos[MAX_CAMERAS],
Float: mCamera_Look_xPos[MAX_CAMERAS],
Float: mCamera_Look_yPos[MAX_CAMERAS],
Float: mCamera_Look_zPos[MAX_CAMERAS],

Float: mAutoFixer_xPos[MAX_AUTOFIXERS],
Float: mAutoFixer_yPos[MAX_AUTOFIXERS],
Float: mAutoFixer_zPos[MAX_AUTOFIXERS],
Float: mAutoFixer_Range[MAX_AUTOFIXERS],
mAutoFixer_Trigger[MAX_AUTOFIXERS],

Float: mSpeedBooster_Power[MAX_SPEEDBOOSTERS],
Float: mSpeedBooster_xPos[MAX_SPEEDBOOSTERS],
Float: mSpeedBooster_yPos[MAX_SPEEDBOOSTERS],
Float: mSpeedBooster_zPos[MAX_SPEEDBOOSTERS],
Float: mSpeedBooster_Range[MAX_SPEEDBOOSTERS],
mSpeedBooster_Trigger[MAX_SPEEDBOOSTERS],

Float: mHopper_Power[MAX_HOPPERS],
Float: mHopper_xPos[MAX_HOPPERS],
Float: mHopper_yPos[MAX_HOPPERS],
Float: mHopper_zPos[MAX_HOPPERS],
Float: mHopper_Range[MAX_HOPPERS],
mHopper_Trigger[MAX_HOPPERS],

Float: mNitro_xPos[MAX_NITROUS],
Float: mNitro_yPos[MAX_NITROUS],
Float: mNitro_zPos[MAX_NITROUS],
Float: mNitro_Range[MAX_NITROUS],
mNitro_Trigger[MAX_NITROUS],

mChanger_Vehicle[MAX_CHANGERS],
Float: mChanger_xPos[MAX_CHANGERS],
Float: mChanger_yPos[MAX_CHANGERS],
Float: mChanger_zPos[MAX_CHANGERS],
Float: mChanger_Range[MAX_CHANGERS],
mChanger_Trigger[MAX_CHANGERS],

mRace_Money,
mRace_Score,
mRace_Laps,
mRace_Respawn,
mCheckpoint_Vehicle[MAX_CHECKPOINTS],
Float: mCheckpoint_xPos[MAX_CHECKPOINTS],
Float: mCheckpoint_yPos[MAX_CHECKPOINTS],
Float: mCheckpoint_zPos[MAX_CHECKPOINTS],
Float: mCheckpoint_Size[MAX_CHECKPOINTS],

mDeathmatch_Mode,
mDeathmatch_Money,
mDeathmatch_Score,
mDeathmatch_Time,
mDeathmatch_Weapon_Model[MAX_WEAPONS],
mDeathmatch_Weapon_Ammo[MAX_WEAPONS],
Float: mDeathmatch_Special_Object_xPos[MAX_SPECIAL_OBJECTS],
Float: mDeathmatch_Special_Object_yPos[MAX_SPECIAL_OBJECTS],
Float: mDeathmatch_Special_Object_zPos[MAX_SPECIAL_OBJECTS],

mPickup_Model[MAX__PICKUPS],
mPickup_Object[MAX__PICKUPS],
mPickup_Trigger[MAX__PICKUPS],
mPickup_Toggle[MAX__PICKUPS],
Float: mPickup_xPos[MAX__PICKUPS],
Float: mPickup_yPos[MAX__PICKUPS],
Float: mPickup_zPos[MAX__PICKUPS],
Float: mPickup_Range[MAX__PICKUPS],

mMission_Vehicle,
mMission_Money,
mMission_Score,
Float: mMission_xPos,
Float: mMission_yPos,
Float: mMission_zPos,
Float: mMission_Range,

Float: mGarage_xPos[MAX_GARAGES],
Float: mGarage_yPos[MAX_GARAGES],
Float: mGarage_zPos[MAX_GARAGES],
Float: mGarage_Range[MAX_GARAGES],
mGarage_Trigger[MAX_GARAGES],

mTrigger_Elevator[MAX_TRIGGERS],
Float: mTrigger_xPos[MAX_TRIGGERS],
Float: mTrigger_yPos[MAX_TRIGGERS],
Float: mTrigger_zPos[MAX_TRIGGERS],
Float: mTrigger_Range[MAX_TRIGGERS],
mTrigger_Trigger[MAX_TRIGGERS],
}
new Map[MAX_MAPS][MapData];


Is there any faster way to reset all enum variables to 0? I know that I can do Map[num][mName] = "" and so on.. but I want to find faster way.

IceMeteor
09/08/2012, 08:12 AM
for(new i; i<sizeof(mapdata); i++)
{
Map[mapid][i] = 0;
}

Killer#Mummy
09/08/2012, 08:45 AM
Wow, I didn't know it can be so simple! I'm wondering, what about strings? As far as I know, I cannot make string empty with 'Map[MapNumber][mName] = 0;' but it must be Map[MapNumber][mName] = '\0' or with EOS. Is it possible to do this within the loop?

Vince
09/08/2012, 09:19 AM
0 = '\0' = EOS. So that works out. '0' in single quotes, however, doesn't belong to this series and has an ASCII value of 48. Consider this image:

https://manual.cs50.net/images/3/37/Asciifull.gif