コード例 #1
0
ファイル: idle_summoner.cpp プロジェクト: Tkachov/scummvm
bool CIdleSummoner::TimerMsg(CTimerMsg *msg) {
	uint nodesCtr = getNodeChangedCtr();
	if (msg->_actionVal == 1 && !petDoorOrBellbotPresent()
			&& nodesCtr > 0 && _fieldD8) {
		if (!compareRoomNameTo("TopOfWell") && !compareRoomNameTo("EmbLobby"))
			return true;

		int region = talkGetDialRegion("BellBot", 1);
		uint delay = region == 1 ? 15000 : 12000;
		uint enterTicks = MIN(getNodeEnterTicks(), _ticks);
		
		CString name;
		uint ticks = getTicksCount() - enterTicks;
		if (ticks > delay) {
			if (region == 1 || getRandomNumber(1) == 1) {
				name = "BellBot";
			} else {
				name = "DoorBot";
			}
			_fieldD8 = nodesCtr;

			if (getRoom()) {
				CSummonBotQueryMsg queryMsg(name);
				if (queryMsg.execute(this)) {
					CSummonBotMsg summonMsg(name, 1);
					summonMsg.execute(this);
				}
			}
		}
	}

	return true;
}
コード例 #2
0
ファイル: pet_control.cpp プロジェクト: 86400/scummvm
int CPetControl::canSummonBot(const CString &name) {
	// If player is the very same view as the NPC, then it's already present
	if (isBotInView(name))
		return SUMMON_CAN;

	// Get the room
	CGameManager *gameManager = getGameManager();
	if (!gameManager)
		return SUMMON_CANT;
	CRoomItem *room = gameManager->getRoom();
	if (!room)
		return SUMMON_CANT;

	// Query current room to see whether the bot can be summoned to it
	CSummonBotQueryMsg queryMsg(name);
	return queryMsg.execute(room) ? SUMMON_CAN : SUMMON_CANT;
}
コード例 #3
0
ファイル: SreqListenActor.hpp プロジェクト: firememory/dfwbi
    inline void HandleReqMsg(std::string msg,amqp_basic_properties_t *p)
        {
            std::cout<<msg<<std::endl;

            char key[4096];
            memset(key,0,sizeof(key));
            strncpy(key,(char*)(p->reply_to.bytes),p->reply_to.len);
            std::cout<<key<<std::endl;


            std::stringstream ss(msg);
            search::QueryInfo *qi=new search::QueryInfo();
            boost::archive::xml_iarchive ia(ss);
            ia >> BOOST_SERIALIZATION_NVP(*qi);
            
            QueryMessage queryMsg(qi,key);
            Send(queryMsg, parent);
        }
コード例 #4
0
void pawsPetitionGMWindow::QueryServer()
{
    // Construct the special petition request message to ask the server for info
    psPetitionRequestMessage queryMsg(true, "query");
    msgqueue->SendMessage(queryMsg.msg);
}
コード例 #5
0
void pawsPetitionGMWindow::CloseCurrPetition(const char *desc)
{
    // Send a message to the server requesting assignment:
    psPetitionRequestMessage queryMsg(true, "close", petitionMessage.petitions.Get(petitionList->GetRow(currentRow)->GetLastIndex()).id, desc);
    msgqueue->SendMessage(queryMsg.msg);
}
コード例 #6
0
bool pawsPetitionGMWindow::OnButtonReleased(int /*mouseButton*/, int /*keyModifier*/, pawsWidget* widget)
{
    // We know that the calling widget is a button.
    int button = widget->GetID();

    switch( button )
    {
        case QUIT_BUTTON:
        {
            // Hide our petition window
            petitionList->Clear();
            Hide();
            break;
        }

        case CANCEL_BUTTON:
        {
            if (petCount > 0)
            {
                // Get the currently selected row:
                int sel = petitionList->GetSelectedRowNum();
                if (sel < 0)
                {
                    psSystemMessage error(0,MSG_INFO,PawsManager::GetSingleton().Translate("You must select a petition from the list in order to cancel it."));
                    msgqueue->Publish(error.msg);
                    return true;
                }

                if (csString("In Progress") == petitionList->GetSelectedText(PGMCOL_STATUS)
                    && ((csString)psengine->GetMainPlayerName()).StartsWith(petitionList->GetSelectedText(PGMCOL_GM)))
                {

                    currentRow = sel;

                    // Send a message to the server requesting cancel
                    psPetitionRequestMessage queryMsg(true, "cancel", petitionMessage.petitions.Get(petitionList->GetRow(currentRow)->GetLastIndex()).id);
                    msgqueue->SendMessage(queryMsg.msg);
                }
                else
                {
                    psSystemMessage error(0,MSG_INFO,PawsManager::GetSingleton().Translate("You must be assigned to a petition in order to cancel it."));
                    msgqueue->Publish(error.msg);
                }
            }
            break;
        }

        case ASSIGN_BUTTON:
        {
            if (petCount > 0)
            {
                // Get the currently selected row:
                int sel = petitionList->GetSelectedRowNum();
                if (sel < 0)
                {
                    psSystemMessage error(0,MSG_INFO,PawsManager::GetSingleton().Translate("You must select a petition from the list in order to assign yourself."));
                    msgqueue->Publish(error.msg);
                    return true;
                }

                if (csString("Open") == petitionList->GetSelectedText(PGMCOL_STATUS))
                {
                    currentRow = sel;

                    // Send a message to the server requesting assignment:
                    psPetitionRequestMessage queryMsg(true, "assign", petitionMessage.petitions.Get(petitionList->GetRow(currentRow)->GetLastIndex()).id);
                    msgqueue->SendMessage(queryMsg.msg);
                }
                else
                {
                    psSystemMessage error(0,MSG_INFO,PawsManager::GetSingleton().Translate("The selected petition isn't Open."));
                    msgqueue->Publish(error.msg);
                }
            }
            break;
        }

        case DEASSIGN_BUTTON:
        {
            if (petCount > 0)
            {
                // Get the currently selected row:
                int sel = petitionList->GetSelectedRowNum();
                if (sel < 0)
                {
                    psSystemMessage error(0,MSG_INFO,PawsManager::GetSingleton().Translate("You must select a petition from the list in order to deassign yourself."));
                    msgqueue->Publish(error.msg);
                    return true;
                }

                if ((csString("In Progress") == petitionList->GetSelectedText(PGMCOL_STATUS)
                    && ((csString)psengine->GetMainPlayerName()).StartsWith(petitionList->GetSelectedText(PGMCOL_GM)))
                    || psengine->GetCelClient()->GetMainPlayer()->GetType() >= 25)
                {
                    currentRow = sel;

                    // Send a message to the server requesting deassignment:
                    psPetitionRequestMessage queryMsg(true, "deassign", petitionMessage.petitions.Get(petitionList->GetRow(currentRow)->GetLastIndex()).id);
                    msgqueue->SendMessage(queryMsg.msg);
                }
                else
                {
                    psSystemMessage error(0,MSG_INFO,PawsManager::GetSingleton().Translate("The selected petition isn't assigned."));
                    msgqueue->Publish(error.msg);
                }
            }
            break;
        }

        case CLOSE_BUTTON:
        {
            if (petCount > 0)
            {
                // Get the currently selected row:
                int sel = petitionList->GetSelectedRowNum();
                if (sel < 0)
                {
                    psSystemMessage error(0,MSG_INFO,PawsManager::GetSingleton().Translate("You must select a petition from the list in order to close it."));
                    msgqueue->Publish(error.msg);
                    return true;
                }

                if (csString("In Progress") == petitionList->GetSelectedText(PGMCOL_STATUS)
                    && ((csString)psengine->GetMainPlayerName()).StartsWith(petitionList->GetSelectedText(PGMCOL_GM)))
                {
                    currentRow = sel;

                    pawsStringPromptWindow::Create(PawsManager::GetSingleton().Translate("Describe the petition and how you've helped"), "",
                                                   true, 400, 60, this, "CloseDesc");
                }
                else
                {
                    psSystemMessage error(0,MSG_INFO,PawsManager::GetSingleton().Translate("You must be assigned to a petition in order to close it."));
                    msgqueue->Publish(error.msg);
                }
            }
            break;
        }

        case ESCALATE_BUTTON:
        {
            if (petCount > 0)
            {
                // Get the currently selected row:
                int sel = petitionList->GetSelectedRowNum();
                if (sel < 0)
                {
                    psSystemMessage error(0,MSG_INFO,PawsManager::GetSingleton().Translate("You must select a petition from the list in order to escalate it."));
                    msgqueue->Publish(error.msg);
                    return true;
                }

                if (psengine->GetCelClient()->GetMainPlayer()->GetType() + 1 >= atoi(petitionList->GetSelectedText(PGMCOL_LVL)))
                {
                    int level = atoi(petitionList->GetSelectedText(PGMCOL_LVL));
                    if ( level == 10 )
                    {
                        psSystemMessage error(0,MSG_INFO,"Cannot escalate above 10");
                        msgqueue->Publish(error.msg);
                        return true;
                    }

                    currentRow = sel;

                    // Send a message to the server requesting assignment:
                    psPetitionRequestMessage queryMsg(true, "escalate", petitionMessage.petitions.Get(petitionList->GetRow(currentRow)->GetLastIndex()).id);
                    msgqueue->SendMessage(queryMsg.msg);
                }
            }
            break;
        }

        case DESCALATE_BUTTON:
        {
            if (petCount > 0)
            {
                // Get the currently selected row:
                int sel = petitionList->GetSelectedRowNum();
                if (sel < 0)
                {
                    psSystemMessage error(0,MSG_INFO,PawsManager::GetSingleton().Translate("You must select a petition from the list in order to descalate it."));
                    msgqueue->Publish(error.msg);
                    return true;
                }

                if (psengine->GetCelClient()->GetMainPlayer()->GetType() + 1 >= atoi(petitionList->GetSelectedText(PGMCOL_LVL)))
                {
                    int level = atoi(petitionList->GetSelectedText(PGMCOL_LVL));
                    if ( level == 0 )
                    {
                        psSystemMessage error(0,MSG_INFO,"Cannot descalate below 0");
                        msgqueue->Publish(error.msg);
                        return true;
                    }

                    currentRow = sel;

                    // Send a message to the server requesting assignment:
                    psPetitionRequestMessage queryMsg(true, "descalate", petitionMessage.petitions.Get(petitionList->GetRow(currentRow)->GetLastIndex()).id);
                    msgqueue->SendMessage(queryMsg.msg);
                }
            }
            break;
        }

        case ADMIN_BUTTON:
        {
            // store the target petitioner data
            if (petCount > 0)
            {
                // Get the currently selected row:
                int sel = petitionList->GetSelectedRowNum();
                if (sel < 0)
                    psengine->SetTargetPetitioner("None");
                else
                {
                    if (csString("In Progress") == petitionList->GetSelectedText(PGMCOL_STATUS))
                        psengine->SetTargetPetitioner(petitionList->GetSelectedText(PGMCOL_PLAYER));
                    else
                        psengine->SetTargetPetitioner("None");
                }
            }
            else
                psengine->SetTargetPetitioner("None");

            // load the gm gui so that the gm can access functions to aid the pet
            const char* errorMessage = cmdsource->Publish( "/show gm" );
            if ( errorMessage )
            {
                psSystemMessage error(0,MSG_INFO,errorMessage);
                msgqueue->Publish(error.msg);
            }
        }
    }

    return true;
}
コード例 #7
0
ファイル: MsgCore.c プロジェクト: sssemil/cjdns
static Iface_DEFUN incoming(struct Message* msg, struct Iface* interRouterIf)
{
    struct MsgCore_pvt* mcp =
        Identity_containerOf(interRouterIf, struct MsgCore_pvt, pub.interRouterIf);

    struct Address addr = { .padding = 0 };
    struct RouteHeader* hdr = (struct RouteHeader*) msg->bytes;
    Message_shift(msg, -(RouteHeader_SIZE + DataHeader_SIZE), NULL);
    Bits_memcpy(addr.ip6.bytes, hdr->ip6, 16);
    Bits_memcpy(addr.key, hdr->publicKey, 32);
    addr.protocolVersion = Endian_bigEndianToHost32(hdr->version_be);
    addr.path = Endian_bigEndianToHost64(hdr->sh.label_be);

    Dict* content = NULL;
    uint8_t* msgBytes = msg->bytes;
    int length = msg->length;
    //Log_debug(mcp->log, "Receive msg [%s] from [%s]",
    //    Escape_getEscaped(msg->bytes, msg->length, msg->alloc),
    //    Address_toString(&addr, msg->alloc)->bytes);
    //
    BencMessageReader_readNoExcept(msg, msg->alloc, &content);
    if (!content) {
        char* esc = Escape_getEscaped(msgBytes, length, msg->alloc);
        Log_debug(mcp->log, "DROP Malformed message [%s]", esc);
        return NULL;
    }

    int64_t* verP = Dict_getIntC(content, "p");
    if (!verP) {
        Log_debug(mcp->log, "DROP Message without version");
        return NULL;
    }
    addr.protocolVersion = *verP;

    String* q = Dict_getStringC(content, "q");

    if (!Defined(SUBNODE)) {
        String* txid = Dict_getStringC(content, "txid");
        Assert_true(txid);
        if (q) {
            if (txid->bytes[0] == '0') {
                Log_debug(mcp->log, "DROP query which begins with 0 and is for old pathfinder");
                return NULL;
            }
        } else {
            if (txid->bytes[0] != '1') {
                Log_debug(mcp->log, "DROP reply which does not begin with 1");
                return NULL;
            }
            String* newTxid = String_newBinary(NULL, txid->len - 1, msg->alloc);
            Bits_memcpy(newTxid->bytes, &txid->bytes[1], txid->len - 1);
            Dict_putStringC(content, "txid", newTxid, msg->alloc);
            txid = newTxid;
        }
    }

    if (q) {
        return queryMsg(mcp, content, &addr, msg);
    } else {
        return replyMsg(mcp, content, &addr, msg);
    }
}

struct MsgCore* MsgCore_new(struct EventBase* base,
                            struct Random* rand,
                            struct Allocator* allocator,
                            struct Log* log,
                            struct EncodingScheme* scheme)
{
    struct Allocator* alloc = Allocator_child(allocator);
    struct MsgCore_pvt* mcp = Allocator_calloc(alloc, sizeof(struct MsgCore_pvt), 1);
    Identity_set(mcp);
    mcp->pub.interRouterIf.send = incoming;
    mcp->qh = ArrayList_OfQueryHandlers_new(alloc);
    mcp->pinger = Pinger_new(base, rand, log, alloc);
    mcp->log = log;

    mcp->scheme = scheme;
    mcp->schemeDefinition = EncodingScheme_serialize(scheme, alloc);

    return &mcp->pub;
}