本文整理汇总了C++中NETuint8_t函数的典型用法代码示例。如果您正苦于以下问题:C++ NETuint8_t函数的具体用法?C++ NETuint8_t怎么用?C++ NETuint8_t使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NETuint8_t函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recvGift
bool recvGift(NETQUEUE queue)
{
uint8_t type, from, to;
int audioTrack;
uint32_t droidID;
NETbeginDecode(queue, GAME_GIFT);
NETuint8_t(&type);
NETuint8_t(&from);
NETuint8_t(&to);
NETuint32_t(&droidID);
NETend();
if (!canGiveOrdersFor(queue.index, from))
{
debug(LOG_WARNING, "Gift (%d) from %d, to %d, queue.index %d", (int)type, (int)from, (int)to, (int)queue.index);
syncDebug("Wrong player.");
return false;
}
// Handle the gift depending on what it is
switch (type)
{
case RADAR_GIFT:
audioTrack = ID_SENSOR_DOWNLOAD;
giftRadar(from, to, false);
break;
case DROID_GIFT:
audioTrack = ID_UNITS_TRANSFER;
recvGiftDroids(from, to, droidID);
break;
case STRUCTURE_GIFT:
audioTrack = ID_GIFT;
recvGiftStruct(from, to, droidID);
break;
case RESEARCH_GIFT:
audioTrack = ID_TECHNOLOGY_TRANSFER;
giftResearch(from, to, false);
break;
case POWER_GIFT:
audioTrack = ID_POWER_TRANSMIT;
giftPower(from, to, droidID, false);
break;
case AUTOGAME_GIFT:
audioTrack = ID_SOUND_NEXUS_SYNAPTIC_LINK;
giftAutoGame(from, to, false);
break;
default:
debug(LOG_ERROR, "recvGift: Unknown Gift recvd");
return false;
break;
}
// If we are on the receiving end play an audio alert.
if (bMultiPlayer && to == selectedPlayer)
{
audio_QueueTrack(audioTrack);
}
return true;
}
示例2: giftResearch
// ////////////////////////////////////////////////////////////////////////////
// give technologies.
static void giftResearch(uint8_t from, uint8_t to, bool send)
{
int i;
uint32_t dummy = 0;
if (send)
{
uint8_t giftType = RESEARCH_GIFT;
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_GIFT);
NETuint8_t(&giftType);
NETuint8_t(&from);
NETuint8_t(&to);
NETuint32_t(&dummy);
NETend();
}
else if (alliancesCanGiveResearchAndRadar(game.alliance))
{
if (to == selectedPlayer)
{
CONPRINTF(ConsoleString, (ConsoleString, _("%s Gives You Technology Documents"), getPlayerName(from)));
}
// For each topic
for (i = 0; i < asResearch.size(); i++)
{
// If they have it and we don't research it
if (IsResearchCompleted(&asPlayerResList[from][i])
&& !IsResearchCompleted(&asPlayerResList[to][i]))
{
MakeResearchCompleted(&asPlayerResList[to][i]);
researchResult(i, to, false, NULL, true);
}
}
}
}
示例3: giftRadar
// ////////////////////////////////////////////////////////////////////////////
// give radar information
void giftRadar(uint8_t from, uint8_t to, bool send)
{
uint32_t dummy = 0;
if (send)
{
uint8_t subType = RADAR_GIFT;
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_GIFT);
NETuint8_t(&subType);
NETuint8_t(&from);
NETuint8_t(&to);
NETuint32_t(&dummy);
NETend();
}
// If we are recieving the gift
else
{
hqReward(from, to);
if (to == selectedPlayer)
{
CONPRINTF(ConsoleString, (ConsoleString, _("%s Gives You A Visibility Report"), getPlayerName(from)));
}
}
}
示例4: recvAlliance
BOOL recvAlliance(BOOL allowAudio)
{
uint8_t to, from, state;
int32_t value;
NETbeginDecode(NET_ALLIANCE);
NETuint8_t(&from);
NETuint8_t(&to);
NETuint8_t(&state);
NETint32_t(&value);
NETend();
switch (state)
{
case ALLIANCE_NULL:
break;
case ALLIANCE_REQUESTED:
requestAlliance(from, to, false, allowAudio);
break;
case ALLIANCE_FORMED:
formAlliance(from, to, false, allowAudio, true);
break;
case ALLIANCE_BROKEN:
breakAlliance(from, to, false, allowAudio);
break;
default:
debug(LOG_ERROR, "Unknown alliance state recvd.");
return false;
break;
}
return true;
}
示例5: recvLasSat
// recv lassat info on the receiving end.
BOOL recvLasSat(NETQUEUE queue)
{
BASE_OBJECT *psObj;
UBYTE player,targetplayer;
STRUCTURE *psStruct;
uint32_t id,targetid;
// TODO Add some kind of checking, so that things don't get lasatted by bunkers.
NETbeginDecode(queue, GAME_LASSAT);
NETuint8_t(&player);
NETuint32_t(&id);
NETuint32_t(&targetid);
NETuint8_t(&targetplayer);
NETend();
psStruct = IdToStruct (id, player);
psObj = IdToPointer(targetid, targetplayer);
if (psStruct && psObj)
{
// Give enemy no quarter, unleash the lasat
proj_SendProjectile(&psStruct->asWeaps[0], NULL, player, psObj->pos, psObj, true, 0);
psStruct->asWeaps[0].lastFired = gameTime;
// Play 5 second countdown message
audio_QueueTrackPos( ID_SOUND_LAS_SAT_COUNTDOWN, psObj->pos.x, psObj->pos.y, psObj->pos.z);
}
return true;
}
示例6: giftPower
// ////////////////////////////////////////////////////////////////////////////
// give Power
void giftPower(uint8_t from, uint8_t to, BOOL send)
{
UDWORD gifval;
uint32_t dummy = 0;
if (from == ANYPLAYER)
{
gifval = OILDRUM_POWER;
}
else
{
// Give 1/3 of our power away
gifval = getPower(from) / 3;
usePower(from, gifval);
}
addPower(to, gifval);
if (send)
{
uint8_t giftType = POWER_GIFT;
NETbeginEncode(NET_GIFT, NET_ALL_PLAYERS);
NETuint8_t(&giftType);
NETuint8_t(&from);
NETuint8_t(&to);
NETuint32_t(&dummy);
NETend();
}
else if (to == selectedPlayer)
{
CONPRINTF(ConsoleString,(ConsoleString,_("%s Gives You %u Power"),getPlayerName(from),gifval));
}
}
示例7: recvLasSat
// recv lassat info on the receiving end.
BOOL recvLasSat()
{
BASE_OBJECT *psObj;
UBYTE player,targetplayer;
STRUCTURE *psStruct;
uint32_t id,targetid;
NETbeginDecode(NET_LASSAT);
NETuint8_t(&player);
NETuint32_t(&id);
NETuint32_t(&targetid);
NETuint8_t(&targetplayer);
NETend();
psStruct = IdToStruct (id, player);
psObj = IdToPointer(targetid, targetplayer);
if (psStruct && psObj)
{
// Give enemy no quarter, unleash the lasat
proj_SendProjectile(&psStruct->asWeaps[0], NULL, player, psObj->pos, psObj, true, 0);
// Play 5 second countdown message
audio_QueueTrackPos( ID_SOUND_LAS_SAT_COUNTDOWN, psObj->pos.x, psObj->pos.y, psObj->pos.z);
}
return true;
}
示例8: giftAutoGame
static void giftAutoGame(uint8_t from, uint8_t to, bool send)
{
uint32_t dummy = 0;
if (send)
{
uint8_t subType = AUTOGAME_GIFT;
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_GIFT);
NETuint8_t(&subType);
NETuint8_t(&from);
NETuint8_t(&to);
NETuint32_t(&dummy);
NETend();
debug(LOG_SYNC, "We (%d) are telling %d we want to enable/disable a autogame", from, to);
}
// If we are recieving the "gift"
else
{
if (to == selectedPlayer)
{
NetPlay.players[from].autoGame = !NetPlay.players[from].autoGame ;
CONPRINTF(ConsoleString, (ConsoleString, "%s has %s the autoGame command", getPlayerName(from), NetPlay.players[from].autoGame ? "Enabled" : "Disabled"));
debug(LOG_SYNC, "We (%d) are being told that %d has %s autogame", selectedPlayer, from, NetPlay.players[from].autoGame ? "Enabled" : "Disabled");
}
}
}
示例9: recvPing
// accept and process incoming ping messages.
bool recvPing(NETQUEUE queue)
{
bool isNew = false;
uint8_t sender, us = selectedPlayer;
uint8_t challenge[sizeof(pingChallenge)];
EcKey::Sig challengeResponse;
NETbeginDecode(queue, NET_PING);
NETuint8_t(&sender);
NETbool(&isNew);
if (isNew)
{
NETbin(challenge, sizeof(pingChallenge));
}
else
{
NETbytes(&challengeResponse);
}
NETend();
if (sender >= MAX_PLAYERS)
{
debug(LOG_ERROR, "Bad NET_PING packet, sender is %d", (int)sender);
return false;
}
// If this is a new ping, respond to it
if (isNew)
{
challengeResponse = getMultiStats(us).identity.sign(&challenge, sizeof(pingChallenge));
NETbeginEncode(NETnetQueue(sender), NET_PING);
// We are responding to a new ping
isNew = false;
NETuint8_t(&us);
NETbool(&isNew);
NETbytes(&challengeResponse);
NETend();
}
// They are responding to one of our pings
else
{
if (!getMultiStats(sender).identity.empty() && !getMultiStats(sender).identity.verify(challengeResponse, pingChallenge, sizeof(pingChallenge)))
{
// Either bad signature, or we sent more than one ping packet and this response is to an older one than the latest.
debug(LOG_NEVER, "Bad and/or old NET_PING packet, alleged sender is %d", (int)sender);
return false;
}
// Work out how long it took them to respond
ingame.PingTimes[sender] = (realTime - PingSend[sender]) / 2;
// Note that we have received it
PingSend[sender] = 0;
}
return true;
}
示例10: sendGiftDroids
// sendGiftDroids()
// We give selected droid(s) as a gift to another player.
//
// \param from :player that sent us the droid
// \param to :player that should be getting the droid
static void sendGiftDroids(uint8_t from, uint8_t to)
{
DROID *next, *psD;
uint8_t giftType = DROID_GIFT;
uint8_t totalToSend;
if (apsDroidLists[from] == NULL)
{
return;
}
/*
* Work out the number of droids to send. As well as making sure they are
* selected we also need to make sure they will NOT put the receiving player
* over their droid limit.
*/
for (totalToSend = 0, psD = apsDroidLists[from];
psD && getNumDroids(to) + totalToSend < getMaxDroids(to) && totalToSend != UINT8_MAX;
psD = psD->psNext)
{
if (psD->selected)
++totalToSend;
}
/*
* We must send one droid at a time, due to the fact that giftSingleDroid()
* does its own net calls.
*/
for (psD = apsDroidLists[from]; psD && totalToSend != 0; psD = next)
{
// Store the next droid in the list as the list may change
next = psD->psNext;
if (psD->droidType == DROID_TRANSPORTER
&& !transporterIsEmpty(psD))
{
CONPRINTF(ConsoleString, (ConsoleString, _("Tried to give away a non-empty %s - but this is not allowed."), psD->aName));
continue;
}
if (psD->selected)
{
NETbeginEncode(NET_GIFT, NET_ALL_PLAYERS);
NETuint8_t(&giftType);
NETuint8_t(&from);
NETuint8_t(&to);
// Add the droid to the packet
NETuint32_t(&psD->id);
NETend();
// Hand over the droid on our sidde
giftSingleDroid(psD, to);
// Decrement the number of droids left to send
--totalToSend;
}
}
}
示例11: sendAlliance
void sendAlliance(uint8_t from, uint8_t to, uint8_t state, int32_t value)
{
NETbeginEncode(NET_ALLIANCE, NET_ALL_PLAYERS);
NETuint8_t(&from);
NETuint8_t(&to);
NETuint8_t(&state);
NETint32_t(&value);
NETend();
}
示例12: sendAlliance
void sendAlliance(uint8_t from, uint8_t to, uint8_t state, int32_t value)
{
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_ALLIANCE);
NETuint8_t(&from);
NETuint8_t(&to);
NETuint8_t(&state);
NETint32_t(&value);
NETend();
}
示例13: recvMultiPlayerRandomArtifacts
// ///////////////////////////////////////////////////////////////
// receive splattered artifacts
void recvMultiPlayerRandomArtifacts(NETQUEUE queue)
{
int count, i;
uint8_t quantity, player;
uint32_t tx,ty;
uint32_t ref;
FEATURE_TYPE type = FEAT_TREE; // Dummy initialisation.
FEATURE *pF;
NETbeginDecode(queue, GAME_ARTIFACTS);
NETuint8_t(&quantity);
NETenum(&type);
debug(LOG_FEATURE, "receiving %u artifact(s) type: (%s)", quantity, feature_names[type]);
for (i = 0; i < numFeatureStats && asFeatureStats[i].subType != type; i++) {}
for (count = 0; count < quantity; count++)
{
MAPTILE *psTile;
NETuint32_t(&tx);
NETuint32_t(&ty);
NETuint32_t(&ref);
NETuint8_t(&player);
if (tx == INVALID_XY)
{
continue;
}
else if (!tileOnMap(tx, ty))
{
debug(LOG_ERROR, "Bad tile coordinates (%u,%u)", tx, ty);
continue;
}
psTile = mapTile(tx, ty);
if (!psTile || psTile->psObject != NULL)
{
debug(LOG_ERROR, "Already something at (%u,%u)!", tx, ty);
continue;
}
pF = buildFeature((asFeatureStats + i), world_coord(tx), world_coord(ty), false);
if (pF)
{
pF->id = ref;
pF->player = player;
syncDebugFeature(pF, '+');
}
else
{
debug(LOG_ERROR, "Couldn't build feature %u for player %u ?", ref, player);
}
}
NETend();
}
示例14: SendDroid
// ////////////////////////////////////////////////////////////////////////////
// Send a new Droid to the other players
bool SendDroid(DROID_TEMPLATE *pTemplate, uint32_t x, uint32_t y, uint8_t player, uint32_t id, const INITIAL_DROID_ORDERS *initialOrdersP)
{
if (!bMultiMessages)
{
return true;
}
ASSERT_OR_RETURN(false, x != 0 && y != 0, "SendDroid: Invalid droid coordinates");
ASSERT_OR_RETURN(false, player < MAX_PLAYERS, "invalid player %u", player);
// Dont send other droids during campaign setup
if (ingame.localJoiningInProgress)
{
return true;
}
// Only send the droid if we are responsible
if (!myResponsibility(player))
{
// Don't build if we are not responsible
return false;
}
debug(LOG_SYNC, "Droid sent with id of %u", id);
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_DEBUG_ADD_DROID);
{
Position pos(x, y, 0);
bool haveInitialOrders = initialOrdersP != NULL;
int32_t droidType = pTemplate->droidType;
NETuint8_t(&player);
NETuint32_t(&id);
NETPosition(&pos);
NETqstring(pTemplate->name);
NETint32_t(&droidType);
NETuint8_t(&pTemplate->asParts[COMP_BODY]);
NETuint8_t(&pTemplate->asParts[COMP_BRAIN]);
NETuint8_t(&pTemplate->asParts[COMP_PROPULSION]);
NETuint8_t(&pTemplate->asParts[COMP_REPAIRUNIT]);
NETuint8_t(&pTemplate->asParts[COMP_ECM]);
NETuint8_t(&pTemplate->asParts[COMP_SENSOR]);
NETuint8_t(&pTemplate->asParts[COMP_CONSTRUCT]);
NETint8_t(&pTemplate->numWeaps);
for (int i = 0; i < pTemplate->numWeaps; i++)
{
NETuint8_t(&pTemplate->asWeaps[i]);
}
NETbool(&haveInitialOrders);
if (haveInitialOrders)
{
INITIAL_DROID_ORDERS initialOrders = *initialOrdersP;
NETuint32_t(&initialOrders.secondaryOrder);
NETint32_t(&initialOrders.moveToX);
NETint32_t(&initialOrders.moveToY);
NETuint32_t(&initialOrders.factoryId); // For making scripts happy.
}
}
debug(LOG_LIFE, "===> sending Droid from %u id of %u ", player, id);
return NETend();
}
示例15: sendLasSat
BOOL sendLasSat(UBYTE player, STRUCTURE *psStruct, BASE_OBJECT *psObj)
{
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_LASSAT);
NETuint8_t(&player);
NETuint32_t(&psStruct->id);
NETuint32_t(&psObj->id); // Target
NETuint8_t(&psObj->player); // Target player
return NETend();
}