MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / GetFileNameFromPlayerAndID

Function GetFileNameFromPlayerAndID

Descent3/multi.cpp:8077–8134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8075}
8076
8077char *GetFileNameFromPlayerAndID(int16_t playernum, int16_t id) {
8078 static char rval[_MAX_PATH * 2];
8079
8080 rval[0] = '\0';
8081
8082 if (playernum >= MAX_NET_PLAYERS) {
8083 mprintf(0, "Invalid playernum (%d) passed to GetFileNameFromPlayerAndID()\n", playernum);
8084 return rval;
8085 }
8086 if (id > NETFILE_ID_LAST_FILE) {
8087 mprintf(0, "Invalid file id (%d) passed to GetFileNameFromPlayerAndID()\n", id);
8088 return rval;
8089 }
8090 switch (id) {
8091
8092 case NETFILE_ID_NOFILE:
8093 break;
8094 case NETFILE_ID_SHIP_TEX:
8095 if (NetPlayers[playernum].ship_logo[0])
8096 ddio_MakePath(rval, Base_directory, "custom", "graphics", NetPlayers[playernum].ship_logo, NULL);
8097 break;
8098 case NETFILE_ID_VOICE_TAUNT1:
8099 if (NetPlayers[playernum].voice_taunt1[0])
8100 ddio_MakePath(rval, Base_directory, "custom", "sounds", NetPlayers[playernum].voice_taunt1, NULL);
8101 break;
8102 case NETFILE_ID_VOICE_TAUNT2:
8103 if (NetPlayers[playernum].voice_taunt2[0])
8104 ddio_MakePath(rval, Base_directory, "custom", "sounds", NetPlayers[playernum].voice_taunt2, NULL);
8105 break;
8106 case NETFILE_ID_VOICE_TAUNT3:
8107 if (NetPlayers[playernum].voice_taunt3[0])
8108 ddio_MakePath(rval, Base_directory, "custom", "sounds", NetPlayers[playernum].voice_taunt3, NULL);
8109 break;
8110 case NETFILE_ID_VOICE_TAUNT4:
8111 if (NetPlayers[playernum].voice_taunt4[0])
8112 ddio_MakePath(rval, Base_directory, "custom", "sounds", NetPlayers[playernum].voice_taunt4, NULL);
8113 break;
8114 default:
8115 mprintf(0, "Unknown id (%d) passed to GetFileNameFromPlayerAndID()\n", id);
8116 Int3();
8117 break;
8118 }
8119 if (*rval) {
8120 CFILE *cfp;
8121 cfp = cfopen(rval, "rb");
8122 if (!cfp) {
8123 mprintf(0, "Multiplayer file xfer File does not exist, not using file %d for player %d!\n", id, playernum);
8124 // rval[0] = '\0';
8125 } else if (32768 < cfilelength(cfp)) {
8126 mprintf(0, "Multiplayer file xfer File to long, not using file %d for player %d!\n", id, playernum);
8127 rval[0] = '\0';
8128 }
8129 if (cfp)
8130 cfclose(cfp);
8131 }
8132
8133 return rval;
8134}

Callers 3

MultiAskForFileFunction · 0.85
MultiDoFileReqFunction · 0.85
MultiDoFileDataFunction · 0.85

Calls 4

cfopenFunction · 0.85
cfilelengthFunction · 0.85
cfcloseFunction · 0.85
ddio_MakePathFunction · 0.50

Tested by

no test coverage detected