int msgBoardSerial  = 0;
void MsgBoardOpenPost( int s ){	// READ IN bbp FILE  (Client dbl-clicked on posted message on message board list)	// Get Message Board serial number from message buffer		// 50 chars for prefix and 4 for the extension plus the ending NULL	char fileName[256] = "";	FILE *file = NULL;		unsigned long loopexit4=0,loopexit2=0;	int msgSN           = 0;	int msgBoardSerial  = 0;	int msgBytes        = 0;	int dateBytes       = 0;	int authorBytes     = 0;	int subjectBytes    = 0;	int foundMsg        = 0;	int x, y, z;			// Calculate the messages SN to determine which file to open	// GLOBAL   Posts start at 01 00 00 00 -> 01 FF FF FF	// REGIONAL Posts start at 02 00 00 00 -> 02 FF FF FF	// LOCAL    Posts start at 03 00 00 00 -> 03 FF FF FF		// If a MSBBOARDPATH has been define in the SERVER.SCP file, then use it	if (SrvParms->msgboardpath)		strcpy( fileName, SrvParms->msgboardpath );			msgSN = calcserial(buffer[s][8], buffer[s][9], buffer[s][10], buffer[s][11]);		// Is msgSN within the GLOBAL post range	if ( (msgSN>=0x01000000) && (msgSN<=0x01FFFFFF) )	{#ifdef DEBUG		sysmessage( s, "Opening GLOBAL.bbp posting");#endif		strcat( fileName, "global.bbp" );		file = fopen( fileName, "rb" );	}	// Is msgSN within the REGIONAL post range	else if ( (msgSN>=0x02000000) && (msgSN<=0x02FFFFFF) )	{#ifdef DEBUG		sysmessage( s, "Opening REGIONAL.bbp posting");#endif		P_ITEM msgBoardSerial = FindItemBySerial(calcserial(buffer[s][4], buffer[s][5], buffer[s][6], buffer[s][7]));		sprintf( (char*)temp, "region%d.bbp", calcRegionFromXY(msgBoardSerial->pos.x, msgBoardSerial->pos.y) );		strcat( fileName,(char*) temp );		file = fopen( fileName, "rb" );	}	// Is msgSN within the LOCAL post range	else if ( (msgSN>=0x03000000) && (msgSN<=0xFFFFFFFF) )	{#ifdef DEBUG		sysmessage( s, "Opening LOCAL.bbp posting");#endif		sprintf( (char*)temp, "%02x%02x%02x%02x.bbp", buffer[s][4], buffer[s][5], buffer[s][6], buffer[s][7]);		strcat( fileName, (char*)temp );		file = fopen( fileName, "rb" );	}	// This msgSN does not fall within a valid range	else	{		clConsole.send("WOLFPACK: MsgBoardOpenPost() Invalid message SN: %02x%02x%02x%02x", buffer[s][8], buffer[s][9], buffer[s][10], buffer[s][11] );		sysmessage( s, "Post not valid, please notify GM");		return;	}		if (file == NULL) return;   // Put file not found error control here	if (feof(file)) return;     // Put end of file error control here		// Find Message ID that has been requested	while ( !foundMsg && (++loopexit4 < MAXLOOPS)) 	{		//                                0       1     2      3      4   5   6      7   8    9    10   11   12   13   14   15		// Read In the first 12 bytes |PacketID|Size1|Size2|MsgType|bSn1|bSn2|bSn3|bSn4|mSn1|mSn2|mSn3|mSn4|pmSN|pmSN|pmSN|pmSN|		for ( x=0; x<12; x++)			msg[x] = fgetc( file );				// If we have reached the EOF then stop searching		if ( feof(file) )		{			clConsole.send("WOLFPACK: MsgBoardEvent() case 3: message not found \n");			break;		}				// Find post that was ACK'd by client		if (( msg[8]  == buffer[s][8] ) &&			( msg[9]  == buffer[s][9] ) &&			( msg[10] == buffer[s][10]) &&			( msg[11] == buffer[s][11]))		{			// Don't forget to set the flag to stop searching for the message when we find it			foundMsg = 1;						// Jump ahead 4 bytes in bbp file to skip 			// the parent message serial number section as it is not required			if ( fseek(file, 4, SEEK_CUR) )				clConsole.send("WOLFPACK: MsgBoardEvent() case 3 : failed to seek Author segment\n");						// Read in  author, subject and date info to pass back to client (DO NOT SEND BODY of msg)			// Count the total number of bytes in posting (not including body as it isn't sent to client)			msgBytes = x;						// Get size of Author segment			msg[msgBytes] = fgetc( file );			if ( feof(file) ) return;			msgBytes++;						// Store size of Author segment			authorBytes = msg[msgBytes-1];						// Fill in msg[] with Author data			for ( x=0; x<authorBytes; x++)			{				msg[msgBytes+x] = fgetc( file );				if ( feof(file) ) return;			}			msgBytes += x;			// Get size of Subject segment			msg[msgBytes] = fgetc( file );			if ( feof(file) ) return;			msgBytes++;						// Store size of Subject segment			subjectBytes = msg[msgBytes-1];						// Fill in msg[] with Subject data			for ( x=0; x<subjectBytes; x++)			{				msg[msgBytes+x] = fgetc( file );				if ( feof(file) ) return;			}			msgBytes += x;						// Get size of Date segment			msg[msgBytes] = fgetc( file );			if ( feof(file) ) return;			msgBytes++;						// Store size of Date segment			dateBytes = msg[msgBytes-1];						// Fill in msg[] with Date data			for ( x=0; x<dateBytes; x++)			{				msg[msgBytes+x] = fgetc( file );				if ( feof(file) ) return;			}			msgBytes += x;						// Weird stuff ???  don't know what it does...  Always has to be some thing to screw stuff up.			// but if it isn't inserted into the message..... KABOOM!!!  no more client (page faults the client!)			// 29 bytes			char weird[30]="\x01\x90\x83\xea\x06\x15\x2e\x07\x1d\x17\x0f\x07\x37\x1f\x7b\x05\xeb\x20\x3d\x04\x66\x20\x4d\x04\x66\x0e\x75\x00\x00";						// Fill in weird portion between DATE and BODY			for ( x=0; x<29; x++ )				msg[msgBytes+x] = weird[x];						msgBytes += x;			// Hope this works!!!			// Yup it worked!   Whew, thats a load off...									// Get the messages body info (body section, body size, body data)			z = fgetc( file );     // Total number of NULL's in Body of message			msg[msgBytes] = z;			msgBytes++;						loopexit2=0;			while (z 	&& (++loopexit2 < MAXLOOPS) )  // Loop until number of remaining NULLS equal zero			{				y = fgetc( file );     // Get the FIRST Body segment size				if ( feof(file) )				{					fclose( file );					file = NULL;					break;				}								msg[msgBytes] = y;				msgBytes++;								// Get Body segment into msg[] ( continue until 0x00 reached )				for ( x=0; x<y; x++ )				{					msg[msgBytes+x] = fgetc( file );				}								msgBytes += x;								// Decrement NULL count (processed one segment of the Body)				z--;			}						msg[1] = msgBytes/256;			msg[2] = msgBytes%256;			msg[3] = 2;              // Set packet 0x71 message type to 0x02 (send full message)   }   else // If this isn't the message were looking for, jump ahead to next message   {	   // Since we didn't find the message in this pass, get this messages size and jump ahead	   msgBytes += (msg[1]*256) + msg[2];	   	   // Jump to next message	   if ( fseek(file, msgBytes, SEEK_SET) )		   clConsole.send("WOLFPACK: MsgBoardEvent() case 3 : failed to seek next message\n");   }     }// End of while loop    // Close bbp file and return  fclose(file);  file = NULL;    // Send message to client  Xsend(s, msg, msgBytes);}