本文整理汇总了C++中TMap::CheckKey方法的典型用法代码示例。如果您正苦于以下问题:C++ TMap::CheckKey方法的具体用法?C++ TMap::CheckKey怎么用?C++ TMap::CheckKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMap
的用法示例。
在下文中一共展示了TMap::CheckKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: R_FindCustomTranslation
int R_FindCustomTranslation(FName name)
{
switch (name)
{
case NAME_Ice:
// Ice is a special case which will remain in its original slot.
return TRANSLATION(TRANSLATION_Standard, 7);
case NAME_None:
return 0;
case NAME_RainPillar1:
case NAME_RainPillar2:
case NAME_RainPillar3:
case NAME_RainPillar4:
case NAME_RainPillar5:
case NAME_RainPillar6:
case NAME_RainPillar7:
case NAME_RainPillar8:
return TRANSLATION(TRANSLATION_RainPillar, name.GetIndex() - NAME_RainPillar1);
case NAME_Player1:
case NAME_Player2:
case NAME_Player3:
case NAME_Player4:
case NAME_Player5:
case NAME_Player6:
case NAME_Player7:
case NAME_Player8:
return TRANSLATION(TRANSLATION_Players, name.GetIndex() - NAME_Player1);
}
int *t = customTranslationMap.CheckKey(FName(name, true));
return (t != nullptr)? *t : -1;
}
示例2: Net_WriteWeapon
void Net_WriteWeapon(PClassWeapon *type)
{
int index, *index_p;
index_p = Weapons_hton.CheckKey(type);
if (index_p == NULL)
{
index = 0;
}
else
{
index = *index_p;
}
// 32767 weapons better be enough for anybody.
assert(index >= 0 && index <= 32767);
if (index < 128)
{
Net_WriteByte(index);
}
else
{
Net_WriteByte(0x80 | index);
Net_WriteByte(index >> 7);
}
}
示例3: LumpSampleRate
unsigned int LumpRemapper::LumpSampleRate(FResourceFile *Owner)
{
const int file = Wads.GetLumpFile(Owner->GetFirstLump());
const unsigned int* rate = sampleRateMap.CheckKey(file);
if(rate)
return 1000000/(256 - *rate);
return 1000000/(256 - TIMER_VALUE_DEFAULT);
}
示例4: CheckCompatibility
void CheckCompatibility(MapData *map)
{
FMD5Holder md5;
FCompatValues *flags;
ii_compatflags = 0;
ii_compatflags2 = 0;
ib_compatflags = 0;
ii_compatparams = -1;
// When playing Doom IWAD levels force COMPAT_SHORTTEX and COMPATF_LIGHT.
// I'm not sure if the IWAD maps actually need COMPATF_LIGHT but it certainly does not hurt.
// TNT's MAP31 also needs COMPATF_STAIRINDEX but that only gets activated for TNT.WAD.
if (Wads.GetLumpFile(map->lumpnum) == 1 && (gameinfo.flags & GI_COMPATSHORTTEX) && level.maptype == MAPTYPE_DOOM)
{
ii_compatflags = COMPATF_SHORTTEX|COMPATF_LIGHT;
if (gameinfo.flags & GI_COMPATSTAIRS) ii_compatflags |= COMPATF_STAIRINDEX;
}
map->GetChecksum(md5.Bytes);
flags = BCompatMap.CheckKey(md5);
if (developer >= DMSG_NOTIFY)
{
Printf("MD5 = ");
for (size_t j = 0; j < sizeof(md5.Bytes); ++j)
{
Printf("%02X", md5.Bytes[j]);
}
if (flags != NULL)
{
Printf(", cflags = %08x, cflags2 = %08x, bflags = %08x\n",
flags->CompatFlags[SLOT_COMPAT], flags->CompatFlags[SLOT_COMPAT2], flags->CompatFlags[SLOT_BCOMPAT]);
}
else
{
Printf("\n");
}
}
if (flags != NULL)
{
ii_compatflags |= flags->CompatFlags[SLOT_COMPAT];
ii_compatflags2 |= flags->CompatFlags[SLOT_COMPAT2];
ib_compatflags |= flags->CompatFlags[SLOT_BCOMPAT];
ii_compatparams = flags->ExtCommandIndex;
}
// Reset i_compatflags
compatflags.Callback();
compatflags2.Callback();
// Set floatbob compatibility for all maps with an original Hexen MAPINFO.
if (level.flags2 & LEVEL2_HEXENHACK)
{
ib_compatflags |= BCOMPATF_FLOATBOB;
}
}
示例5: AddFile
void LumpRemapper::AddFile(const char* extension, FResourceFile *file, Type type)
{
LumpRemapper *iter = remaps.CheckKey(extension);
if(iter == NULL)
{
LumpRemapper remaper(extension);
remaper.AddFile(file, type);
remaps.Insert(extension, remaper);
return;
}
iter->AddFile(file, type);
}
示例6: LoadMap
void LumpRemapper::LoadMap(const char* extension, const char* name, const char* data, unsigned int length)
{
LumpRemapper *iter = remaps.CheckKey(extension);
if(iter == NULL)
{
LumpRemapper remaper(extension);
remaper.LoadMap(name, data, length);
remaps.Insert(extension, remaper);
return;
}
iter->LoadMap(name, data, length);
}
示例7:
FxExpression *FxGlobalFunctionCall::StaticCreate
(FName methodname, FArgumentList *args, const FScriptPosition &pos)
{
Creator *creator = CreatorMap.CheckKey(methodname);
if (!creator)
{
pos.Message(MSG_ERROR, "Call to unknown function '%s'", methodname.GetChars());
return NULL;
}
return (*creator)(methodname, args, pos);
}
示例8: ParticleColor
static uint32_t ParticleColor(int rgb)
{
int *val;
int stuff;
val = ColorSaver.CheckKey(rgb);
if (val != NULL)
{
return *val;
}
stuff = rgb | (ColorMatcher.Pick(RPART(rgb), GPART(rgb), BPART(rgb)) << 24);
ColorSaver[rgb] = stuff;
return stuff;
}
示例9: ParseSpawnMap
static void ParseSpawnMap(FScanner &sc, SpawnMap & themap, const char *descript)
{
TMap<int, bool> defined;
int error = 0;
MapinfoSpawnItem editem;
editem.filename = sc.ScriptName;
while (true)
{
if (sc.CheckString("}")) return;
else if (sc.CheckNumber())
{
int ednum = sc.Number;
sc.MustGetStringName("=");
sc.MustGetString();
bool *def = defined.CheckKey(ednum);
if (def != NULL)
{
sc.ScriptMessage("%s %d defined more than once", descript, ednum);
error++;
}
else if (ednum < 0)
{
sc.ScriptMessage("%s must be positive, got %d", descript, ednum);
error++;
}
defined[ednum] = true;
editem.classname = sc.String;
editem.linenum = sc.Line;
themap.Insert(ednum, editem);
}
else
{
sc.ScriptError("Number expected");
}
}
if (error > 0)
{
sc.ScriptError("%d errors encountered in %s definition", error, descript);
}
}
示例10: FindClass
const PClass *P_GetSpawnableType(int spawnnum)
{
if (spawnnum < 0)
{ // A named arg from a UDMF map
FName spawnname = FName(ENamedName(-spawnnum));
if (spawnname.IsValidName())
{
return PClass::FindClass(spawnname);
}
}
else
{ // A numbered arg from a Hexen or UDMF map
const PClass **type = SpawnableThings.CheckKey(spawnnum);
if (type != NULL)
{
return *type;
}
}
return NULL;
}
示例11: COOP_PotentiallyStoreUVDPickup
//*****************************************************************************
//
void COOP_PotentiallyStoreUVDPickup ( const PClass *pType )
{
// [BB] The current game mode doesn't need voodoo dolls, so no need to store any pickups.
if ( COOP_VoodooDollsSelectedByGameMode() == false )
return;
// [BB] There is no ingame joining in such gamemodes, so no need to store any pickups.
if ( GAMEMODE_GetFlags( GAMEMODE_GetCurrentMode( )) & GMF_MAPRESETS )
return;
// [BB] Nothing to store.
if ( pType == NULL )
return;
// [BB] We only store weapons and keys since they might be crucial to finish a map.
if ( ( pType->IsDescendantOf( RUNTIME_CLASS( AWeapon )) == false )
&& ( pType->IsDescendantOf( RUNTIME_CLASS( AKey )) == false ) )
return;
const FName pickupName = pType->TypeName.GetChars();
if ( UVDpickupMap.CheckKey( pickupName ) == false )
UVDpickupMap.Insert( pickupName, 1 );
}
示例12: CheckForUnsafeStates
//==========================================================================
//
// CheckForUnsafeStates
//
// Performs a quick analysis to find potentially bad states.
// This is not perfect because it cannot track jumps by function.
// For such cases a runtime check in the relevant places is also present.
//
//==========================================================================
static void CheckForUnsafeStates(PClassActor *obj)
{
static ENamedName weaponstates[] = { NAME_Ready, NAME_Deselect, NAME_Select, NAME_Fire, NAME_AltFire, NAME_Hold, NAME_AltHold, NAME_Flash, NAME_AltFlash, NAME_None };
static ENamedName pickupstates[] = { NAME_Pickup, NAME_Drop, NAME_Use, NAME_None };
TMap<FState *, bool> checked;
ENamedName *test;
if (obj->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
{
if (obj->Size == RUNTIME_CLASS(AWeapon)->Size) return; // This class cannot have user variables.
test = weaponstates;
}
else if (obj->IsDescendantOf(RUNTIME_CLASS(ACustomInventory)))
{
if (obj->Size == RUNTIME_CLASS(ACustomInventory)->Size) return; // This class cannot have user variables.
test = pickupstates;
}
else return; // something else derived from AStateProvider. We do not know what this may be.
for (; *test != NAME_None; test++)
{
FState *state = obj->FindState(*test);
while (state != nullptr && checked.CheckKey(state) == nullptr) // have we checked this state already. If yes, we can stop checking the current chain.
{
checked[state] = true;
if (state->ActionFunc && state->ActionFunc->Unsafe)
{
// If an unsafe function (i.e. one that accesses user variables) is being detected, print a warning once and remove the bogus function. We may not call it because that would inevitably crash.
auto owner = FState::StaticFindStateOwner(state);
GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "Unsafe state call in state %s.%d which accesses user variables, reached by %s.%s.\n",
owner->TypeName.GetChars(), state - owner->OwnedStates, obj->TypeName.GetChars(), FName(*test).GetChars());
}
state = state->NextState;
}
}
}
示例13:
DamageTypeDefinition *DamageTypeDefinition::Get(FName type)
{
return GlobalDamageDefinitions.CheckKey(type);
}
示例14: CheckCompatibility
void CheckCompatibility(MapData *map)
{
FMD5Holder md5;
FCompatValues *flags;
bool onlyparams = true;
// When playing Doom IWAD levels force COMPAT_SHORTTEX and COMPATF_LIGHT.
// I'm not sure if the IWAD maps actually need COMPATF_LIGHT but it certainly does not hurt.
// TNT's MAP31 also needs COMPATF_STAIRINDEX but that only gets activated for TNT.WAD.
if (Wads.GetLumpFile(map->lumpnum) == 1 && (gameinfo.flags & GI_COMPATSHORTTEX) && level.maptype == MAPTYPE_DOOM)
{
ii_compatflags = COMPATF_SHORTTEX|COMPATF_LIGHT;
if (gameinfo.flags & GI_COMPATSTAIRS) ii_compatflags |= COMPATF_STAIRINDEX;
ii_compatflags2 = 0;
ib_compatflags = 0;
ii_compatparams = -1;
}
else if (Wads.GetLumpFile(map->lumpnum) == 1 && (gameinfo.flags & GI_COMPATPOLY1) && Wads.CheckLumpName(map->lumpnum, "MAP36"))
{
ii_compatflags = COMPATF_POLYOBJ;
ii_compatflags2 = 0;
ib_compatflags = 0;
ii_compatparams = -1;
}
else if (Wads.GetLumpFile(map->lumpnum) == 2 && (gameinfo.flags & GI_COMPATPOLY2) && Wads.CheckLumpName(map->lumpnum, "MAP47"))
{
ii_compatflags = COMPATF_POLYOBJ;
ii_compatflags2 = 0;
ib_compatflags = 0;
ii_compatparams = -1;
}
else
{
onlyparams = false;
}
map->GetChecksum(md5.Bytes);
flags = BCompatMap.CheckKey(md5);
if (developer)
{
Printf("MD5 = ");
for (size_t j = 0; j < sizeof(md5.Bytes); ++j)
{
Printf("%02X", md5.Bytes[j]);
}
if (flags != NULL)
{
Printf(", cflags = %08x, cflags2 = %08x, bflags = %08x\n",
flags->CompatFlags[SLOT_COMPAT], flags->CompatFlags[SLOT_COMPAT2], flags->CompatFlags[SLOT_BCOMPAT]);
}
else
{
Printf("\n");
}
}
if (flags != NULL)
{
if (!onlyparams)
{
ii_compatflags = flags->CompatFlags[SLOT_COMPAT];
ii_compatflags2 = flags->CompatFlags[SLOT_COMPAT2];
ib_compatflags = flags->CompatFlags[SLOT_BCOMPAT];
}
ii_compatparams = flags->ExtCommandIndex;
}
else
{
if (!onlyparams)
{
ii_compatflags = 0;
ii_compatflags2 = 0;
ib_compatflags = 0;
}
ii_compatparams = -1;
}
// Reset i_compatflags
compatflags.Callback();
compatflags2.Callback();
}
示例15: DoParse
static void DoParse(const char *filename)
{
if (TokenMap.CountUsed() == 0)
{
InitTokenMap();
}
FScanner sc;
void *parser;
int tokentype;
int lump;
bool failed;
ZCCToken value;
lump = Wads.CheckNumForFullName(filename, true);
if (lump >= 0)
{
sc.OpenLumpNum(lump);
}
else if (FileExists(filename))
{
sc.OpenFile(filename);
}
else
{
Printf("Could not find script lump '%s'\n", filename);
return;
}
parser = ZCCParseAlloc(malloc);
failed = false;
#ifdef _DEBUG
FILE *f = fopen("trace.txt", "w");
char prompt = '\0';
ZCCParseTrace(f, &prompt);
#endif
ZCCParseState state(sc);
while (sc.GetToken())
{
value.SourceLoc = sc.GetMessageLine();
switch (sc.TokenType)
{
case TK_StringConst:
value.String = state.Strings.Alloc(sc.String, sc.StringLen);
tokentype = ZCC_STRCONST;
break;
case TK_NameConst:
value.Int = sc.Name;
tokentype = ZCC_NAMECONST;
break;
case TK_IntConst:
value.Int = sc.Number;
tokentype = ZCC_INTCONST;
break;
case TK_UIntConst:
value.Int = sc.Number;
tokentype = ZCC_UINTCONST;
break;
case TK_FloatConst:
value.Float = sc.Float;
tokentype = ZCC_FLOATCONST;
break;
case TK_Identifier:
value.Int = FName(sc.String);
tokentype = ZCC_IDENTIFIER;
break;
case TK_NonWhitespace:
value.Int = FName(sc.String);
tokentype = ZCC_NWS;
break;
default:
TokenMapEntry *zcctoken = TokenMap.CheckKey(sc.TokenType);
if (zcctoken != NULL)
{
tokentype = zcctoken->TokenType;
value.Int = zcctoken->TokenName;
}
else
{
sc.ScriptMessage("Unexpected token %s.\n", sc.TokenName(sc.TokenType).GetChars());
goto parse_end;
}
break;
}
ZCCParse(parser, tokentype, value, &state);
if (failed)
{
sc.ScriptMessage("Parse failed\n");
goto parse_end;
}
}
parse_end:
//.........这里部分代码省略.........