コード例 #1
0
ファイル: UserProfile.cpp プロジェクト: Mateuus/srcundead
void CClientUserProfile::GenerateSessionKey(char* outKey)
{
	char sessionInfo[128];
	sprintf(sessionInfo, "%d:%d", CustomerID, SessionID);
	for(size_t i=0; i<strlen(sessionInfo); ++i)
		sessionInfo[i] = sessionInfo[i]^0x64;
	
	CkString str;
	str = sessionInfo;
	str.base64Encode("utf-8");
	
	strcpy(outKey, str.getUtf8());
	return;
}
コード例 #2
0
ファイル: WOLoginHelper.cpp プロジェクト: Mateuus/srcundead
void CLoginHelper::CreateAuthToken(char* token) const
{
	char sessionInfo[512];
	sprintf(sessionInfo, "%d:%d:%d", CustomerID, SessionID, AccountStatus);

	for(size_t i=0; i<strlen(sessionInfo); ++i)
		sessionInfo[i] = sessionInfo[i] ^ 0x64;
        
	CkString encoded;
	encoded = sessionInfo;
	encoded.base64Encode("utf-8");
      
	strcpy(token, encoded.getAnsi());
	return;
}
コード例 #3
0
ファイル: SupervisorServer.cpp プロジェクト: Mateuus/devsrc
void CSupervisorServer::StartGame(const SBPKT_M2S_StartGameReq_s& n)
{
  r3dCSHolder cs1(csGames_);

  const int slot = n.port - gSupervisorConfig->portStart_;
  if(slot < 0 || slot >= gSupervisorConfig->maxGames_) {
    r3dOutToLog("!!!warning!!! invalid StartGame request port %d", n.port);
    return;
  }
  
  if(games_[slot].hProcess != 0) {
    r3dOutToLog("!!!warning!!! invalid StartGame request, slot %d already used\n", slot);

    // this may be because of previous instance crash, so terminate it
    TerminateProcess(games_[slot].hProcess, 0);
    games_[slot].Reset();
  }
  
  r3dOutToLog("StartGame %I64x slot:%d, users:%d, id:%08x, creatorID:%u\n", n.sessionId, slot, n.ginfo.maxPlayers, n.gameId, n.creatorID); CLOG_INDENT;

  games_[slot].Init(n.gameId, n.sessionId);
  
  STARTUPINFO si;
  ZeroMemory(&si, sizeof(si));
  si.cb = sizeof(si);
  PROCESS_INFORMATION pi;
  ZeroMemory(&pi, sizeof(pi));

  char arg1[128];
  char arg2[128];
  char arg3[128];
  sprintf(arg1, "%u %u %u", n.gameId, n.port, n.creatorID);
  n.ginfo.ToString(arg2);
  r3dscpy(arg3, gSupervisorConfig->masterIp_.c_str());
  
  CkString ckGameName;
   CkString ckGamepwd;
  ckGameName.setString(n.ginfo.name);
  ckGameName.base64Encode("utf-8");
//   ckGamepwd.setString(n.ginfo.IsPassword);
  //ckGamepwd.base64Encode("utf-8");
  
  char argfap[128];
  sprintf(argfap,arg2);
  sprintf(arg2,"%d %s %d",(int)n.ginfo.ispre,argfap,(int)n.ginfo.ispass);
  char params[512];
  sprintf(params, "\"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%d\"", 
    gSupervisorConfig->gameServerExe_.c_str(), 
    arg1, 
    arg2,
    arg3,
    ckGameName.getString(),
    gSupervisorConfig->uploadLogs_
    );
  
  r3dOutToLog("CreateProcess: %s\n", params);
  BOOL res = CreateProcess(
    NULL,
    params,
    NULL,
    NULL,
    FALSE,
    DETACHED_PROCESS, // no console by default, if needed game server will alloc it
    NULL,
    NULL,
    &si,
    &pi);
    
  if(res == 0) {
    r3dOutToLog("!!!warning!!! unable to spawn game servers, hr:%d\n", GetLastError());
    games_[slot].Reset();
    return;
  }
  
  // set process handle
  games_[slot].hProcess = pi.hProcess;
  
  return;
}