MCPcopy Create free account
hub / github.com/bwapi/bwapi / vSendTextEx

Method vSendTextEx

bwapi/BWAPI/Source/BWAPI/GameImpl.cpp:437–509  ·  view source on GitHub ↗

--------------------------------------------- SEND TEXT --------------------------------------------------

Source from the content-addressed store, hash-verified

435 }
436 //--------------------------------------------- SEND TEXT --------------------------------------------------
437 void GameImpl::vSendTextEx(bool toAllies, const char *format, va_list arg)
438 {
439 // safety
440 if ( !format ) return;
441
442 // Expand format and store in buffer
443 char buffer[80]; // Use maximum size of 80 since there is a hardcoded limit in Broodwar of 80 characters
444 VSNPrintf(buffer, format, arg);
445
446 // Check if tournament module allows sending text
447 if ( !this->tournamentCheck(Tournament::SendText, buffer) )
448 return;
449
450 if ( buffer[0] == '/' ) // If we expect a battle.net command
451 {
452 SNetSendServerChatCommand(buffer);
453 return;
454 }
455
456 if ( this->isReplay() ) // Just print the text if in a replay
457 {
458 Broodwar << buffer << std::endl;
459 return;
460 }
461
462 // If we're in single player
463 if ( this->isInGame() && !this->isMultiplayer() )
464 {
465 BW::CheatFlags::Enum cheatID = BW::getCheatFlag(buffer);
466 if ( cheatID != BW::CheatFlags::None ) // Apply cheat code if it is one
467 {
468 this->cheatFlags ^= cheatID;
469 QUEUE_COMMAND(BW::Orders::UseCheat, this->cheatFlags);
470 if (cheatID == BW::CheatFlags::ShowMeTheMoney ||
471 cheatID == BW::CheatFlags::BreatheDeep ||
472 cheatID == BW::CheatFlags::WhatsMineIsMine ||
473 cheatID == BW::CheatFlags::SomethingForNothing)
474 this->cheatFlags ^= cheatID;
475 }
476 else // Just print the message otherwise
477 {
478 Broodwar << this->BWAPIPlayer->getTextColor() << this->BWAPIPlayer->getName()
479 << ": " << Text::Green << buffer << std::endl;
480 }
481 } // single
482 else // multiplayer or lobby
483 {
484 // Otherwise, send the message using Storm command
485 char szMessage[82];
486 szMessage[0] = 0;
487 szMessage[1] = 1;
488 int msgLen = SStrCopy(&szMessage[2], buffer, 80);
489
490 if ( this->isInGame() ) // in game
491 {
492 if ( toAllies ) // Send to all allies
493 {
494 for (int i = 0; i < BW::PLAYABLE_PLAYER_COUNT; ++i)

Callers 3

vSendTextMethod · 0.45
sendTextMethod · 0.45
sendTextExMethod · 0.45

Calls 9

tournamentCheckMethod · 0.95
isReplayMethod · 0.95
isInGameMethod · 0.95
isMultiplayerMethod · 0.95
getCheatFlagFunction · 0.85
getTextColorMethod · 0.80
VSNPrintfFunction · 0.50
getNameMethod · 0.45
isAllyMethod · 0.45

Tested by

no test coverage detected