예제 #1
0
void LocalPrefServer::processPlayerDrop(CardsSet drop, BidType deal)
{
	for( int i = 0; i < NumOfPlayers; i++ ) {
		players[mapModelToRealPlayer(i)].Player->OnMessage(
			DropMessage(deal, i == model->Dealer() ? drop : EmptyCardsSet));
	}
	notifyAll(DropMessage(deal, drop) );
}
예제 #2
0
 //------------------------------------------------------------------------------------------------------------------------------------
 bool __stdcall spiGetPerformanceData(DWORD dwType, DWORD *dwResult, int a3, int a4)
 {
   DropMessage(0, "spiGetPerformanceData");
   /*
   // Returns performance data in dwResult
   switch ( dwType )
   {
   case 12:    // Total number of calls made to sendto
     *dwResult = gdwSendCalls;
     return true;
   case 13:    // Total number of calls made to recvfrom
     *dwResult = gdwRecvCalls;
     return true;
   case 14:    // Total number of bytes sent using sendto
     *dwResult = gdwSendBytes;
     return true;
   case 15:    // Total number of bytes received using recvfrom
     *dwResult = gdwRecvBytes;
     return true;
   default:
     return false;
   }
   */
   return false;
 }
예제 #3
0
  //------------------------------------------------------------------------------------------------------------------------------------
  bool __stdcall spiSend(DWORD addrCount, SOCKADDR * *addrList, char *buf, DWORD bufLen)
  {
//    DropMessage(0, "spiSend %d", GetCurrentThreadId());

    if(!addrCount)
      return true;

    if(addrCount > 1)
      DropMessage(1, "spiSend, multicast not supported");

    try
    {
      // support for 1 peer for now
      SOCKADDR him = *(addrList[0]);

      // send packet over the network module
      pluggedNetwork->sendAsyn(him, Util::MemoryFrame(buf, bufLen));

      // debug
//      DropMessage(0, "Sent storm packet %d bytes", bufLen);
//      DropMessage(0, "S> %s", sprintfBytes(buf, bufLen));
    }
    catch(GeneralException &e)
    {
      DropLastError("spiSend failed: %s", e.getMessage());
      return false;
    }
    return true;
  }
예제 #4
0
파일: Output.cpp 프로젝트: AdesChacal/bwapi
void DropLastError(const char *format, ...)
{
  char szBuffer[256];
  va_list ap;
  va_start(ap, format);
  vsnprintf_s(szBuffer, 256, 256, format, ap);
  va_end(ap);

  DWORD dwErrCode = GetLastError();

  char szErrStr[256];
  SEGetErrorStr(dwErrCode, szErrStr);

  char szFinalStr[512];
  sprintf_s(szFinalStr, 512, "Error: 0x%x;%s;%s", dwErrCode, szBuffer, szErrStr);

  /*
  FILE *hLog = fopen(gszLogPath, "a+");
  if ( hLog )
  {
    fprintf(hLog, "%s\n------------\n", szFinalStr);
    fclose(hLog);
  }
  */
  //errorMsg(szFinalStr);
  DropMessage(2, szFinalStr);
}
예제 #5
0
 //------------------------------------------------------------------------------------------------------------------------------------
 bool __stdcall spiFreeExternalMessage(SOCKADDR * addr, char *data, DWORD databytes)
 {
   DropMessage(0, "spiFreeExternalMessage");
   /*
   // This function is complete
   SetLastError(ERROR_INVALID_PARAMETER);
   */
   return false;
 }
예제 #6
0
 //------------------------------------------------------------------------------------------------------------------------------------
 bool __stdcall spiSelectGame( int a1, 
                               client_info *gameClientInfo, 
                               user_info *userData, 
                               battle_info *bnCallbacks, 
                               module_info *moduleData, 
                               int a6)
 {
   DropMessage(0, "spiSelectGame");
   // Looks like an old function and doesn't seem like it's used anymore
   // UDPN's function Creates an IPX game select dialog window
   return false;
 }
예제 #7
0
TEST_F(ProtocolTest, testProtocols)
{
	testSharedMessages();
	testMessage(AddCaveMessage(1, false));
	testMessage(AddRopeMessage(1, 2));
	testMessage(LightStateMessage(1, false));
	testMessage(RemoveRopeMessage(1));
	testMessage(UpdateCollectedTypeMessage(EntityType::NONE, false));
	testMessage(WaterHeightMessage(1.0f));
	testMessage(WaterImpactMessage(1.0f, 1.0f));
	testMessage(DropMessage());
}
예제 #8
0
  //------------------------------------------------------------------------------------------------------------------------------------
  bool __stdcall spiReceive(SOCKADDR **senderPeer, char **data, DWORD *databytes)
  {
    INTERLOCKED;
//    DropMessage(0, "spiReceive %d", GetCurrentThreadId());
    // Passes pointers from queued receive data to storm

    *senderPeer = nullptr;
    *data       = nullptr;
    *databytes  = 0;

    try
    {
      pluggedNetwork->receive();

      while(true)
      {
        // check if packets available
        if(incomingGamePackets.empty())
        {
          SErrSetLastError(STORM_ERROR_NO_MESSAGES_WAITING);
          return false;
        }

        // save the packet before removing it from queue
        GamePacket *loan = new GamePacket();
        *loan = incomingGamePackets.front();
        incomingGamePackets.pop();

        // paket outdated?
        if(GetTickCount() > loan->timeStamp + 10000)
        {
          DropMessage(1, "Dropped outdated packet (%dms delay)", GetTickCount() - loan->timeStamp);
          continue;
        }

        // give saved data to storm
        *senderPeer =&loan->sender;
        *data       = loan->data;
        *databytes  = loan->packetSize;
//        DropMessage(0, "R %s", sprintfBytes(*data, *databytes));
//        DropMessage(0, "Received storm packet %d bytes", *databytes);
        break;
      }
    }
    catch(GeneralException &e)
    {
      DropLastError("spiLockGameList failed: %s", e.getMessage());
      return false;
    }
    return true;
  }
예제 #9
0
  //------------------------------------------------------------------------------------------------------------------------------------
  //------------------------------------------------------------------------------------------------------------------------------------
  void LocalPC::initialize()
  {
    INTERLOCKED;

    // init shared stuff
    bool just_created = session.create("Global\\LocalPC_Network_Memory");
    shd = &session.get();

    // if the shared memory was just created, init it
    if(just_created)
    {
      DropMessage(0, "Memory newly created");
      memset(shd, 0, sizeof(SharedData));
    }

    // reserve an index for oneself
    self = -1;
    for(int i = 0; i < 8; i++)
    {
      if(!shd->peer[i].isOccupied())
      {
        self = i;
        break;
      }
    }
    DropMessage(0, "self: %d", self);
    if(self == -1)
    {
      DropMessage(2, "could not reserve self. exiting");
      exit(1);
    }
    PeerData &selfData = shd->peer[self];
    selfData.lastOccupied = GetTickCount();
    selfData.isAdvertising = false;
    selfData.incomingCount = 0;

  }
예제 #10
0
  void LocalPC::sendAsyn(const int& him, Util::MemoryFrame packet)
  {
    processIncomingPackets();

    if(!shd->peer[him].isOccupied())
      return;

    INTERLOCKED;
    // push the packet on target's packetqueue
    PeerData &peerData = shd->peer[him];
    int slotIndex = peerData.incomingCount++;
    if(slotIndex >= 16)
    {
      DropMessage(1, "stacked 16 packets, no space");
      return;
    }
    if(packet.size() > 508)
    {
      DropMessage(1, "packet bigger than 508 bytes (%d), being cut", packet.size());
    }
    Util::MemoryFrame::from(peerData.incoming[slotIndex].data).write(packet);
    peerData.incoming[slotIndex].length = packet.size();
    peerData.incoming[slotIndex].sender = self;
  }
예제 #11
0
  //------------------------------------------------------------------------------------------------------------------------------------
  bool __stdcall spiCompareNetAddresses(SOCKADDR * addr1, SOCKADDR * addr2, DWORD *dwResult)
  {
    INTERLOCKED;
    DropMessage(0, "spiCompareNetAddresses");

    if ( dwResult )
      *dwResult = 0;
    if ( !addr1 || !addr2 || !dwResult )
    {
      SErrSetLastError(ERROR_INVALID_PARAMETER);
      return false;
    }

    *dwResult = (0 == memcmp(addr1, addr2, sizeof(SOCKADDR)));
    return true;
  }
예제 #12
0
static Boolean ParseMessage(queuedData *qd) {
    /* Fill in all the information we'll need to execute the message as
       quickly as possible when the time comes.  This means figuring out where
       the address ends and the arguments begin, and also pattern matching the
       address to find the callbacks associated with it.

       The message may be something we have to invoke now, or it may be some
       message scheduled for the future that's just waiting on the queue; this
       procedure doesn't care.  */


    char *args; 	/* char * so we can do pointer subtraction */
    int messageLen;
    char *DAAS_errormsg;


    if (qd->type != MESSAGE) {
        fatal_error("This can't happen: message isn't a message!");
    }

    args = OSCDataAfterAlignedString(qd->data.message.messageName, 
				     qd->data.message.messageName+qd->data.message.length,
				     &DAAS_errormsg);

    if (args == 0) {
	OSCProblem("Bad message name string: %s\n", DAAS_errormsg);
	DropMessage(qd->data.message.messageName, qd->data.message.length, qd->myPacket);
	return FALSE;
    }

    qd->data.message.args = args;
    messageLen = args - qd->data.message.messageName;
    qd->data.message.argLength = qd->data.message.length - messageLen;

    qd->data.message.callbacks = OSCDispatchMessage(qd->data.message.messageName);

    if (qd->data.message.callbacks == 0) {
	OSCWarning("Message pattern \"%s\" did not correspond to any address in the synth.",
		   qd->data.message.messageName);
	return FALSE;
    }

    return TRUE;
}
예제 #13
0
Boolean OSCBeProductiveWhileWaiting(void) {
    /* Here's where we could be clever if an allocation fails. 
       (I.e., if we're out of QD objects, we should avoid
       parsing bundles.) The code isn't that smart yet. */

    queuedData *qd;

    if (globals.timePassed) {
	OSCQueueScanStart(globals.TheQueue);
    }

    while (1) {
	qd = (queuedData *) OSCQueueScanNext(globals.TheQueue);
	if (qd == 0) return FALSE;

	if (qd->type == BUNDLE) {
            ParseBundle(qd);
	    OSCQueueRemoveCurrentScanItem(globals.TheQueue);
	    return TRUE;
	} else {
	    if (qd->data.message.callbacks == NOT_DISPATCHED_YET) {
                if (ParseMessage(qd) == FALSE) {
                    /* Problem with this message - flush it. */
		    DropMessage(qd->data.message.messageName,
				qd->data.message.length,
				qd->myPacket);
		    OSCQueueRemoveCurrentScanItem(globals.TheQueue);
		    PacketRemoveRef(qd->myPacket);
                    FreeQD(qd);
		}
		return TRUE;
	    }
	    /* The item we found was an already-dispatched message,
	       so continue the while loop. */
	}
    }
}
예제 #14
0
 //------------------------------------------------------------------------------------------------------------------------------------
 bool __stdcall spiLeagueGetName(char *pszDest, DWORD dwSize)
 {
   DropMessage(0, "spiLeagueGetName");
   // This function is complete
   return true;
 }
예제 #15
0
 //------------------------------------------------------------------------------------------------------------------------------------
 bool __stdcall spiSendExternalMessage(int a1, int a2, int a3, int a4, int a5)
 {
   DropMessage(0, "spiSendExternalMessage");
   // This function is complete
   return false;
 }
예제 #16
0
 //------------------------------------------------------------------------------------------------------------------------------------
 bool __stdcall spiInitializeDevice(int a1, void *a2, void *a3, DWORD *a4, void *a5)
 {
   DropMessage(0, "spiInitializeDevice");
   // This function is complete
   return false;
 }
예제 #17
0
static void InsertBundleOrMessage(char *buf, int n, OSCPacketBuffer packet, OSCTimeTag enclosingTimeTag) {
    Boolean IsBundle;
    queuedData *qd;

    /* We add the reference first thing so in case any of the upcoming
       potential failure situations come we can call PacketRemoveRef, thereby
       freeing the packet if necessary. */
    PacketAddRef(packet);

#ifdef PARANOID
    if ((n % 4) != 0) {
	OSCProblem("OSC message or bundle size (%d bytes) not a multiple of 4.", n);
	DropMessage(buf, n, packet)
	PacketRemoveRef(packet);
	return;
    }
#endif

    if ((n >= 8) && (strncmp(buf, "#bundle", 8) == 0)) {
	IsBundle = TRUE;

	if (n < 16) {
	    OSCProblem("Bundle message too small (%d bytes) for time tag.", n);
	    DropBundle(buf, n, packet);
	    PacketRemoveRef(packet);
	    return;
	}
    } else {
	IsBundle = FALSE;
    }


    qd = AllocQD();

    if (qd == 0) {
	OSCProblem("Not enough memory for queued data!");
	DropBundle(buf, n, packet);
	PacketRemoveRef(packet);
	return;
    }

    qd->myPacket = packet;
    qd->type = IsBundle ? BUNDLE : MESSAGE;

    if (IsBundle) {
	/* Be careful of 8-byte alignment when copying the time tag.  Here's a good
	   way to get a bus error when buf happens not to be 8-byte aligned:
	   qd->timetag = *((OSCTimeTag *)(buf+8));
	*/
	memcpy(&(qd->timetag), buf+8, sizeof(OSCTimeTag));

	if (OSCTT_Compare(qd->timetag, enclosingTimeTag) < 0) {
	    OSCProblem("Time tag of sub-bundle is before time tag of enclosing bundle.");
	    DropBundle(buf, n, packet);
	    PacketRemoveRef(packet);
	    FreeQD(qd);
	    return;
	}
	qd->data.bundle.bytes = buf + 16;
	qd->data.bundle.length = n - 16;
    } else {
        qd->timetag = enclosingTimeTag;
	qd->data.message.messageName = buf;
	qd->data.message.length = n;
	qd->data.message.callbacks = NOT_DISPATCHED_YET;
    }

    OSCQueueInsert(globals.TheQueue, (OSCSchedulableObject) qd);
}
예제 #18
0
int InventoryManager::InventoryCommand(bool *keys)
{
    if (keys[VC_X] || keys[VK_ESC]) //inventory look
    {
        keys[VK_ESC] = false;
        keys[VC_X] = false;

        if (mState == eEquip || mState == eDrop)
        {
            ShowInventory(-1);
            mState = eDisplay;
            return 1;
        }
        else if (mState == eDisplay)
        {
            return 0;
        }
    }

    else if (mState == eEquip)
    {
        int ret = Equip(keys);
        if (ret)
            return ret;
    }

    else if (mState == eDrop)
    {
        int ret = Drop(keys);
        if (ret)
            return ret;
    }

    else if (keys[VK_U]) //equip/unequip
    {
        EquipMessage();
        mState = eEquip;
        keys[VK_U] = false;
    }

    else if (keys[VK_D]) //drop
    {
        DropMessage();
        mState = eDrop;
        keys[VK_D] = false;
    }

    else if (keys[VK_E]) //toggle keys
    {
        mShowEquip = true;
        mShowAll = mShowInv = false;

        ShowInventory(1);
        keys[VK_E] = false;
    }
    else if (keys[VK_I]) //toggle keys
    {
        mShowInv = true;
        mShowAll = mShowEquip = false;
        ShowInventory(0);
        keys[VK_E] = false;
    }
    else if (keys[VK_A]) //toggle keys
    {
        mShowAll = !mShowAll;
        ShowInventory(-1);
        keys[VK_E] = false;
    }

    return 1;
}