Example #1
0
bool GPlayerAccess::ProcessMessage(GNetMsg & msg,int message)
{
	switch(message)
	{
	case IGM_ACCESS:
		{
			if(Valid())
			{
				GSocketAccess * sa=static_cast<GSocketAccess*>(socket);
				GTicketConnectionClient t_connection_client;
				msg.R(t_connection_client);
				if (*t_connection_client.access.target_location_ID == 0)
				{
					if (t_connection_client.access.target_gamestate_ID > 0)
					{
						strcpy(t_connection_client.access.target_location_ID, location_ID_from_gamestate_ID(t_connection_client.access.target_gamestate_ID).c_str());
					}
				}
				else
				{
					t_connection_client.access.target_gamestate_ID = gamestate_ID_from_location_ID(t_connection_client.access.target_location_ID);
				}

				sockaddr_in addr;
				socklen_t len=sizeof(addr);
				getpeername(socket->GetSocket(),(sockaddr*)&addr,&len);
				memcpy(&t_connection_client.client_host.addr_detected_by_server,&addr.sin_addr,4);

				t_connection_client.access.RID=GetRID();

				if (Service(ESTClientAccess)->GetOutQueueSize() >= global_serverconfig->net.ticket_queue_busy_limit ||
					Service(ESTClientAccess)->GetWaitQueueSize() >= global_serverconfig->net.ticket_queue_busy_limit)
				{
					MsgExt(IGM_CONNECTION_CLOSE).WT("server busy").A();
					return true;
				}

				GTicketConnectionPtr ticket(new GTicketConnection());
				Coerce(*ticket,t_connection_client);

				TicketInt(ESTClientAccess,IGMITIC_ACCESS,ticket);
				Coerce(sa->player_info,t_connection_client);
				sa->group_id = t_connection_client.access.group_ID;
			}
		}
		return true;
	}
	return false;
};
Example #2
0
int xlw::XlfOper4::ConvertToRef(XlfRef& r) const throw()
{
    int xlret;

    if (lpxloper_ == 0)
        return xlretInvXloper;

    if (lpxloper_->xltype & xltypeRef)
    {
        const XLREF& ref=lpxloper_->val.mref.lpmref->reftbl[0];
        r = XlfRef (ref.rwFirst,  // top
                    ref.colFirst, // left
                    ref.rwLast,   // bottom
                    ref.colLast,  // right
                    lpxloper_->val.mref.idSheet); // sheet id
        xlret = xlretSuccess;
    }
    else
    {
        // see AsDouble
        XLOPER tmp;
        // Function Coerce calls function Call which sets bit xlbitFreeAuxMem of variable cast,
        // so that the memory which Excel allocates to that variable (the reference) is freed
        // when the variable goes out of scope.
        XlfOper4 cast(&tmp);
        xlret = Coerce(xltypeRef,cast);
        if (xlret == xlretSuccess)
            xlret = cast.ConvertToRef(r);
    }
    return xlret;
}
Example #3
0
int xlw::XlfOper4::ConvertToString(char *& s) const throw()
{
    int xlret;

    if (lpxloper_ == 0)
        return xlretInvXloper;

    if (lpxloper_->xltype & xltypeStr)
    {
        // Must use datatype unsigned char (BYTE) to process 0th byte
        // otherwise numbers greater than 128 are incorrect
        size_t n = (unsigned char) lpxloper_->val.str[0];
        s = XlfExcel::Instance().GetMemory(n + 1);
        memcpy(s, lpxloper_->val.str + 1, n);
        s[n] = 0;
        xlret = xlretSuccess;
    }
    else
    {
        // see AsDouble
        XLOPER tmp;
        // Function Coerce calls function Call which sets bit xlbitFreeAuxMem of variable cast,
        // so that the memory which Excel allocates to that variable (the string) is freed
        // when the variable goes out of scope.
        XlfOper4 cast(&tmp);
        xlret = Coerce(xltypeStr,cast);
        if (xlret == xlretSuccess)
            xlret = cast.ConvertToString(s);
    }
    return xlret;
}
Example #4
0
int xlw::XlfOper4::ConvertToShort(short& s) const throw()
{
    int xlret;

    if (lpxloper_ == 0)
        return xlretInvXloper;

    if (lpxloper_->xltype & xltypeNum)
    {
        s = static_cast<short>(lpxloper_->val.num);
        xlret=xlretSuccess;
    }
    else
    {
        // Allocates tmp on the stack to avoid filling the internal buffer.
        XLOPER tmp;
        // Creates a XlfOper4 based on tmp.
        XlfOper4 cast(&tmp);
        // Coerces to numeric type.
        xlret = Coerce(xltypeNum,cast);
        if (xlret == xlretSuccess)
            xlret = cast.ConvertToShort(s);
    }
    return xlret;
};
Example #5
0
int xlw::XlfOper4::ConvertToDouble(double& d) const throw()
{
    int xlret;

    if (lpxloper_ == 0)
        return xlretInvXloper;

    if (lpxloper_->xltype & xltypeInt)
    {
        d = lpxloper_->val.w;
        xlret=xlretSuccess;
    }
    else if (lpxloper_->xltype & xltypeNum)
    {
        d = lpxloper_->val.num;
        xlret=xlretSuccess;
    }
    else
    {
        // Allocates tmp on the stack to avoid filling the internal buffer.
        XLOPER tmp;
        // Creates a XlfOper4 based on tmp.
        XlfOper4 cast(&tmp);
        // Coerces to numeric type.
        xlret = Coerce(xltypeNum,cast);
        if (xlret == xlretSuccess)
            xlret = cast.ConvertToDouble(d);
    }
    return xlret;
};
void *VersionInfo<string>::GetValue(const char *block, size_t *length) const
{
    // Attempt to query the requested block
    LPVOID buffer;
    size_t bufferLength;
    if (!initialised
            || !VerQueryValueI(versionInfo, Coerce(block).c_str(), &buffer,(PUINT) &bufferLength)
            || (bufferLength == 0))
    {
        buffer = 0;
    }

    // Return the results
    if (length) *length = buffer ? bufferLength : 0;
    return buffer;
}
Example #7
0
int xlw::XlfOper4::ConvertToErr(WORD& e) const throw()
{
    int xlret;

    if (lpxloper_ == 0)
        return xlretInvXloper;

    if (lpxloper_->xltype & xltypeErr)
    {
        e = lpxloper_->val.err ;
        xlret = xlretSuccess;
    }
    else
    {
        // see ConvertToDouble
        XLOPER tmp;
        XlfOper4 cast(&tmp);
        xlret = Coerce(xltypeErr,cast);
        if (xlret == xlretSuccess)
            xlret = cast.ConvertToErr(e);
    }
    return xlret;
};
Example #8
0
int xlw::XlfOper4::ConvertToBool(bool& b) const throw()
{
    int xlret;

    if (lpxloper_ == 0)
        return xlretInvXloper;

    if (lpxloper_->xltype & xltypeBool)
    {
        b = (lpxloper_->val.xbool != 0);
        xlret = xlretSuccess;
    }
    else
    {
        // see ConvertToDouble
        XLOPER tmp;
        XlfOper4 cast(&tmp);
        xlret = Coerce(xltypeBool,cast);
        if (xlret == xlretSuccess)
            xlret = cast.ConvertToBool(b);
    }
    return xlret;
};