Exemplo n.º 1
0
	/*
	* Class:     aflobby_CUnitSyncJNIBindings
	* Method:    GetMapChecksum
	* Signature: (I)I
	*/
	JNIEXPORT jstring JNICALL Java_aflobby_CUnitSyncJNIBindings_GetMapChecksum
		(JNIEnv *env, jclass myobject, jint index){
			char* c = new char[15];
			int i = GetMapChecksum(index);
			sprintf(c,"%u",i);
			return env->NewStringUTF((const char*)c);
		}
Exemplo n.º 2
0
void CPreGame::UpdateClientNet()
{
	int a;
	if((a=net->GetData(&inbuf[inbuflength],15000-inbuflength,0))==-1){
		globalQuit=true;
		return;
	}
	inbuflength+=a;

	while(inbufpos<inbuflength){
		switch (inbuf[inbufpos]){
		case NETMSG_HELLO:
			inbufpos += 1;
			break;

		case NETMSG_SCRIPT:
			CScriptHandler::SelectScript((char*)(&inbuf[inbufpos+2]));
			if (mapName.empty()) state = WAIT_ON_MAP;
			else if (modName.empty()) state = WAIT_ON_MOD;
			else state = ALL_READY;
			inbufpos += inbuf[inbufpos+1];
			break;

		case NETMSG_MAPNAME:
			SelectMap((char*)(&inbuf[inbufpos+6]));
			if (GetMapChecksum() != *(unsigned*)(&inbuf[inbufpos+2])) {
				char buf[256];
				sprintf(buf, "Local map archive(s) are not binary equal to host map archive(s).\n"
						"Make sure you installed all map dependencies & consider redownloading the map."
						"\n\nLocal checksum = %u\nRemote checksum = %u", GetMapChecksum(), *(unsigned*)(&inbuf[inbufpos+2]));
				throw content_error(buf);
			}
			if (!CScriptHandler::Instance().chosenScript) state = WAIT_ON_SCRIPT;
			else if (modName.empty()) state = WAIT_ON_MOD;
			else state = ALL_READY;
			inbufpos += inbuf[inbufpos+1];
			break;

		case NETMSG_MODNAME:
			SelectMod((char*)(&inbuf[inbufpos+6]));
			if (GetModChecksum() != *(unsigned*)(&inbuf[inbufpos+2])) {
				char buf[256];
				sprintf(buf, "Local mod archive(s) are not binary equal to host mod archive(s).\n"
						"Make sure you installed all mod dependencies & consider redownloading the mod."
						"\n\nLocal checksum = %u\nRemote checksum = %u", GetModChecksum(), *(unsigned*)(&inbuf[inbufpos+2]));
				throw content_error(buf);
			}
			if (!CScriptHandler::Instance().chosenScript) state = WAIT_ON_SCRIPT;
			else if (mapName.empty()) state = WAIT_ON_MAP;
			else state = ALL_READY;
			inbufpos += inbuf[inbufpos+1];

		case NETMSG_MAPDRAW:
			inbufpos += inbuf[inbufpos+1];	
			break;

		case NETMSG_SYSTEMMSG:
		case NETMSG_CHAT:{
			int player=inbuf[inbufpos+2];
			string s=(char*)(&inbuf[inbufpos+3]);
			logOutput.Print(s);
			inbufpos += inbuf[inbufpos+1];	
			break;}

		case NETMSG_STARTPOS:{
			inbufpos += 15;
			break;}

		case NETMSG_SETPLAYERNUM:
			gu->myPlayerNum=inbuf[inbufpos+1];
			logOutput.Print("Became player %i",gu->myPlayerNum);
			inbufpos += 2;
			break;

		case NETMSG_PLAYERNAME:
			gs->players[inbuf[inbufpos+2]]->playerName=(char*)(&inbuf[inbufpos+3]);
			gs->players[inbuf[inbufpos+2]]->readyToStart=true;
			gs->players[inbuf[inbufpos+2]]->active=true;
			inbufpos += inbuf[inbufpos+1];
			break;

		case NETMSG_QUIT:
			net->connected=false;
			globalQuit=true;
			return;

		case NETMSG_USER_SPEED:
		case NETMSG_INTERNAL_SPEED:
			inbufpos += 5;
			break;
		default:
			char txt[200];
			sprintf(txt,"Unknown net msg in client %d",(int)inbuf[inbufpos]);
			handleerror(0,txt,"Network error in CPreGame",0);
			inbufpos++;
			break;
		}
	}
}