Esempio n. 1
0
File: main.cpp Progetto: CCJY/coliru
 void do_send(typename C::argument_type arg, Detail::ResultTypeIsVoid<true>)
 {
     try_deserialize_result<void>(sendImpl(GetTypeName(Identity<C>()), Serialize(arg)));
 }
Esempio n. 2
0
File: main.cpp Progetto: CCJY/coliru
 void do_send(Detail::ResultTypeIsVoid<true>)
 {
     try_deserialize_result<void>(sendImpl(GetTypeName(Identity<C>()), ""));
 }
Esempio n. 3
0
File: main.cpp Progetto: CCJY/coliru
 typename C::result_type do_send(Detail::ResultTypeIsVoid<false>)
 {
     return try_deserialize_result<typename C::result_type>(sendImpl(GetTypeName(Identity<C>()), ""));
 }
bool CTilegenAction_FilterCandidatesForLinearGrowth::LoadFromKeyValues( KeyValues *pKeyValues )
{
	bool bSuccess = true;
	bSuccess &= CreateExpressionFromKeyValuesBlock( pKeyValues, "threshold", GetTypeName(), &m_pThresholdExpression );
	return bSuccess;
}
bool CTilegenAction_EnsureRoomExists::LoadFromKeyValues( KeyValues *pKeyValues )
{
	return CreateExpressionFromKeyValuesBlock( pKeyValues, "roomname", GetTypeName(), &m_pRoomNameExpression );
}
Esempio n. 6
0
 const char* GetTypeName() const {return GetTypeName(m_NodeType);}
Esempio n. 7
0
{
	SQInteger res;
	SQInteger i1 = _integer(o1), i2 = _integer(o2);
	if((type(o1)==OT_INTEGER) && (type(o2)==OT_INTEGER))
	{
		switch(op) {
			case BW_AND:	res = i1 & i2; break;
			case BW_OR:		res = i1 | i2; break;
			case BW_XOR:	res = i1 ^ i2; break;
			case BW_SHIFTL:	res = i1 << i2; break;
			case BW_SHIFTR:	res = i1 >> i2; break;
			case BW_USHIFTR:res = (SQInteger)(*((SQUnsignedInteger*)&i1) >> i2); break;
			default: { Raise_Error(_SC("internal vm error bitwise op failed")); return false; }
		}
	} 
	else { Raise_Error(_SC("bitwise op between '%s' and '%s'"),GetTypeName(o1),GetTypeName(o2)); return false;}
	trg = res;
	return true;
}

bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
{
	if(sq_isnumeric(o1) && sq_isnumeric(o2)) {
			if((type(o1)==OT_INTEGER) && (type(o2)==OT_INTEGER)) {
				SQInteger res, i1 = _integer(o1), i2 = _integer(o2);
				switch(op) {
				case '+': res = i1 + i2; break;
				case '-': res = i1 - i2; break;
				case '/': if(i2 == 0) { Raise_Error(_SC("division by zero")); return false; }
					res = i1 / i2; 
					break;
Esempio n. 8
0
wxString wxCmdLineParser::GetUsageString()
{
    wxString appname;
    if ( m_data->m_arguments.empty() )
    {
        if ( wxTheApp )
            appname = wxTheApp->GetAppName();
    }
    else // use argv[0]
    {
        appname = wxFileName(m_data->m_arguments[0]).GetName();
    }

    // we construct the brief cmd line desc on the fly, but not the detailed
    // help message below because we want to align the options descriptions
    // and for this we must first know the longest one of them
    wxString usage;
    wxArrayString namesOptions, descOptions;

    if ( !m_data->m_logo.empty() )
    {
        usage << m_data->m_logo << _T('\n');
    }

    usage << wxString::Format(_("Usage: %s"), appname.c_str());

    // the switch char is usually '-' but this can be changed with
    // SetSwitchChars() and then the first one of possible chars is used
    wxChar chSwitch = !m_data->m_switchChars ? _T('-')
                                             : m_data->m_switchChars[0u];

    bool areLongOptionsEnabled = AreLongOptionsEnabled();
    size_t n, count = m_data->m_options.GetCount();
    for ( n = 0; n < count; n++ )
    {
        wxCmdLineOption& opt = m_data->m_options[n];

        usage << _T(' ');
        if ( !(opt.flags & wxCMD_LINE_OPTION_MANDATORY) )
        {
            usage << _T('[');
        }

        if ( !opt.shortName.empty() )
        {
            usage << chSwitch << opt.shortName;
        }
        else if ( areLongOptionsEnabled && !opt.longName.empty() )
        {
            usage << _T("--") << opt.longName;
        }
        else
        {
            if (!opt.longName.empty())
            {
                wxFAIL_MSG( wxT("option with only a long name while long ")
                            wxT("options are disabled") );
            }
            else
            {
                wxFAIL_MSG( _T("option without neither short nor long name") );
            }
        }

        wxString option;

        if ( !opt.shortName.empty() )
        {
            option << _T("  ") << chSwitch << opt.shortName;
        }

        if ( areLongOptionsEnabled && !opt.longName.empty() )
        {
            option << (option.empty() ? _T("  ") : _T(", "))
                   << _T("--") << opt.longName;
        }

        if ( opt.kind != wxCMD_LINE_SWITCH )
        {
            wxString val;
            val << _T('<') << GetTypeName(opt.type) << _T('>');
            usage << _T(' ') << val;
            option << (!opt.longName ? _T(':') : _T('=')) << val;
        }

        if ( !(opt.flags & wxCMD_LINE_OPTION_MANDATORY) )
        {
            usage << _T(']');
        }

        namesOptions.push_back(option);
        descOptions.push_back(opt.description);
    }

    count = m_data->m_paramDesc.GetCount();
    for ( n = 0; n < count; n++ )
    {
        wxCmdLineParam& param = m_data->m_paramDesc[n];

        usage << _T(' ');
        if ( param.flags & wxCMD_LINE_PARAM_OPTIONAL )
        {
            usage << _T('[');
        }

        usage << param.description;

        if ( param.flags & wxCMD_LINE_PARAM_MULTIPLE )
        {
            usage << _T("...");
        }

        if ( param.flags & wxCMD_LINE_PARAM_OPTIONAL )
        {
            usage << _T(']');
        }
    }

    usage << _T('\n');

    // now construct the detailed help message
    size_t len, lenMax = 0;
    count = namesOptions.size();
    for ( n = 0; n < count; n++ )
    {
        len = namesOptions[n].length();
        if ( len > lenMax )
            lenMax = len;
    }

    for ( n = 0; n < count; n++ )
    {
        len = namesOptions[n].length();
        usage << namesOptions[n]
              << wxString(_T(' '), lenMax - len) << _T('\t')
              << descOptions[n]
              << _T('\n');
    }

    return usage;
}
Esempio n. 9
0
void MathFunction::GetData(mystr& funcname, Vector& coefficients) const//return functionname
{
    funcname = GetTypeName();
    coefficients = coeff;
}
Esempio n. 10
0
bool Resource::Save(Serializer& dest) const
{
    LOGERROR("Save not supported for " + GetTypeName());
    return false;
}
CEntity *CEntityManager::CBaseEntityPostConstructor(CBaseEntity *pEntity, const char * szClassname )
{
	IServerNetworkable *pNetworkable = pEntity->GetNetworkable();
	Assert(pNetworkable);

	edict_t *pEdict = pNetworkable->GetEdict();

	if(strcmp(szClassname,"player") == 0 && engine->IndexOfEdict(pEdict) == 0)
	{
		return NULL;
	}

	IEntityFactory_CE **value = NULL;
	bool m_bShouldAddToCache = false;
	value = pCacheTrie.retrieve(szClassname);

	if(!value)
	{
		m_bShouldAddToCache = true;
		value = pFactoryTrie.retrieve(szClassname);
	}

	if (!value)
	{
		/* Attempt to do an RTTI lookup for C++ class links */
		IType *pType = GetType(pEntity);
		IBaseType *pBase = pType->GetBaseType();

		do 
		{
			const char *classname = GetTypeName(pBase->GetTypeInfo());
			value = pFactoryTrie.retrieve(classname);

			if (value)
			{
				break;
			}

		} while (pBase->GetNumBaseClasses() && (pBase = pBase->GetBaseClass(0)));

		pType->Destroy();
	}

	if (!value)
	{
		/* No specific handler for this entity */
		value = pFactoryTrie.retrieve("baseentity");
		assert(value);
	}

	IEntityFactory_CE *pFactory = *value;
	assert(pFactory);

	if(m_bShouldAddToCache)
	{
		pCacheTrie.insert(szClassname, pFactory);
	}

	CEntity *cent = pFactory->Create(pEdict, pEntity);

	char vtable[20];
	_snprintf(vtable, sizeof(vtable), "%x", (unsigned int) *(void **)pEntity);

	cent->ClearAllFlags();
	cent->InitProps();
	
	if (!pHookedTrie.retrieve(vtable))
	{
		cent->InitHooks();
		pHookedTrie.insert(vtable, true);
	}
	
	cent->InitDataMap();

	return cent;
}
Esempio n. 12
0
// TODO: Handle en passant
static
char*
TryMove(USER_DATA *ud, COLOR c, int x, int y, int dx, int dy)
{
	BOARD b = ud->board;

	PIECE *p = GetPieceAt(ud->board, x, y);
	if (p->type == TYPE_NONE) {
		return "No piece at that position!";
	} else if (p->color != c) {
		return "That piece is not yours!";
	}

	// check if this move is a castle attempt
	// TODO: check for rook movements
	if (p->type == TYPE_KING && IsCastleMove(c, x, y, dx, dy)) {
		if (ColorCanCastle(ud, c) == false) {
			return "You can no longer castle";
		}
		
		return TryCastle(ud, c, x, y, dx, dy);
	}

	// check that the piece can make this movement
	if (PieceCanAttack(ud->board, c, p->type, x, y, dx, dy) == false) {
		return "Piece can't make that movement";
	}

	// target piece
	PIECE *t = GetPieceAt(ud->board, dx, dy);
	if (t->type != TYPE_NONE && t->color == c) {
		return "You already have a piece in the destination position!";
	}

	// make the movements to check for check, but store the data
	// in case the board needs to be reverted
	PIECE old_p = *p;
	PIECE old_t = *t;
	SetPieceAt(b, dx, dy, p->color, p->type);
	SetPieceAt(b, x, y, COLOR_NONE, TYPE_NONE);

	// find the king and test for check
	int kingx, kingy;
	FindKing(b, c, &kingx, &kingy);
	if (IsCoordAttackedBy(b, GetOppositeColor(c), kingx, kingy) == true) {
		// restore saved positions
		SetPieceAt(b, x, y, old_p.color, old_p.type);
		SetPieceAt(b, dx, dy, old_t.color, old_t.type);
		return "That move would place your King in check!";
	}

	//
	// At this point, the move was successful
	//

	// make the pieces blink
	// TODO: this will erroneously leave pieces on if 2 moves
	// are made quickly
	uint32_t objid = LvzGetObjId(old_p.color, old_p.type, dx, dy);
	SetTimer(500, (void*)objid, (void*)0);
	SetTimer(1000, (void*)objid, (void*)1);
	SetTimer(1500, (void*)objid, (void*)0);
	SetTimer(2000, (void*)objid, (void*)1);
	SetTimer(2500, (void*)objid, (void*)0);
	SetTimer(3000, (void*)objid, (void*)1);
	if (old_t.type != TYPE_NONE) {
		// flash the captured piece
		objid = LvzGetObjId(old_t.color, old_t.type, dx, dy);
		SetTimer(500, (void*)objid, (void*)1);
		SetTimer(1000, (void*)objid, (void*)0);
		SetTimer(1500, (void*)objid, (void*)1);
		SetTimer(2000, (void*)objid, (void*)0);
		SetTimer(2500, (void*)objid, (void*)1);
		SetTimer(3000, (void*)objid, (void*)0);
	}

	if (old_p.type == TYPE_KING) {
		// kings cant castle once theyve moved
		if (old_p.color == COLOR_WHITE) {
			ud->white_can_castle = false;
		} else if (old_p.color == COLOR_BLACK) {
			ud->black_can_castle = false;
		}
	}

	// set if a piece has been captured
	bool capture = old_t.type != TYPE_NONE;

	// remove drawing of the old pieces
	LvzActivate(ud, NULL, old_p.color, old_p.type, x, y, false);
	if (capture) {
		LvzActivate(ud, NULL, old_t.color, old_t.type, dx, dy, false);
	}

	// check for pawn promotions
	// TODO: handle underpromotions
	bool promoted = false;
	p = GetPieceAt(b, dx, dy);
	if (p->type == TYPE_PAWN) {
		if (p->color == COLOR_WHITE && dy == 7) {
			p->type = TYPE_QUEEN;
			promoted = true;
		} else if (p->color == COLOR_BLACK && dy == 0) {
			p->type = TYPE_QUEEN;
			promoted = true;
		}
	}

	// draw the new piece
	LvzActivate(ud, NULL, old_p.color, old_p.type, dx, dy, true);
	objid = LvzGetObjId(old_p.color, old_p.type, dx, dy);

	// create move notation
	char move[6];
	move[0] = x + 'a';
	move[1] = y + '1';
	move[2] = ',';
	move[3] = dx + 'a';
	move[4] = dy + '1';
	move[5] = '\0';

	// announce the move
	char line[256];
	snprintf(line, 256, "%s (%s) Moves: %s",
	    GetPlayerName(ud, c), GetColorText(ud->to_move), move);
	if (capture) {
		// add capture line
		char capture[64];
		snprintf(capture, 64, ", capturing a %s!", GetTypeName(old_t.type));
		strlcat(line, capture, 256);
	}
	if (promoted == true) {
		// add promition line
		strlcat(line, " Pawn promoted to Queen!", 256);
	}
	FindKing(b, GetOppositeColor(c), &kingx, &kingy);
	if (IsCoordAttackedBy(b, c, kingx, kingy) == true) {
		if (IsCheckmatedBy(b, c, kingx, kingy) == true) {
			strlcat(line, " Checkmate!", 256);
			ArenaMessage(line);

			char gametime[32];
			TicksToText(gametime, 32, GetTicksMs() - ud->start_tick);
			StopGame(ud, "%s Wins in %s!", GetPlayerName(ud, c), gametime);
		} else {
			strlcat(line, " Check!", 256);
			ArenaMessage(line);
		}
	} else {
		ArenaMessage(line);
	}

	return NULL;
}
Esempio n. 13
0
const ClassBinding& SoapServerInternal::GetClassBinding(const type_info& type)
{
  return GetClassBinding(GetTypeName(type));
}
Esempio n. 14
0
bool SoapServerInternal::HasClassBinding(const type_info& type)
{
  return HasClassBinding(GetTypeName(type));
}