void SendFile(char *dirname,char *filename,sdword fileSize) { FilePacket *pkt; pkt = CreateFilePacket(dirname,filename,fileSize); // for now, just broadcast pkt titanDebug("autodownloadmap: Sending file packet of size %d\n",sizeofFilePacketGivenPacket(pkt)); titanSendBroadcastMessage((ubyte *)pkt,sizeofFilePacketGivenPacket(pkt)); }
void receivedFilePacketCB(ubyte *packet,udword sizeofPacket) { titanDebug("autodownloadmap: Received file packet of size %d\n",sizeofFilePacketGivenPacket((FilePacket *)packet)); if (sigsPlayerIndex == 0) { titanDebug("autodownloadmap: WARNING: player 0 received file"); return; // throw away packet } #define fpacket ((FilePacket *)packet) // lets write file to filesystem, but don't use file.h since this is in another thread // and file.c, file.h is not reentrant (and we're not writing to a big file) { // let's create a directory if necessary char dirtomake[250]; char *findlastslashptr; strcpy(dirtomake,filePrependPath); strcat(dirtomake,fpacket->filename); findlastslashptr = &dirtomake[strlen(dirtomake)]; while (--findlastslashptr >= dirtomake) { if (*findlastslashptr == '\\') { *findlastslashptr = 0; break; } } dbgAssert(*findlastslashptr == 0); _mkdir(dirtomake); // try to make directory. If it already exists, this will fail, that's ok } dbgAssert(sizeofPacket == sizeofFilePacketGivenPacket(fpacket)); SaveFilePacketToFile(fpacket); autodownloadmapInfo.totalFilesToAutodownload = fpacket->totalNumFiles; autodownloadmapInfo.numFilesAutodownloaded++; #undef fpacket }
void titanLogFileOpen(void) { time_t now; char datestring[16]; if (logEnable) { logfileClear(TITAN_LOG_FILE_NAME); now = time(NULL); strftime(datestring, 16, "%a %b %d %Y", gmtime(&now)); titanDebug("Todays date is: %s", datestring); } }
void recievedHorsePacketCB(ubyte *packet,udword sizeofpacket) { //captain should have recieved a packet here... HorsePacket *hp = (HorsePacket *)packet; udword i; i = hp->playerindex; dbgAssertOrIgnore(i < MAX_MULTIPLAYER_PLAYERS); if (multiPlayerGame) { titanDebug("hr: recv hrpacket from %d status %d",i,playersReadyToGo[i]); if (!playerHasDroppedOutOrQuit(i)) { TTimerReset(&hrPlayerDropoutTimers[i]); } } hrDirtyProgressBar(); horseracestatus.barnum[i] = hp->barnum; horseracestatus.percent[i] = hp->percent; }