示例#1
0
bool CustomColumns::Less(size_t column, const PhotoInfo& photo1, const PhotoInfo& photo2) const
{
	double num1, num2;
	String out1, out2;

	Result res1= CalcValue(column, photo1, num1, out1);
	Result res2= CalcValue(column, photo2, num2, out2);

	if (res1 == res2)
	{
		switch (res1)
		{
		case Number:
			return num1 < num2;

		case Text:
			return _tcsicmp(out1.c_str(), out2.c_str()) < 0;

		case Err:
			return false;
		}
	}
	else
	{
		return res1 < res2;
	}

	return false;
}
示例#2
0
文件: evidence.c 项目: vcosta/derclou
S32 tcCalcCarEscape(S32 timeLeft)
{
    ubyte kmhWeight[4] = { 32, 44, 60, 67 };
    ubyte psWeight[4] = { 68, 56, 40, 33 };
    ubyte driverWeight[4] = { 50, 40, 25, 20 };
    ubyte policeSpeed[4] = { 90, 95, 103, 107 }
    , paint;
    char line[TXT_KEY_LENGTH];
    S32 kmh, ps, i, j, YardsInFront, length, wayType, unrealSpeed, x, xOldMatt =
	-1, xOldPoli = -1;
    Car car = dbGetObject(Organisation.CarID);
    Building build = dbGetObject(Organisation.BuildingID);
    S32 result = FAHN_ESCAPED;
    U8 palette[GFX_PALETTE_SIZE];

    if ((Organisation.BuildingID != Building_Tower_of_London) &&
	(Organisation.BuildingID != Building_Starford_Kaserne)) {
	wayType = build->EscapeRoute;
	length = build->EscapeRouteLength;

	kmh = car->Speed;
	ps = car->PS;

	/* Motor : pro 10% Schaden -> 5% Leistung weniger */
	kmh = CalcValue(kmh, 0, 65535L, (car->MotorState) / 2, 50);
	ps = CalcValue(ps, 0, 65535L, (car->MotorState) / 2, 50);

	/* pro Jahr 3% weniger */
	i = (car->Speed * 3 * (tcRGetCarAge(car) + 1)) / 100;
	j = (car->PS * 3 * (tcRGetCarAge(car) + 1)) / 100;

	if (kmh >= i)
	    kmh -= i;
	else
	    kmh = 0;

	if (ps >= j)
	    ps -= j;
	else
	    ps = 0;

	/* Reifen pro 10% um 2% weniger */
	i = (car->Speed * 2 * (255 - car->TyreState)) / 2500;
	j = (car->Speed * 2 * (255 - car->PS)) / 2500;

	if (kmh >= i)
	    kmh -= i;
	else
	    kmh = 0;

	if (ps >= j)
	    ps -= j;
	else
	    ps = 0;

	/* Fahrer */
	/* kann aus einem Auto um ein Viertel mehr herausholen, als eigentlich */
	/* drinnen ist! */
	i = hasGet(Organisation.DriverID, Ability_Autos);
	kmh =
	    CalcValue(kmh, 0, car->Speed + car->Speed / 4, i,
		      driverWeight[wayType]);
	ps = CalcValue(ps, 0, car->PS + car->PS / 4, i, driverWeight[wayType]);

	/* Ma�zahl f�r Geschwindigkeit */
	/* Einheit = m pro Schleifendurchlauf */
	unrealSpeed = (kmh * kmhWeight[wayType] + ps * psWeight[wayType]) / 100;

	unrealSpeed = unrealSpeed + 5 - (S32) (CalcRandomNr(0, 10));

	if (unrealSpeed <= 0)
	    unrealSpeed = 5;

	policeSpeed[wayType] = policeSpeed[wayType] + 5 - CalcRandomNr(0, 10);
	policeSpeed[wayType] =
	    CalcValue(policeSpeed[wayType], 0, 255, build->GRate, 25);

	/* Vorsprung berechnen */
	/* Vorsprung ist maximal die halbe Strecke (length * 500 m) und */
	/* mindestens 2000 Meter (damit man von der Fluct etwas sieht!) */

	i = min(((unrealSpeed * timeLeft) / 5), length * 500);
	i = max(2000, i);	/* mindestens 2000 Meter */

	j = 0;
	length *= 1000;		/* Fluchtweg in Meter */

	/* Bildschirmdarstellung */

	txtGetFirstLine(BUSINESS_TXT, "FLUCHT", line);
	ShowMenuBackground();
	PrintStatus(line);

	gfxChangeColors(l_gc, 0, GFX_FADE_OUT, 0);
	gfxShow(car->PictID, GFX_NO_REFRESH | GFX_ONE_STEP, 0, -1, -1);

	gfxPrepareColl(GFX_COLL_PARKING);
	gfxGetPalette(GFX_COLL_PARKING, palette);

	gfxChangeColors(l_gc, 0, GFX_BLEND_UP, palette);
	SetCarColors(car->ColorIndex);

	gfxSetPens(l_gc, 20, GFX_SAME_PEN, 21);
	gfxRectFill(l_gc, 60, 40, 60 + 199, 40 + 19);

	i = max(i, 60);
	j = max(j, 5);

	sndPrepareFX("flucht.voc");
	sndPlayFX();

	do {
	    i += unrealSpeed;	/* KmH von Matt */
	    i = max(i, 0);

	    paint = 0;

	    if (Search.TimeOfAlarm)
		j += policeSpeed[wayType];

	    YardsInFront = i - j;	/* zum Vorsprung addieren */

	    /* Berechnung der Darstellung */
	    x = (i * 190) / length;	/* Matts Car */

	    if (x != xOldMatt) {
		if (xOldMatt != -1) {
		    gfxSetPens(l_gc, 20, GFX_SAME_PEN, 20);

		    if ((195 - x + 1) < (198 + 195 - xOldMatt))
			gfxRectFill(l_gc, 60 + 195 - xOldMatt, 45,
				    60 + 198 - xOldMatt, 55);
		}

		gfxSetPens(l_gc, 11, GFX_SAME_PEN, 11);
		gfxRectFill(l_gc, 60 + 195 - x, 45, 60 + 198 - x, 55);

		xOldMatt = x;
		paint = 1;
	    }

	    if (Search.TimeOfAlarm) {	/* Police Car */
		x = (j * 190) / length;

		if (x != xOldPoli) {
		    if (xOldPoli != -1) {
			gfxSetPens(l_gc, 20, GFX_SAME_PEN, 20);
			gfxRectFill(l_gc, 60 + 195 - xOldPoli, 45,
				    60 + 198 - xOldPoli, 55);
		    }

		    gfxSetPens(l_gc, 23, GFX_SAME_PEN, 23);
		    gfxRectFill(l_gc, 60 + 195 - x, 45, 60 + 198 - x, 55);

		    paint = 1;
		}

		xOldPoli = x;
	    }

	    if (paint)
		inpDelay(3);
	}
	while ((i < length) && (YardsInFront > 50));

	if (YardsInFront > 50)
	    result = FAHN_ESCAPED;
	else
	    result = FAHN_NOT_ESCAPED;
    }

    return result;
}
示例#3
0
文件: evidence.c 项目: vcosta/derclou
U32 tcStartEvidence(void)
{
    S32 MyEvidence[4][7], guarded, radio;
    U32 totalEvidence[7], i, j, shownEvidence[4], Recognition[4], caught = 0;
    ubyte guyReady, guyNr, evidenceNr, guyCount, shown = 0;
    char line[TXT_KEY_LENGTH];
    Person p[4];
    Evidence evidence = dbGetObject(Evidence_Evidence_1);	/* just for presentation */
    struct ObjectNode *n;
    LIST *guys, *spuren;

    if ((!(Search.EscapeBits & FAHN_ALARM))
	&& (!(Search.EscapeBits & FAHN_QUIET_ALARM)))
	Say(BUSINESS_TXT, 0, ((Person) dbGetObject(Person_John_Gludo))->PictID,
	    "A_BURGLARY_SIR");

    Say(BUSINESS_TXT, 0,
	((Person) dbGetObject(Person_Miles_Chickenwing))->PictID,
	"START_EVIDENCE");

    joined_byAll(Person_Matt_Stuvysunt, OLF_PRIVATE_LIST, Object_Person);
    guys = ObjectListPrivate;
    dbSortObjectList(&guys, dbStdCompareObjects);

    guyCount = (ubyte) GetNrOfNodes(guys);
    spuren = txtGoKey(BUSINESS_TXT, "SPUREN");

    p[0] = p[1] = p[2] = p[3] = NULL;

    guarded = ChangeAbs(((Building) dbGetObject(Search.BuildingId))->GRate,
			((Building) dbGetObject(Search.BuildingId))->Strike / 7,
			0, 255);

    radio = (S32) ((Building) dbGetObject(Search.BuildingId))->RadioGuarding;

    for (n = (struct ObjectNode *) LIST_HEAD(guys), i = 0; NODE_SUCC(n);
	 n = (struct ObjectNode *) NODE_SUCC(n), i++) {
	S32 div = 380;

	p[i] = OL_DATA(n);

	/* alle folgenden Werte sind zwischen 0 und 255 */

	/* statt durch 765 zu dividieren wurde urspr�nglich durch 255 dividiert -> */
	/* viel zu gro�e Werte */

	if (Search.SpotTouchCount[i])
	    div = 1;

	MyEvidence[i][0] =
	    (((tcGetTrail(p[i], 0) * (S32) Search.WalkTime[i] *
	       (max(1, 255 - guarded))) / ((S32) Search.TimeOfBurglary +
					   1))) / div;
	MyEvidence[i][1] =
	    (((tcGetTrail(p[i], 1) * (S32) Search.WaitTime[i] *
	       (max(1, 255 - guarded))) / ((S32) Search.TimeOfBurglary +
					   1))) / div;
	MyEvidence[i][2] =
	    (((tcGetTrail(p[i], 2) * (S32) Search.WorkTime[i] *
	       (max(1, 255 - guarded))) / ((S32) Search.TimeOfBurglary +
					   1))) / div;
	MyEvidence[i][3] =
	    (((tcGetTrail(p[i], 3) * (S32) Search.KillTime[i] *
	       (max(1, 255 - guarded))) / ((S32) Search.TimeOfBurglary + 1)));
	MyEvidence[i][4] =
	    ChangeAbs(0, (S32) Search.CallCount * (S32) radio / 5, 0, 255);
	MyEvidence[i][5] =
	    (p[i]->KnownToPolice * (max(1, guarded))) / (div * 3);
	MyEvidence[i][6] =
	    ChangeAbs(0,
		      (S32) CalcRandomNr(200,
					 255) * (S32) Search.SpotTouchCount[i],
		      0, 255);

	for (j = 0; j < 7; j++)	/* jeden Betrag != 0 AUFRUNDEN auf 1% ! */
	    if (MyEvidence[i][j])
		MyEvidence[i][j] = max(MyEvidence[i][j], 5);

	if (has(Person_Matt_Stuvysunt, Tool_Maske))
	    MyEvidence[i][6] = (MyEvidence[i][6] * 2) / 3;

	/* im Fluchtfall viele Gehspuren! */
	if (Search.EscapeBits & FAHN_ESCAPE)
	    MyEvidence[i][0] =
		CalcValue(MyEvidence[i][0], CalcRandomNr(80, 120), 255, 255,
			  50);

	totalEvidence[i] =
	    MyEvidence[i][0] + MyEvidence[i][1] + MyEvidence[i][2] +
	    MyEvidence[i][3] + MyEvidence[i][4] + MyEvidence[i][5] +
	    MyEvidence[i][6];

	shownEvidence[i] = Recognition[i] = 0;

	tcPersonLearns(OL_NR(n));
    }

    prSetBarPrefs(m_gc, 300, 12, 1, 3, 0);

    guyReady = 0;
    txtGetFirstLine(BUSINESS_TXT, "FAHNDUNG", line);

    while (guyReady != ((1 << guyCount) - 1)) {
	if (shown) {
	    ShowTime(0);
	    inpDelay(35L);
	    AddVTime(CalcRandomNr(1, 11));

	    shown = 0;
	}

	guyNr = CalcRandomNr(0, guyCount);

	/* wer ist den noch nicht fertig? */
	while ((1 << guyNr) & guyReady)
	    guyNr = (guyNr + 1) % guyCount;

	/* bei folgendem CalcRandomNr darf nicht 4 - guyCount stehe, sonst
	 * Division durch 0!
	 */

	/* zuf�llig eine Spurenart ausw�hlen */
	evidenceNr = CalcRandomNr(0, 7);

	/* wenn diese Spurenart schon angzeigt wurde, eine freie
	 * Spur suchen
	 */
	j = 0;

	while (((1 << evidenceNr) & shownEvidence[guyNr]) && (j++ < 7))
	    evidenceNr = (evidenceNr + 1) % 7;

	if (j < 8) {		/* 8 stimmt! -> ober wird anschlie�end noch erh�ht */
	    shownEvidence[guyNr] |= (1 << evidenceNr);

	    if (MyEvidence[guyNr][evidenceNr] > 0) {
		ShowMenuBackground();
		PrintStatus(NODE_NAME(GetNthNode(spuren, evidenceNr)));

		Recognition[guyNr] += MyEvidence[guyNr][evidenceNr];

		evidence->Recognition = Recognition[guyNr] / 3;	/* change also: totalEvidence /= 3.... */
		evidence->pers = (U32) OL_NR(GetNthNode(guys, (U32) guyNr));

		/* f�r alle "Evidences" - stimmt so, da f�r alle */
		/* Personen die selbe Evidence Struct benutzt wird -> */
		/* bestimmte Werte sind von vorher gesetzt und m�ssen gel�scht */
		/* werden */

		evidence->WalkTrail = 0;
		evidence->WaitTrail = 0;
		evidence->WorkTrail = 0;
		evidence->KillTrail = 0;
		evidence->CallTrail = 0;
		evidence->PaperTrail = 0;
		evidence->FotoTrail = 0;

		if (shownEvidence[guyNr] & 1)
		    evidence->WalkTrail = MyEvidence[guyNr][0];

		if (shownEvidence[guyNr] & 2)
		    evidence->WaitTrail = MyEvidence[guyNr][1];

		if (shownEvidence[guyNr] & 4)
		    evidence->WorkTrail = MyEvidence[guyNr][2];

		if (shownEvidence[guyNr] & 8)
		    evidence->KillTrail = MyEvidence[guyNr][3];

		if (shownEvidence[guyNr] & 16)
		    evidence->CallTrail = MyEvidence[guyNr][4];

		if (shownEvidence[guyNr] & 32)
		    evidence->PaperTrail = MyEvidence[guyNr][5];

		if (shownEvidence[guyNr] & 64)
		    evidence->FotoTrail = MyEvidence[guyNr][6];

		Present(Evidence_Evidence_1, "Fahndung", InitEvidencePresent);

		ShowMenuBackground();
		PrintStatus(line);

		shown = 1;
	    }
	}

	if (shownEvidence[guyNr] == ((1 << 7) - 1))
	    guyReady |= (1 << guyNr);
    }

    guyReady = 0;

    /* ein gewisses Restwissen bleibt der Polizei ! */
    for (i = 0; i < guyCount; i++) {
	totalEvidence[i] /= 3;	/* change als in recognition = ... */

	if (p[i] != 0) {
	    if (totalEvidence[i] > 255)
		totalEvidence[i] = 255;

	    p[i]->KnownToPolice = (ubyte) (totalEvidence[i]);

	    if (p[i]->KnownToPolice > tcPERSON_IS_ARRESTED)
		caught |= tcPersonWanted(OL_NR(GetNthNode(guys, i)));

	    if (!caught)
		if (p[i] == dbGetObject(Person_Robert_Bull))
		    caught |= tcATraitor(Person_Robert_Bull);

	    if (!caught)
		if (p[i] == dbGetObject(Person_Marc_Smith))
		    caught |= tcATraitor(Person_Marc_Smith);

            if (setup.Profidisk) {
	        if (!caught)
		    if (p[i] == dbGetObject(Person_Phil_Ciggy))
		        caught |= tcATraitor(Person_Phil_Ciggy);
            }
	}
    }

    caught |= tcIsThereATraitor();

    if (!
	(tcCarFound
	 ((Car) dbGetObject(Organisation.CarID),
	  Search.TimeOfBurglary - Search.TimeOfAlarm))) {
	S32 newStrike;
	Car car = dbGetObject(Organisation.CarID);

	newStrike = CalcValue((S32) car->Strike, 0, 255, 255, 15);

	if (newStrike < (car->Strike + 40))
	    newStrike = ChangeAbs((S32) car->Strike, 40, 0, 255);

	car->Strike = newStrike;
    }

    ((Player) dbGetObject(Player_Player_1))->MattsPart =
	(ubyte) tcCalcMattsPart();
    tcForgetGuys();

    RemoveList(spuren);
    RemoveList(guys);

    return caught;
}