Exemplo n.º 1
0
local void FlagGain(Arena *a, Player *p, int fid, int how)
{
	DEF_AD(a);
	BDEF_PD(p);

	if(how == FLAGGAIN_PICKUP)
	{
		FlagOwner *owner = ad->FlagOwners[fid];
		if(owner)
		{
			FlagTeam *team = GetFlagTeam(a, owner->Freq);
			team->DroppedFlags--;

			Player *ownerp = pd->FindPlayer(owner->Name);
			if(ownerp)
			{
				pdat = BPD(ownerp);
				if(pdat->DroppedFlags > 0) //could be left over from when they were on another team
				{
					pdat->DroppedFlags--;
				}
			}

			MYGLOCK;
			ad->FlagOwners[fid] = NULL;
			afree(owner);
			MYGUNLOCK;
		}
	}
}
Exemplo n.º 2
0
void test_high_order_interpolation() {
    bcon bc_child_doc[] = { "k10", "v10", "k11", "v11", BEND };
    bcon bc_parent_doc[] = { "k0", "v0", "k1", BPD(bc_child_doc), "k2", "v2", BEND };
    test_bson_from_bcon( bc_parent_doc, BCON_OK, BSON_VALID );
    bcon bc_child_array[] = { "k10", "v10", "k11", "v11", BEND };
    bcon bc_parent_doc_array[] = { "k0", "v0", "k1", BPA(bc_child_array), "k2", "v2", BEND };
    test_bson_from_bcon( bc_parent_doc_array, BCON_OK, BSON_VALID );
}
Exemplo n.º 3
0
local int UpdateScores(void *a)
{
	DEF_AD((Arena *)a);
	myPDType *pdata;

	for(int i = 0; i < MAXFLAGS; i++)
	{
		FlagOwner *owner = ad->FlagOwners[i];
		if(owner)
		{
			//lm->LogA(L_ERROR, "hs_flagtime", a, "owner of flag %d is %s", i, owner->Name);
			Player *p = pd->FindPlayer(owner->Name);
			if(p && p->pkt.freq == owner->Freq)
			{
				pdata = BPD(p);
				pdata->FlagSeconds++;
			}

			FlagTeam *team = GetFlagTeam(a, owner->Freq);
			team->FlagSeconds++;

			MYGLOCK;
			int *seconds = HashGetOne(team->Breakdown, owner->Name);
			if(seconds)
			{
				*seconds = *seconds + 1;
				HashReplace(team->Breakdown, owner->Name, seconds);
				//lm->LogA(L_ERROR, "hs_flagtime", a, "%s flag seconds: %d", owner->Name, *seconds);
			}
			else
			{
				seconds = amalloc(sizeof(*seconds));
				*seconds = 1;
				HashReplace(team->Breakdown, owner->Name, seconds);
				//lm->LogA(L_ERROR, "hs_flagtime", a, "%s new flag seconds: %d", owner->Name, *seconds);
			}
			MYGUNLOCK;

		}
	}
	return TRUE;
}