Exemple #1
0
int  CGameDBSocket::TransMsg(CRecvMsgPacket& recv_packet)
{
	FinishMsg(recv_packet.m_XYID,recv_packet.GetMsgTransLen());

	int nRet = 0;
	switch( recv_packet.m_XYID )
	{
	case PublicXY::Resp_Heart::XY_ID:
		{
			OnRespHeart(recv_packet);
		}
		break;
	case DBServerXY::DBS_RespServerConnectData::XY_ID:
	case DBServerXY::DBS_RespRoomTableInfo::XY_ID:
	case DBServerXY::DBS_BotPlayerData::XY_ID:
	case DBServerXY::DBS_RespBotPlayer::XY_ID:
	case DBServerXY::DBS_UserFriendInfo::XY_ID:
	case DBServerXY::DBS_UserAwardInfoList::XY_ID:
	case DBServerXY::DBS_UserHuiYuan::XY_ID:
	case DBServerXY::DBS_UserMoguiExchange::XY_ID:
	case DBServerXY::DBS_UserGiftInfoList::XY_ID:		
	case DBServerXY::DBS_UserGiftInfo::XY_ID:
	case DBServerXY::DBS_FaceInfoList::XY_ID:			
	case DBServerXY::DBS_GiftInfoList::XY_ID:
	case DBServerXY::DBS_MatchInfo::XY_ID:
	case DBServerXY::DBS_RoomInfo::XY_ID:
	case DBServerXY::DBS_TableInfo::XY_ID:
	case DBServerXY::DBS_RespServerPlayerLoginData::XY_ID:
	case DBServerXY::DBS_PlayerData::XY_ID:
	case DBServerXY::DBS_PlayerLimite::XY_ID:
	case DBServerXY::DBS_PlayerRight::XY_ID:
	case DBServerXY::DBS_ReqPlayerOnLine::XY_ID:
	case DBServerXY::DBS_RespPlayerInfo::XY_ID:
	case DBServerXY::DBS_PlayerMoneyCheck::XY_ID:
	case DBServerXY::DBS_RespAddBotMoney::XY_ID:
	case DBServerXY::WDB_RespWinLoss::XY_ID:
	case DBServerXY::WDB_RespWinLossList::XY_ID:
	case DBServerXY::DBS_RespPlayerGameMoney::XY_ID:
	case DBServerXY::DBS_To_GS_Flag::XY_ID:
	case DBServerXY::WDB_RespFinishHonor::XY_ID:
	case PublicXY::BatchProtocol::XY_ID:
	case MOGUI_XieYiList:
		{
			nRet = m_pServer->OnDBServerMsg(this,recv_packet);
		}
		break;
	default:
		{
			printf_s("CGameDBSocket:未处理协议,XYID=%d XYLen=%d \n",recv_packet.m_XYID,recv_packet.m_nLen );
		}
	}

	if ( nRet )
	{
		printf_s("CGameDBSocket:协议处理错误,XYID=%d XYLen=%d \n",recv_packet.m_XYID,recv_packet.m_nLen );
		this->Close();
	}
	return nRet;
}
Exemple #2
0
int Announce()
{
    gr_list	*fgr = NULL, *tmp;
    char	*temp;
    FILE	*fp;
    int		Count = 0, rc = FALSE;
    int		filepos, filepos1, filepos2;
    char	group[13];
    int		i, groups, any;

    if (!do_quiet) {
	mbse_colour(CYAN, BLACK);
	printf("Announce new files\n");
    }

    Uploads();
    IsDoing("Announce files");

    temp = calloc(PATH_MAX, sizeof(char));
    snprintf(temp, PATH_MAX, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
    if ((fp = fopen(temp, "r")) == NULL) {
	Syslog('+', "No new files to announce");
	free(temp);
	if (!do_quiet) {
	    printf("  No new files.\n");
	}
	return FALSE;
    }

    if (!do_quiet)
	printf("  Preparing reports...\n");

    while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
	if (T_File.Announce) {
	    fill_grlist(&fgr, T_File.Group, T_File.Echo);
	    Count++;
	}
    }

    fclose(fp);

    if (Count == 0) {
	unlink(temp);
	if (!do_quiet) 
	    printf("  No new files.\n");
	Syslog('+', "No new files to announce");
	free(temp);
	return FALSE;
    }

    if (!do_quiet) 
	printf("  %d new files found\n", Count);

    sort_grlist(&fgr);

    /*
     *  At this point we have a sorted list of groups with a counter
     *  indicating howmany files to report in each group.
     */
    snprintf(temp, PATH_MAX, "%s/etc/newfiles.data", getenv("MBSE_ROOT"));
    if ((fp = fopen(temp, "r")) == NULL) {
	WriteError("$Can't open %s", temp);
	if (!do_quiet)
	    printf("  No newfile reports defined\n");
	free(temp);
	return FALSE;
    }
    fread(&newfileshdr, sizeof(newfileshdr), 1, fp);
    groups = newfileshdr.grpsize / 13;

    while (fread(&newfiles, newfileshdr.recsize, 1, fp) == 1) {
	if (newfiles.Active) {
	    filepos = ftell(fp);
	    if (!do_quiet)
		printf("  %s\n", newfiles.Comment);
	    any = FALSE;

	    for (i = 0; i < groups; i++) {
		fread(&group, 13, 1, fp);
		for (tmp = fgr; tmp; tmp = tmp->next)
		    if (strcmp(tmp->group, group) == 0)
			any = TRUE;
	    }
	    if (any) {
		fseek(fp, filepos, SEEK_SET);
		rc = TRUE;
		Syslog('+', "Create report: %s", newfiles.Comment);
		MsgCount = 1;
		if ((filepos1 = StartMsg()) != -1) {
		    filepos2 = 0;
		    while (fread(&group, 13, 1, fp) == 1) {
			for (tmp = fgr; tmp; tmp = tmp->next) {
			    if (!strcmp(tmp->group, group)) {
				filepos2 = Report(tmp, filepos1);
			    }
			}
		    }
		    FinishMsg(TRUE, filepos2);
		}
	    } else {
		if (!do_quiet)
		    printf("    No matching groups\n");
	    }

	    fseek(fp, filepos, SEEK_SET);
	}

	fseek(fp, newfileshdr.grpsize, SEEK_CUR);
    }
    fclose(fp);
    tidy_grlist(&fgr);

    if (rc) {
	snprintf(temp, PATH_MAX, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
	unlink(temp);
    }

    free(temp);
    return rc;
}
Exemple #3
0
int Report(gr_list *ta, int filepos)
{
    FILE	    *fp, *fi;
    char	    *temp, *line;
    int		    i, Total = 0;
    unsigned int    Size = 0;
    int		    filepos1 = 0, filepos2, filepos3 = 0, finalpos = 0;
    time_t	    ftime;

    temp = calloc(PATH_MAX, sizeof(char));
    snprintf(temp, PATH_MAX, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
    if ((fp = fopen(temp, "r")) == NULL) {
	WriteError("$Can't open %s", temp);
	return 0;
    }

    MacroVars("GJZ", "ssd", "", "", 0);
    MacroVars("slbkdt", "ssddss", "", "", 0, 0, "", "");
    MacroVars("ABZ", "ddd", 0, 0, 0);

    while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
	if ((!strcmp(T_File.Echo, ta->echo)) && (!strcmp(T_File.Group, ta->group)))
	    break;
    }

	Syslog('m', "Announce %s %s %s", T_File.Echo, T_File.Name, chartran(T_File.LName));
    if ((fi = OpenMacro(newfiles.Template, newfiles.Language, FALSE)) != NULL) {
	/*
	 * Area block header
	 */
	MacroVars("GJZ", "ssd", T_File.Echo, chartran(T_File.Comment), 0);
	fseek(fi, filepos, SEEK_SET);
	Msg_Macro(fi);
	filepos1 = ftell(fi);
    } else {
	free(temp);
	return 0;
    }

    fseek(fp, 0, SEEK_SET);
    while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
	if ((!strcmp(T_File.Echo, ta->echo)) && (!strcmp(T_File.Group, ta->group))) {

	    if (CFG.slow_util && do_quiet)
		msleep(1);

	    /*
	     * Report one newfile, first line.
	     */
	    fseek(fi, filepos1, SEEK_SET);
	    ftime = T_File.Fdate;
	    MacroVars("sl", "ss", T_File.Name, T_File.LName);
	    MacroVars("bk", "dd", T_File.Size, T_File.SizeKb);
	    MacroVars("dt", "ss", rfcdate(ftime), chartran(T_File.LDesc[0]));
	    Msg_Macro(fi);
	    filepos2 = ftell(fi);

	    /*
	     * Extra description lines follow
	     */
	    for (i = 1; i < 24; i++) {
		fseek(fi, filepos2, SEEK_SET);
		if (strlen(T_File.LDesc[i])) {
		    MacroVars("t", "s", chartran(T_File.LDesc[i]));
		    Msg_Macro(fi);
		} else {
		    line = calloc(MAXSTR, sizeof(char));
		    while ((fgets(line, MAXSTR-2, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {}
		    free(line);
		}
		filepos3 = ftell(fi);
	    }

	    /*
	     * Magic request
	     */
	    if (strlen(T_File.Magic)) {
		MacroVars("u", "s", T_File.Magic);
		Msg_Macro(fi);
	    } else {
		line = calloc(MAXSTR, sizeof(char));
		while ((fgets(line, MAXSTR-2, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {}
		free(line);
	    }
	    filepos3 = ftell(fi);
	    Total++;
	    Size += T_File.SizeKb;
	}
    }

    /*
     * Area block footer
     */
    if (Msg.Size > (CFG.new_split * 1024))
	MacroVars("ABZ", "ddd", Total, Size, 1);
    else
	MacroVars("ABZ", "ddd", Total, Size, 0);
    fseek(fi, filepos3, SEEK_SET);
    Msg_Macro(fi);
    finalpos = ftell(fi);
    fclose(fp);
    free(temp);

    /*
     * Split messages if too big.
     */
    if (Msg.Size > (CFG.new_split * 1024)) {
	MsgCount++;
	Syslog('m', "Report() splitting report");
	FinishMsg(FALSE, finalpos);
	StartMsg();
    }

    TotalFiles += Total;
    TotalSize += Size;

    if (fi != NULL) {
	fclose(fi);
    }
    return finalpos;
}