diff --git a/RP_L4/RPL4CONSOLE.cpp b/RP_L4/RPL4CONSOLE.cpp index d270f9a..0deaf43 100644 --- a/RP_L4/RPL4CONSOLE.cpp +++ b/RP_L4/RPL4CONSOLE.cpp @@ -164,6 +164,46 @@ namespace pod->connection, packet, (int) sizeof(NetworkPacketHeader) + size); } + //--------------------------------------------------------------- + // The same packet, delivered to the station on this machine. + // + // A real pod bay console sits on its own machine and every station + // hears it over the wire. Here it is colocated, and the network stack + // is quite right not to push bytes through a socket to reach a client + // in the same process - but the console had gone further than that and + // called application->Dispatch, stepping past the client's receive + // entry altogether. Anything watching packets therefore never saw the + // console speak: the first Live Cam recording held all 14,342 of the + // racer's packets and not one LoadMission, RunMission or StopMission, + // because those were the messages that came from inside the house. + // + // So build the packet SendWire would have built and hand it to the + // client's own front door. No socket, no wire, no copy of the protocol + // - just the delivery arriving where a delivery arrives. + //--------------------------------------------------------------- + void DeliverLocal(int client_ID, const void *message, int size) + { + char packet[sizeof(NetworkPacketHeader) + 1400]; + + if (size > (int) sizeof(packet) - (int) sizeof(NetworkPacketHeader)) + { + return; + } + memset(packet, 0, sizeof(NetworkPacketHeader)); + + NetworkPacketHeader *header = (NetworkPacketHeader *) packet; + + header->clientID = (NetworkClient::ClientID) client_ID; + header->gameID = 0; + header->fromHost = 1; // the console's reserved host ID + memcpy(packet + sizeof(NetworkPacketHeader), message, size); + + NetworkPacket *received = (NetworkPacket *) packet; + + Check(application); + application->ReceiveNetworkPacket(received, &received->messageData); + } + void SendEggTo(RemotePod *pod) { int chunk_count = (gEggWireSize + 999) / 1000; @@ -348,7 +388,11 @@ namespace DEBUG_STREAM << "LocalConsole: stopping local pod\n" << std::flush; InterlockedExchange(&gMissionRunning, 0); Application::StopMissionMessage message(0); - application->Dispatch(&message); + DeliverLocal( + NetworkClient::ApplicationClientID, + &message, + (int) message.messageLength + ); gPhase = PhaseStopped; } @@ -455,7 +499,11 @@ namespace &run, (int) run.messageLength); } Application::RunMissionMessage local_run; - application->Dispatch(&local_run); + DeliverLocal( + NetworkClient::ApplicationClientID, + &local_run, + (int) local_run.messageLength + ); gRunSent = True; } }