예제 #1
0
파일: starDust.cpp 프로젝트: xyuan/covise
int starDust::loadData(std::string particlepath, osg::Group *parent)
{
    unloadData(particlepath);
    FILE *fp;
    fp = fopen(particlepath.c_str(), "r");
    if (fp)
    {
#define LINE_LEN 1000
        char buf[1001];
        buf[1000] = '\0';
        dD = new dustDrawable();
        while (!feof(fp))
        {
            fgets(buf, LINE_LEN, fp);
            if ((buf[0] != '%') && (buf[0] != '#'))
            {
                double xc, yc, zc, vx, vy, vz, mass, f, startTime;
                sscanf(buf, "%lf %lf %lf %lf %lf %lf %lf %lf %lf", &xc, &yc, &zc, &vx, &vy, &vz, &mass, &f, &startTime);
                dD->particles.push_back(particleData(xc, yc, zc, vx, vy, vz, mass, f, startTime));
            }
        }
        dD->particleCoords = new CUDA_DATATYPE[dD->particles.size() * 4];
        dD->particleVelos = new CUDA_DATATYPE[dD->particles.size() * 3];
        dD->planetCoords = new CUDA_DATATYPE[starDust::instance()->planets.size() * 4];
        dD->planetVelos = new CUDA_DATATYPE[starDust::instance()->planets.size() * 3];
        int n = dD->particles.size();
        for (int i = 0; i < n; i++)
        {
            dD->particleCoords[i * 4 + 0] = dD->particles[i].xc;
            dD->particleCoords[i * 4 + 1] = dD->particles[i].yc;
            dD->particleCoords[i * 4 + 2] = dD->particles[i].zc;
            dD->particleCoords[i * 4 + 3] = dD->particles[i].m;
            dD->particleVelos[i * 3] = dD->particles[i].vx;
            dD->particleVelos[i * 3 + 1] = dD->particles[i].vy;
            dD->particleVelos[i * 3 + 2] = dD->particles[i].vz;
        }
        osg::Geode *g = new osg::Geode;
        g->setName("startDustGeo");
        geode[particlepath] = g;

        g->addDrawable(dD.get());
        dD->setUseDisplayList(false);
        if (parent)
            parent->addChild(g);
        else
            cover->getObjectsRoot()->addChild(g);

        geode[std::string(particlepath)] = g;
        initDone = true;
    }
    else
    {
        fprintf(stderr, "Could not open file %s\n", particlepath.c_str());
    }

    return 0;
}
예제 #2
0
파일: GridMap.cpp 프로젝트: Phatcat/mangos
bool GridMap::loadData(char *filename)
{
    // Unload old data if exist
    unloadData();

    GridMapFileHeader header;
    // Not return error if file not found
    FILE *in = fopen(filename, "rb");
    if (!in)
        return true;

    fread(&header, sizeof(header),1,in);
    if (header.mapMagic     == *((uint32 const*)(MAP_MAGIC)) &&
        header.versionMagic == *((uint32 const*)(MAP_VERSION_MAGIC)))
    {
        // loadup area data
        if (header.areaMapOffset && !loadAreaData(in, header.areaMapOffset, header.areaMapSize))
        {
            sLog.outError("Error loading map area data\n");
            fclose(in);
            return false;
        }

        // loadup holes data
        if (header.holesOffset && !loadHolesData(in, header.holesOffset, header.holesSize))
        {
            sLog.outError("Error loading map holes data\n");
            fclose(in);
            return false;
        }

        // loadup height data
        if (header.heightMapOffset && !loadHeightData(in, header.heightMapOffset, header.heightMapSize))
        {
            sLog.outError("Error loading map height data\n");
            fclose(in);
            return false;
        }

        // loadup liquid data
        if (header.liquidMapOffset && !loadGridMapLiquidData(in, header.liquidMapOffset, header.liquidMapSize))
        {
            sLog.outError("Error loading map liquids data\n");
            fclose(in);
            return false;
        }

        fclose(in);
        return true;
    }

    sLog.outError("Map file '%s' is non-compatible version (outdated?). Please, create new using ad.exe program.", filename);
    fclose(in);
    return false;
}
예제 #3
0
파일: police.c 프로젝트: startmenu/ythtbbs
//  ---------------------------   警署     --------------------------  //
static int
cop_accuse()
{
    char uident[IDLEN + 1], buf[256];
    mcUserInfo *mcuInfo;
    time_t currTime;

    move(4, 4);
    prints("如果您遭遇抢劫或偷窃,如果您有任何线索,请向警方报告。");
    move(5, 4);
    prints("\033[1;32m警民合作,共创安定大好局面!\033[0m");
    if (!getOkUser("举报谁?", uident, 7, 4))
        return 0;
    move(8, 4);
    sethomefile(buf, uident, "mc.save");
    if (!file_exist(buf))
        initData(1, buf);
    if((mcuInfo = loadData(buf, sizeof (mcUserInfo))) == (void*)-1)
        return 0;
    if (seek_in_file(DIR_MC "policemen", uident)) {
        showAt(8, 4, "大胆!想诬陷警务人员吗?!", YEA);
        goto UNMAP;
    }
    if (mcuInfo->freeTime > 0) {
        showAt(8, 4, "这个人已经被警署监禁了。", YEA);
        goto UNMAP;
    }
    currTime = time(NULL);
    if ((mcuInfo->robExp == 0) || (mcuInfo->begExp == 0)
            || (mcuInfo->lastActiveTime + 7200 < currTime) || !(mcuInfo->BeIn)) {
        showAt(8, 4, "这个人最近很安分啊!你不要诽谤别人哦!", YEA);
        goto UNMAP;
    }
    if (seek_in_file(DIR_MC "criminals_list", uident)) {
        showAt(8, 4, "此人已经被警署通缉了,警署仍然向你表示感谢。",
               YEA);
        goto UNMAP;
    }
    getdata(8, 4, "简述案情[\033[1;33mENTER\033[0m放弃]:",
            genbuf, 40, DOECHO, YEA);
    if (genbuf[0] == '\0')
        goto UNMAP;
    move(9, 4);
    if (askyn("\033[1;33m你向警方提供的上述信息真实吗\033[0m", NA, NA) ==
            NA)
        goto UNMAP;
    snprintf(buf, STRLEN - 1, "%s %s", uident, genbuf);
    addtofile(DIR_MC "criminals_list", buf);
    showAt(10, 4, "警方非常感谢您提供的线索,我们将尽力尽快破案。", YEA);
    return 1;

UNMAP:
    unloadData(mcuInfo, 1);
    return 0;
}
예제 #4
0
void WLD_SetPoint::closeEvent(QCloseEvent *event)
{
    if(!sceneCreated)
    {
        event->accept();
        return;
    }

    unloadData();
    event->accept();
}
예제 #5
0
void DataBackend::newFromBlank()
{
	if(!checkBeforeDataUnload()) return;
	emit(unloadData());
	dataLock=false;
	emit(dataLocked(false));
	currentName="";
	lastChangeUnpredictable=false;
	emit(gainedUnpredicatableChanges(lastChangeUnpredictable));
	unpredictableChange=0;
	purgeData();
}
예제 #6
0
파일: police.c 프로젝트: startmenu/ythtbbs
static int
cop_arrange(int type)
{
    int found;
    char uident[IDLEN + 1], buf[STRLEN], title[STRLEN];
    char *actionDesc[] = { "-", "任命", "解职", NULL };
    mcUserInfo *mcuInfo;

    if (!getOkUser("请输入ID: ", uident, 12, 4))
        return 0;
    found = seek_in_file(DIR_MC "policemen", uident);
    move(13, 4);
    if (type == 1 && found) {
        showAt(13, 4, "该ID已经是警员了。", YEA);
        return 0;
    } else if (type == 2 && !found) {
        showAt(13, 4, "该ID不是警署警员。", YEA);
        return 0;
    }
    if (type == 1 && (clubtest(ROBUNION) || clubtest(BEGGAR))) {
        showAt(13, 4, "此人社会关系不明,不宜雇用为警员。", YEA);
        return 0;
    }

    sprintf(buf, "%s确定%s吗?",
            type == 2 ? "被解雇警员会损失一半胆识跟身法," : "",
            actionDesc[type]);
    if (askyn(buf, NA, NA) == NA)
        return 0;
    if (type == 1)
        addtofile(DIR_MC "policemen", uident);
    else {
        sethomefile(buf, uident, "mc.save");
        if (!file_exist(buf))
            initData(1, buf);
        if((mcuInfo = loadData(buf, sizeof (mcUserInfo))) == (void*)-1)
            return 0;
        mcuInfo->robExp /= 2;
        mcuInfo->begExp /= 2;
        mcuInfo->luck = -100;
        del_from_file(DIR_MC "policemen", uident);
        unloadData(mcuInfo, sizeof (mcUserInfo));
    }
    sprintf(title, "【警署】%s警员 %s", actionDesc[type], uident);
    sprintf(buf, "警署署长%s %s警员 %s", currentuser->userid,
            actionDesc[type], uident);
    deliverreport(title, buf);
    system_mail_buf(buf, strlen(buf), uident, title, currentuser->userid);
    showAt(14, 4, "操作成功。", YEA);
    return 1;
}
예제 #7
0
void DataBackend::load()
{
	if(!checkBeforeDataUnload()) return;
	emit(unloadData());
	dataLock=false;
	emit(dataLocked(false));
	currentName="";
	lastChangeUnpredictable=false;
	emit(gainedUnpredicatableChanges(lastChangeUnpredictable));
	unpredictableChange=0;
	purgeData();
	QString filename = QFileDialog::getOpenFileName(NULL, "Load Project",QString(),"*xml");
	if(filename.isEmpty()) return;
	else 
	{
		loadDataFromXML(filename);
	}
}
예제 #8
0
void WLD_SetPoint::on_buttonBox_clicked(QAbstractButton *button)
{
    if(ui->buttonBox->buttonRole(button)==QDialogButtonBox::AcceptRole)
    {
        if(mapPointIsNull)
        {
            QMessageBox::information(this, tr("Point is not selected"), tr("Select the point on the world map first."), QMessageBox::Ok);
            return;
        }

        unloadData();
        QDialog::accept();
    }
    else
    {
        QDialog::reject();
    }
}
예제 #9
0
파일: police.c 프로젝트: startmenu/ythtbbs
static void
SearchCrime()
{
    char uident[IDLEN + 1], buf[256];
    time_t currTime, ActiveTime;
    mcUserInfo *mcuInfo;
    int day, hour, minute;

    nomoney_show_stat("档案室");
    if (!getOkUser("\n请选择查询的档案:", uident, 6, 4)) {
        move(8, 4);
        prints("查无此人");
        pressanykey();
        return;
    }

    sethomefile(buf, uident, "mc.save");
    if (!file_exist(buf))
        initData(1, buf);
    if((mcuInfo = loadData(buf, sizeof (mcUserInfo))) == (void*)-1)
        return;

    ActiveTime = mcuInfo->lastActiveTime;
    currTime = time(NULL);
    if (currTime > ActiveTime) {
        day = (currTime - ActiveTime) / 86400;
        hour = (currTime - ActiveTime) % 86400 / 3600;
        minute = (currTime - ActiveTime) % 3600 / 60 + 1;
        move(9, 1);
        prints("    此人上次犯案是在%d天%d小时%d分钟以前。", day, hour,
               minute);
    }
    unloadData(mcuInfo, sizeof (mcUserInfo));
    pressanykey();
    return;
}
예제 #10
0
// -----------------------------------------------------------------------------
// Reads grp format data from a MemChunk
// Returns true if successful, false otherwise
// -----------------------------------------------------------------------------
bool GrpArchive::open(MemChunk& mc)
{
	// Check data was given
	if (!mc.hasData())
		return false;

	// Read grp header
	uint32_t num_lumps     = 0;
	char     ken_magic[13] = "";
	mc.seek(0, SEEK_SET);
	mc.read(ken_magic, 12); // "KenSilverman"
	mc.read(&num_lumps, 4); // No. of lumps in grp

	// Byteswap values for big endian if needed
	num_lumps = wxINT32_SWAP_ON_BE(num_lumps);

	// Null-terminate the magic header
	ken_magic[12] = 0;

	// Check the header
	if (!(S_CMP(wxString::FromAscii(ken_magic), "KenSilverman")))
	{
		Log::error(S_FMT("GrpArchive::openFile: File %s has invalid header", filename_));
		Global::error = "Invalid grp header";
		return false;
	}

	// Stop announcements (don't want to be announcing modification due to entries being added etc)
	setMuted(true);

	// The header takes as much space as a directory entry
	uint32_t entryoffset = 16 * (1 + num_lumps);

	// Read the directory
	UI::setSplashProgressMessage("Reading grp archive data");
	for (uint32_t d = 0; d < num_lumps; d++)
	{
		// Update splash window progress
		UI::setSplashProgress(((float)d / (float)num_lumps));

		// Read lump info
		char     name[13] = "";
		uint32_t offset   = entryoffset;
		uint32_t size     = 0;

		mc.read(name, 12); // Name
		mc.read(&size, 4); // Size
		name[12] = '\0';

		// Byteswap values for big endian if needed
		size = wxINT32_SWAP_ON_BE(size);

		// Increase offset of next entry by this entry's size
		entryoffset += size;

		// If the lump data goes past the end of the file,
		// the grpfile is invalid
		if (offset + size > mc.size())
		{
			Log::error("GrpArchive::open: grp archive is invalid or corrupt");
			Global::error = "Archive is invalid and/or corrupt";
			setMuted(false);
			return false;
		}

		// Create & setup lump
		auto nlump = std::make_shared<ArchiveEntry>(wxString::FromAscii(name), size);
		nlump->setLoaded(false);
		nlump->exProp("Offset") = (int)offset;
		nlump->setState(ArchiveEntry::State::Unmodified);

		// Add to entry list
		rootDir()->addEntry(nlump);
	}

	// Detect all entry types
	MemChunk edata;
	UI::setSplashProgressMessage("Detecting entry types");
	for (size_t a = 0; a < numEntries(); a++)
	{
		// Update splash window progress
		UI::setSplashProgress((((float)a / (float)num_lumps)));

		// Get entry
		auto entry = entryAt(a);

		// Read entry data if it isn't zero-sized
		if (entry->size() > 0)
		{
			// Read the entry data
			mc.exportMemChunk(edata, getEntryOffset(entry), entry->size());
			entry->importMemChunk(edata);
		}

		// Detect entry type
		EntryType::detectEntryType(entry);

		// Unload entry data if needed
		if (!archive_load_data)
			entry->unloadData();

		// Set entry to unchanged
		entry->setState(ArchiveEntry::State::Unmodified);
	}

	// Setup variables
	setMuted(false);
	setModified(false);
	announce("opened");

	UI::setSplashProgressMessage("");

	return true;
}
예제 #11
0
파일: police.c 프로젝트: startmenu/ythtbbs
static void
cop_tax()
{
    char uident[IDLEN + 1], buf[256], title[STRLEN];
    time_t currtime;
    mcUserInfo *mcuInfo;
    int num;

    nomoney_show_stat("税局");

    if (clubtest(ROBUNION) || clubtest(BEGGAR)) {
        showAt(12, 4, "《无间道》看多了吧你?", YEA);
        return;
    }

    if (myInfo->robExp < 500 || myInfo->begExp < 500) {
        showAt(12, 4,
               "新警察吧?先去练练基本功,不然就是送死了。党和国家培养你不容易啊!",
               YEA);
        return;
    }
    if (check_health(100, 12, 4, "你没有充沛的体力来执行任务。", YEA))
        return;

    currtime = time(NULL);
    if (myInfo->WorkPoint < 9000) {
        showAt(12, 4, "不要着急,上级还没有行动指示。", YEA);
        return;
    }

    move(4, 4);
    prints("最近偷税漏税严重,需要严厉打击这种抗税风潮。");

    if (!getOkUser("\n请选择你的目标:", uident, 6, 4)) {
        move(8, 4);
        prints("查无此人");
        pressanykey();
        return;
    }
    if (!strcmp(uident, currentuser->userid)) {
        showAt(8, 4, "牛魔王:“老婆~快来看神经病啦~”", YEA);
        return;
    }

    myInfo->Actived += 10;
    move(10, 4);
    prints("你敲开了%s的家门。", uident);
    sleep(1);

    sethomefile(buf, uident, "mc.save");
    if (!file_exist(buf))
        initData(1, buf);
    if((mcuInfo = loadData(buf, sizeof (mcUserInfo))) == (void*)-1)
        return;

    if (mcuInfo->GetLetter == 0) {
        clear();
        showAt(6, 4, "虚拟货币持有者,无法征税", YEA);
        unloadData(mcuInfo, sizeof (mcUserInfo));
        return;
    }

    myInfo->lastActiveTime = currtime;
    myInfo->WorkPoint -= 9000;
    sleep(1);

    if (check_chance
            (myInfo->robExp + myInfo->begExp, mcuInfo->robExp + mcuInfo->begExp,
             myInfo->weapon, mcuInfo->armor, 200, 100)) {
        myInfo->begExp += 20;
        myInfo->robExp += 20;
        num = mcuInfo->credit / 3;
        myInfo->health = 0;
        mcuInfo->credit -= num;
        mcEnv->Treasury += num * 2 / 3;
        myInfo->credit += num / 3;

        myInfo->luck = MIN(100, myInfo->luck + 20);
        prints("\n    %s并不像想象中的那么滑头啊。"
               "\n    他在你的监督下如数缴纳了%d%s的欠税。"
               "\n    你从中获得1/3 的奖励,你的胆识身法上升。", uident,
               num, MONEY_NAME);
        sprintf(title, "【税务】%s缴纳欠税", uident);
        sprintf(buf,
                "在警员%s的监督下,%s如期缴纳了所欠的%d%s税款。特此公告。",
                currentuser->userid, uident, num, MONEY_NAME);
        deliverreport(title, buf);
        sprintf(buf,
                "警员%s陪同税务前来查税,看来是躲不过去了。\n"
                "不得不缴纳了%d%s的税款,心痛啊。",
                currentuser->userid, num, MONEY_NAME);
        if (mcuInfo->GetLetter == 1)
            system_mail_buf(buf, strlen(buf), uident, "你缴纳欠税",
                            currentuser->userid);
    } else {
        myInfo->begExp = MAX(0, myInfo->begExp - 5);
        myInfo->robExp = MAX(0, myInfo->robExp - 5);
        myInfo->health = 0;
        mcuInfo->robExp += 10;
        mcuInfo->begExp += 10;
        prints("\n    %s一副死猪不怕开水烫的样子。"
               "\n    “要钱没有,要命一条”"
               "\n    软硬不吃,你无计可使,不得不狼狈归去。", uident);
    }
    unloadData(mcuInfo, sizeof (mcUserInfo));
    pressanykey();
    return;
}
예제 #12
0
// -----------------------------------------------------------------------------
// Reads wad format data from a MemChunk
// Returns true if successful, false otherwise
// -----------------------------------------------------------------------------
bool Wad2Archive::open(MemChunk& mc)
{
	// Check data was given
	if (!mc.hasData())
		return false;

	// Read wad header
	uint32_t num_lumps   = 0;
	uint32_t dir_offset  = 0;
	char     wad_type[4] = "";
	mc.seek(0, SEEK_SET);
	mc.read(&wad_type, 4);   // Wad type
	mc.read(&num_lumps, 4);  // No. of lumps in wad
	mc.read(&dir_offset, 4); // Offset to directory

	// Byteswap values for big endian if needed
	num_lumps  = wxINT32_SWAP_ON_BE(num_lumps);
	dir_offset = wxINT32_SWAP_ON_BE(dir_offset);

	// Check the header
	if (wad_type[0] != 'W' || wad_type[1] != 'A' || wad_type[2] != 'D' || (wad_type[3] != '2' && wad_type[3] != '3'))
	{
		Log::error("Wad2Archive::open: Invalid header");
		Global::error = "Invalid wad2 header";
		return false;
	}
	if (wad_type[3] == '3')
		wad3_ = true;

	// Stop announcements (don't want to be announcing modification due to entries being added etc)
	setMuted(true);

	// Read the directory
	mc.seek(dir_offset, SEEK_SET);
	UI::setSplashProgressMessage("Reading wad archive data");
	for (uint32_t d = 0; d < num_lumps; d++)
	{
		// Update splash window progress
		UI::setSplashProgress(((float)d / (float)num_lumps));

		// Read lump info
		Wad2Entry info;
		mc.read(&info, 32);

		// Byteswap values for big endian if needed
		info.offset = wxINT32_SWAP_ON_BE(info.offset);
		info.size   = wxINT32_SWAP_ON_BE(info.size);
		info.dsize  = wxINT32_SWAP_ON_BE(info.dsize);

		// If the lump data goes past the end of the file,
		// the wadfile is invalid
		if ((unsigned)(info.offset + info.dsize) > mc.size())
		{
			Log::error("Wad2Archive::open: Wad2 archive is invalid or corrupt");
			Global::error = "Archive is invalid and/or corrupt";
			setMuted(false);
			return false;
		}

		// Create & setup lump
		auto nlump = std::make_shared<ArchiveEntry>(wxString::FromAscii(info.name, 16), info.dsize);
		nlump->setLoaded(false);
		nlump->exProp("Offset") = (int)info.offset;
		nlump->exProp("W2Type") = info.type;
		nlump->exProp("W2Size") = (int)info.size;
		nlump->exProp("W2Comp") = !!(info.cmprs);
		nlump->setState(ArchiveEntry::State::Unmodified);

		// Add to entry list
		rootDir()->addEntry(nlump);
	}

	// Detect all entry types
	MemChunk edata;
	UI::setSplashProgressMessage("Detecting entry types");
	for (size_t a = 0; a < numEntries(); a++)
	{
		// Update splash window progress
		UI::setSplashProgress((((float)a / (float)num_lumps)));

		// Get entry
		auto entry = entryAt(a);

		// Read entry data if it isn't zero-sized
		if (entry->size() > 0)
		{
			// Read the entry data
			mc.exportMemChunk(edata, (int)entry->exProp("Offset"), entry->size());
			entry->importMemChunk(edata);
		}

		// Detect entry type
		EntryType::detectEntryType(entry);

		// Unload entry data if needed
		if (!archive_load_data)
			entry->unloadData();

		// Set entry to unchanged
		entry->setState(ArchiveEntry::State::Unmodified);
	}

	// Detect maps (will detect map entry types)
	UI::setSplashProgressMessage("Detecting maps");
	detectMaps();

	// Setup variables
	setMuted(false);
	setModified(false);
	announce("opened");

	UI::setSplashProgressMessage("");

	return true;
}
예제 #13
0
void GofunWidget::reloadData()
{
	unloadData();
	loadData();
}
예제 #14
0
/**
 * MapDataSet destruction.
 */
MapDataSet::~MapDataSet()
{
	unloadData();
}
예제 #15
0
파일: police.c 프로젝트: startmenu/ythtbbs
static void
cop_Arrest(void)
{
    char uident[IDLEN + 1], police[IDLEN + 1], buf[256], title[STRLEN];
    char *CrimeName[] =
    {   "莫须有", "有伤风化", "小偷小摸", "破坏治安", "卖淫嫖娼",
        "杀人放火", "颠覆政府", "反社会反人类", "种族灭绝", NULL
    };
    int CrimeTime[] = { 1, 2, 3, 4, 6, 8, 12, 16, 24 };
    time_t currtime;
    mcUserInfo *mcuInfo;
    int num, tranum, crime = 0, bonus = 100;

    nomoney_show_stat("刑警队");
    if (!seek_in_file(DIR_MC "policemen", currentuser->userid)) {
        showAt(12, 4, "警察执行任务,闲杂人等请回避,以免误伤。", YEA);
        return;
    }
    if (clubtest(ROBUNION) || clubtest(BEGGAR)) {
        showAt(12, 4, "《无间道》看多了吧你?", YEA);
        return;
    }

    if (myInfo->robExp < 50 || myInfo->begExp < 50) {
        showAt(12, 4,
               "新警察吧?先去练练基本功,不然就是送死了。党和国家培养你不容易啊!",
               YEA);
        return;
    }
    if (check_health(100, 12, 4, "你没有充沛的体力来执行任务。", YEA))
        return;

    currtime = time(NULL);
    if (myInfo->WorkPoint < 7200) {
        showAt(12, 4, "不要着急,上级还没有行动指示。", YEA);
        return;
    }

    move(5, 4);
    prints("刚刚接到上级指示,马上要进行一次抓捕行动。");

    if (!getOkUser("\n请选择你的目标:", uident, 6, 4)) {
        move(8, 4);
        prints("查无此人");
        pressanykey();
        return;
    }
    if (!strcmp(uident, currentuser->userid)) {
        showAt(8, 4, "牛魔王:“老婆~快来看神经病啦~”", YEA);
        return;
    }
    if (!seek_in_file(DIR_MC "criminals_list", uident)) {
        showAt(8, 4, "此人不在通缉名单上面。”", YEA);
        return;
    }
    myInfo->Actived += 10;
    move(10, 4);
    prints("你埋伏在大富翁世界的必经之路,等待目标的出现。");
    sleep(1);

    sethomefile(buf, uident, "mc.save");
    if (!file_exist(buf))
        initData(1, buf);
    if((mcuInfo = loadData(buf, sizeof (mcUserInfo))) == (void*)-1)
        return;

    myInfo->lastActiveTime = currtime;
    myInfo->WorkPoint -= 7200;
    sleep(1);
    if (currtime > 3600 + mcuInfo->lastActiveTime) {
        myInfo->health -= 10;
        showAt(12, 4, "你等了整整一天,目标还是没有出现,只好放弃了。",
               YEA);
        return;
    }

    /*	if (!(random() % 3)) {
    		myInfo->health -= 10;
    		showAt(12, 4, "你眼看老远处人影一晃,目标得到风声跑掉了。",
    		       YEA);
    		return;
    	}

    	if ((myInfo->robExp + myInfo->begExp >=
    	     (mcuInfo->robExp + mcuInfo->begExp)
    	     * 5 + 50 || myInfo->luck - mcuInfo->luck >= 100 || (random() % 3))
    	    && !(mcuInfo->robExp + mcuInfo->begExp >= (myInfo->
    						       robExp +
    						       myInfo->begExp) * 5 +
    		 50)) {
    */
    num =
        myInfo->robExp + myInfo->begExp + (mcuInfo->robExp +
                                           mcuInfo->begExp) * 2;
    if (num > 150000)
        crime = 8;
    else if (num > 100000)
        crime = 7;
    else if (num > 50000)
        crime = 6;
    else if (num > 10000)
        crime = 5;
    else if (num > 5000)
        crime = 4;
    else if (num > 2000)
        crime = 3;
    else if (num > 1000)
        crime = 2;
    else if (num > 500)
        crime = 1;
    else
        crime = 0;
    tranum =
        MIN((myInfo->robExp + myInfo->begExp + mcuInfo->robExp +
             mcuInfo->begExp) / 250,
            (mcuInfo->robExp + mcuInfo->begExp) / 50);
    whoTakeCharge(8, police);
    if (!(strcmp(currentuser->userid, police)))
        bonus = 300;
    if (check_chance
            (myInfo->robExp + myInfo->begExp, mcuInfo->robExp + mcuInfo->begExp,
             myInfo->weapon, mcuInfo->armor, 200, bonus)) {
        myInfo->begExp += tranum + 10;
        myInfo->robExp += tranum + 10;
        myInfo->health = 0;
        myInfo->cash += mcuInfo->cash;
        mcuInfo->cash = 0;
        mcuInfo->begExp = MAX(0, mcuInfo->begExp - tranum - 10);
        mcuInfo->robExp = MAX(0, mcuInfo->robExp - tranum - 10);
        mcuInfo->luck = MAX(-100, mcuInfo->luck - 10);
//              mcuInfo->freeTime += (currtime + 10800);
        mcuInfo->freeTime = time(NULL) + CrimeTime[crime] * 3600;

        myInfo->luck = MIN(100, myInfo->luck + 10);
        del_from_file(DIR_MC "criminals_list", uident);
        prints("\n    远处有人走了过来,你定睛一看,正是你要抓的%s。"
               "\n    你跳出来拔出手枪大吼道:“不许动!你被捕了!”"
               "\n    %s目瞪口呆,只好束手就擒。"
               "\n    你的胆识增加了!	你的身法增加了!"
               "\n    你的体力耗尽了!"
               "\n    你的人品增加了!"
               "\n    没收罪犯所有现金做为补助!", uident, uident);
        sprintf(title, "【警署】警方抓获通缉犯%s", uident);
        sprintf(buf,
                "警员%s耐心守候,孤身勇擒在榜通缉犯%s,特此公告,以示表彰。\n\n"
                "经%s法庭判决,被告%s%s罪名成立,判处%d小时有期徒刑。",
                currentuser->userid, uident, CENTER_NAME, uident,
                CrimeName[crime], CrimeTime[crime]);
        deliverreport(title, buf);
        sprintf(buf,
                "你被警员%s设伏抓获,没收所有现金,胆识身法下降。\n"
                "还被法庭判决%s罪,关押%d小时。\n"
                "不报此仇,誓不为人!",
                currentuser->userid, CrimeName[crime],
                CrimeTime[crime]);
        if (mcuInfo->GetLetter == 1)
            system_mail_buf(buf, strlen(buf), uident,
                            "你被警方抓获", currentuser->userid);
        unloadData(mcuInfo, sizeof (mcUserInfo));
    } else {
        myInfo->begExp = MAX(0, myInfo->begExp - tranum / 2);
        myInfo->robExp = MAX(0, myInfo->robExp - tranum / 2);
        myInfo->health = 0;
        mcuInfo->cash += myInfo->cash;
        myInfo->cash = 0;
        mcuInfo->robExp += tranum / 2;
        mcuInfo->begExp += tranum / 2;
        myInfo->freeTime = time(NULL) + CrimeTime[crime] * 1800 + 1800;
        prints("\n    远处有人走了过来,你定睛一看,正是你要抓的%s。"
               "\n    你跳出来拔出手枪大吼道:“不许动!你被捕了!”"
               "\n    正得意时,不料背后有人打了你一个闷棍。"
               "\n    你的胆识减少了!"
               "\n    你的身法减少了!" "\n    你昏了过去!", uident);
        sprintf(title, "【警署】警员%s受伤住院", currentuser->userid);
        sprintf(buf,
                "警员%s在执行任务的时候,被罪犯打伤住院。目前情况稳"
                "定,%d小时以后即可出院。", currentuser->userid,
                (CrimeTime[crime] + 1) / 2);
        deliverreport(title, buf);
        sprintf(buf,
                "条子%s设伏抓你,还好你艺高人胆大将其干掉,自己安然"
                "无恙。\n 顺手捞走了他身上的现金,胆识身法上升,太爽了!",
                currentuser->userid);
        if (mcuInfo->GetLetter == 1)
            system_mail_buf(buf, strlen(buf), uident, "你金蝉脱壳",
                            currentuser->userid);
        unloadData(mcuInfo, sizeof (mcUserInfo));
        unloadData(myInfo, sizeof (mcUserInfo));
        unloadData(mcEnv, sizeof (MC_Env));
        pressreturn();
        Q_Goodbye();
    }

    pressreturn();
//      Q_Goodbye();
    return;

}
예제 #16
0
GridMap::~GridMap()
{
    unloadData();
}
예제 #17
0
// -----------------------------------------------------------------------------
// Reads lfd format data from a MemChunk
// Returns true if successful, false otherwise
// -----------------------------------------------------------------------------
bool LfdArchive::open(MemChunk& mc)
{
	// Check data was given
	if (!mc.hasData())
		return false;

	// Check size
	if (mc.size() < 16)
		return false;

	// Check magic header
	if (mc[0] != 'R' || mc[1] != 'M' || mc[2] != 'A' || mc[3] != 'P')
		return false;

	// Get directory length
	uint32_t dir_len = 0;
	mc.seek(12, SEEK_SET);
	mc.read(&dir_len, 4);
	dir_len = wxINT32_SWAP_ON_BE(dir_len);

	// Check size
	if ((unsigned)mc.size() < (dir_len) || dir_len % 16)
		return false;

	// Guess number of lumps
	uint32_t num_lumps = dir_len / 16;

	// Stop announcements (don't want to be announcing modification due to entries being added etc)
	setMuted(true);

	// Read each entry
	UI::setSplashProgressMessage("Reading lfd archive data");
	size_t offset = dir_len + 16;
	size_t size   = mc.size();
	for (uint32_t d = 0; offset < size; d++)
	{
		// Update splash window progress
		UI::setSplashProgress(((float)d / (float)num_lumps));

		// Read lump info
		uint32_t length  = 0;
		char     type[5] = "";
		char     name[9] = "";

		mc.read(type, 4);    // Type
		mc.read(name, 8);    // Name
		mc.read(&length, 4); // Size
		name[8] = '\0';
		type[4] = 0;

		// Move past the header
		offset += 16;

		// Byteswap values for big endian if needed
		length = wxINT32_SWAP_ON_BE(length);

		// If the lump data goes past the end of the file,
		// the gobfile is invalid
		if (offset + length > size)
		{
			LOG_MESSAGE(1, "LfdArchive::open: lfd archive is invalid or corrupt");
			Global::error = "Archive is invalid and/or corrupt";
			setMuted(false);
			return false;
		}

		// Create & setup lump
		wxFileName fn(name);
		fn.SetExt(type);
		auto nlump = std::make_shared<ArchiveEntry>(fn.GetFullName(), length);
		nlump->setLoaded(false);
		nlump->exProp("Offset") = (int)offset;
		nlump->setState(ArchiveEntry::State::Unmodified);

		// Add to entry list
		rootDir()->addEntry(nlump);

		// Move to next entry
		offset += length;
		mc.seek(offset, SEEK_SET);
	}

	if (num_lumps != numEntries())
		LOG_MESSAGE(1, "Warning: computed %i lumps, but actually %i entries", num_lumps, numEntries());

	// Detect all entry types
	MemChunk edata;
	UI::setSplashProgressMessage("Detecting entry types");
	for (size_t a = 0; a < numEntries(); a++)
	{
		// Update splash window progress
		UI::setSplashProgress((((float)a / (float)num_lumps)));

		// Get entry
		auto entry = entryAt(a);

		// Read entry data if it isn't zero-sized
		if (entry->size() > 0)
		{
			// Read the entry data
			mc.exportMemChunk(edata, getEntryOffset(entry), entry->size());
			entry->importMemChunk(edata);
		}

		// Detect entry type
		EntryType::detectEntryType(entry);

		// Unload entry data if needed
		if (!archive_load_data)
			entry->unloadData();

		// Set entry to unchanged
		entry->setState(ArchiveEntry::State::Unmodified);
	}

	// Setup variables
	setMuted(false);
	setModified(false);
	announce("opened");

	UI::setSplashProgressMessage("");

	return true;
}