Beispiel #1
0
void LogBanFromName(std::string BannedName, int UserIndex, std::string Motivo) {
	WriteVar(GetLogFileName("BanDetail"), BannedName, "BannedBy",
			UserList[UserIndex].Name);
	WriteVar(GetLogFileName("BanDetail"), BannedName, "Reason", Motivo);

	LogGenteBanned(BannedName);
}
void DoWrite() {
  Match('(');
  Expression();
  WriteVar();
    NewLine();
  while(Look == ',') {
    Match(',');
    Expression();
    WriteVar();
    NewLine();
  }
  Match(')');
}
Beispiel #3
0
/* refresh vars of the steps (activity+time) */
void RefreshStepsVars( void )
{
	int NumStep;
	for( NumStep=0; NumStep<NBR_STEPS; NumStep++ )
	{
		if ( Sequential->Step[ NumStep ].Activated )
			Sequential->Step[ NumStep ].TimeActivated += InfosGene->GeneralParams.PeriodicRefreshMilliSecs;
		else
			Sequential->Step[ NumStep ].TimeActivated = 0;

		/* refresh the vars for the step number associated to this step */
		WriteVar( VAR_STEP_ACTIVITY, Sequential->Step[ NumStep ].StepNumber, Sequential->Step[ NumStep ].Activated );
		WriteVar( VAR_STEP_TIME, Sequential->Step[ NumStep ].StepNumber, Sequential->Step[ NumStep ].TimeActivated/1000 );
	}
}
void CopyPropagation::TransformCopyInst(TACInstPtr& inst)
{
    auto copyInst = static_cast<TACCopyInst*>(inst.get());

    if (!copyInst->src.IsLabel())
    {
        /* Propagate copy */
        ReadVar(copyInst->src);
        WriteVar(copyInst->dest, copyInst->src);
    }
}
Beispiel #5
0
static gint chkvar_press_event( GtkWidget      *widget, void * numcheck )
{
	long NumCheckWidget = (long)numcheck;
	int Type = VAR_MEM_BIT;
	int Offset = ValOffsetBoolVar[ 0 ];
	int NumCheck = NumCheckWidget;
	if( NumCheckWidget>=NBR_BOOLS_VAR_SPY && NumCheckWidget<2*NBR_BOOLS_VAR_SPY )
	{
		Type = VAR_PHYS_INPUT;
		Offset = ValOffsetBoolVar[ 1 ];
		NumCheck -= NBR_BOOLS_VAR_SPY;
	} 
	if( NumCheckWidget>=2*NBR_BOOLS_VAR_SPY && NumCheckWidget<3*NBR_BOOLS_VAR_SPY )
	{
		Type = VAR_PHYS_OUTPUT;
		Offset = ValOffsetBoolVar[ 2 ];
		NumCheck -= 2*NBR_BOOLS_VAR_SPY;
	} 
	if (gtk_toggle_button_get_active((GtkToggleButton *)widget))
		WriteVar(Type,Offset+NumCheck,1);
	else
		WriteVar(Type,Offset+NumCheck,0);
	return TRUE;
}
Beispiel #6
0
static void WriteIndex (void)
/* Write the index of a library file */
{
    unsigned I;

    /* Sync I/O in case the last operation was a read */
    fseek (NewLib, 0, SEEK_CUR);

    /* Remember the current offset in the header */
    Header.IndexOffs = ftell (NewLib);

    /* Write the object file count */
    WriteVar (NewLib, CollCount (&ObjPool));

    /* Write the object files */
    for (I = 0; I < CollCount (&ObjPool); ++I) {
        WriteIndexEntry (CollConstAt (&ObjPool, I));
    }
}
Beispiel #7
0
/* VarDest := ArithmExpr */
void MakeCalc(char * CalcString,int VerifyMode)
{
	char StrCopy[ARITHM_EXPR_SIZE+1]; /* used for putting null char after first expr */
	int TargetVarType,TargetVarOffset;
	int  Found = FALSE;

	/* null expression ? */
	if (*CalcString=='\0' || *CalcString=='#')
		return;

	strcpy(StrCopy,CalcString);

	Expr = StrCopy;
	if (IdentifyFinalVar(Expr,&TargetVarType,&TargetVarOffset))
	{
		/* flush var found */
		Expr++;
		do
		{
			Expr++;
		}
		while( (*Expr!='@') && (*Expr!='\0') );
		Expr++;
		/* verify if there is the '=' or ':=' */
		do
		{
			if (*Expr==':')
				Expr++;
			if (*Expr=='=')
			{
				Found = TRUE;
				Expr++;
			}
			if (*Expr==' ')
				Expr++;
		}
		while( !Found && *Expr!='\0' );
		while( *Expr==' ')
			Expr++;
		if (Found)
		{
			arithmtype EvalExpr;
//printf("Calc - Eval String=%s\n",Expr);
			EvalExpr = EvalExpression(Expr);
//printf("Calc - Result=%d\n",EvalExpr);
			if (!VerifyMode)
			{
				WriteVar(TargetVarType,TargetVarOffset,(int)EvalExpr);
			}
#ifdef GTK_INTERFACE
			else
			{
				if ( !TestVarIsReadWrite( TargetVarType, TargetVarOffset ) )
				{
					ErrorDesc = "Target variable must be read/write !";
					SyntaxError();
				}
			}
#endif
		}
		else
		{
			ErrorDesc = "Missing := to make operate";
			SyntaxError();
		}
	}
}
Beispiel #8
0
void HalReads32Inputs(void) {
	int i;
	for( i=0; i<InfosGene->GeneralParams.SizesInfos.nbr_phys_words_inputs; i++) {
		WriteVar(VAR_PHYS_WORD_INPUT, i, *hal_s32_inputs[i]);
	}
}	
Beispiel #9
0
void HalReadPhysicalInputs(void) {
	int i;
	for( i=0; i<InfosGene->GeneralParams.SizesInfos.nbr_phys_inputs; i++) {
		WriteVar(VAR_PHYS_INPUT, i, *hal_inputs[i]);
	}
}
Beispiel #10
0
void HalReadFloatInputs(void) {
	int i;
	for( i=0; i<InfosGene->GeneralParams.SizesInfos.nbr_phys_float_inputs; i++) {
		WriteVar(VAR_PHYS_FLOAT_INPUT, i, *hal_float_inputs[i]);
	}
}	
Beispiel #11
0
/* ' @param Cantidad Specifies how many items in that slot are you trying to sell / buy */
void Comercio(eModoComercio Modo, int UserIndex, int NpcIndex, int Slot, int Cantidad) {
	/* '************************************************* */
	/* 'Author: Nacho (Integer) */
	/* 'Last modified: 07/06/2010 */
	/* '27/07/08 (MarKoxX) | New changes in the way of trading (now when you buy it rounds to ceil and when you sell it rounds to floor) */
	/* '  - 06/13/08 (NicoNZ) */
	/* '07/06/2010: ZaMa - Los objetos se loguean si superan la cantidad de 1k (antes era solo si eran 1k). */
	/* '************************************************* */
	int Precio;
	struct Obj Objeto;

	if (Cantidad < 1 || Slot < 1) {
		return;
	}

	if (Modo == eModoComercio_Compra) {
		if (Slot > MAX_INVENTORY_SLOTS) {
			return;
		} else if (Cantidad > MAX_INVENTORY_OBJS) {
			SendData(SendTarget_ToAll, 0,
					dakara::protocol::server::BuildConsoleMsg(
							UserList[UserIndex].Name + " ha sido baneado por el sistema anti-cheats.",
							FontTypeNames_FONTTYPE_FIGHT));
			Ban(UserList[UserIndex].Name, "Sistema Anti Cheats",
					"Intentar hackear el sistema de comercio. Quiso comprar demasiados ítems:" + vb6::CStr(Cantidad));
			UserList[UserIndex].flags.Ban = 1;
			WriteErrorMsg(UserIndex, "Has sido baneado por el Sistema AntiCheat.");
			FlushBuffer(UserIndex);
			CloseSocket(UserIndex);
			return;
		} else if (!(Npclist[NpcIndex].Invent.Object[Slot].Amount > 0)) {
			return;
		}

		if (Cantidad > Npclist[NpcIndex].Invent.Object[Slot].Amount) {
			Cantidad = Npclist[UserList[UserIndex].flags.TargetNPC].Invent.Object[Slot].Amount;
		}

		Objeto.Amount = Cantidad;
		Objeto.ObjIndex = Npclist[NpcIndex].Invent.Object[Slot].ObjIndex;

		/* 'El precio, cuando nos venden algo, lo tenemos que redondear para arriba. */
		/* 'Es decir, 1.1 = 2, por lo cual se hace de la siguiente forma Precio = Clng(PrecioFinal + 0.5) Siempre va a darte el proximo numero. O el "Techo" (MarKoxX) */

		Precio = vb6::CLng(
				(ObjData[Npclist[NpcIndex].Invent.Object[Slot].ObjIndex].Valor / Descuento(UserIndex)
						* Cantidad) + 0.5);

		if (UserList[UserIndex].Stats.GLD < Precio) {
			WriteConsoleMsg(UserIndex, "No tienes suficiente dinero.", FontTypeNames_FONTTYPE_INFO);
			return;
		}

		if (MeterItemEnInventario(UserIndex, Objeto) == false) {
			/* 'Call WriteConsoleMsg(UserIndex, "No puedes cargar mas objetos.", FontTypeNames.FONTTYPE_INFO) */
			EnviarNpcInv(UserIndex, UserList[UserIndex].flags.TargetNPC);
			WriteTradeOK(UserIndex);
			return;
		}

		UserList[UserIndex].Stats.GLD = UserList[UserIndex].Stats.GLD - Precio;

		QuitarNpcInvItem(UserList[UserIndex].flags.TargetNPC, vb6::CByte(Slot), Cantidad);

		/* 'Bien, ahora logueo de ser necesario. Pablo (ToxicWaste) 07/09/07 */
		/* 'Es un Objeto que tenemos que loguear? */
		if (ObjData[Objeto.ObjIndex].Log == 1) {
			LogDesarrollo(
					UserList[UserIndex].Name + " compró del NPC " + std::to_string(Objeto.Amount) + " "
							+ ObjData[Objeto.ObjIndex].Name);
			/* 'Es mucha cantidad? */
		} else if (Objeto.Amount >= 1000) {
			/* 'Si no es de los prohibidos de loguear, lo logueamos. */
			if (ObjData[Objeto.ObjIndex].NoLog != 1) {
				LogDesarrollo(
						UserList[UserIndex].Name + " compró del NPC " + std::to_string(Objeto.Amount) + " "
								+ ObjData[Objeto.ObjIndex].Name);
			}
		}

		/* 'Agregado para que no se vuelvan a vender las llaves si se recargan los .dat. */
		if (ObjData[Objeto.ObjIndex].OBJType == eOBJType_otLlaves) {
			WriteVar(GetDatPath(DATPATH::NPCs),
					"NPC" + vb6::CStr(Npclist[NpcIndex].Numero),
					"obj" + vb6::CStr(Slot),
					vb6::CStr(Objeto.ObjIndex) + "-0");
			logVentaCasa(UserList[UserIndex].Name + " compró " + ObjData[Objeto.ObjIndex].Name);
		}

	} else if (Modo == eModoComercio_Venta) {

		if (Cantidad > UserList[UserIndex].Invent.Object[Slot].Amount) {
			Cantidad = UserList[UserIndex].Invent.Object[Slot].Amount;
		}

		Objeto.Amount = Cantidad;
		Objeto.ObjIndex = UserList[UserIndex].Invent.Object[Slot].ObjIndex;

		if (Objeto.ObjIndex == 0) {
			return;

		} else if (ObjData[Objeto.ObjIndex].Intransferible == 1
				|| ObjData[Objeto.ObjIndex].NoComerciable == 1) {
			WriteConsoleMsg(UserIndex, "No puedes vender este tipo de objeto.", FontTypeNames_FONTTYPE_INFO);
			return;
		} else if ((Npclist[NpcIndex].TipoItems != ObjData[Objeto.ObjIndex].OBJType
				&& Npclist[NpcIndex].TipoItems != eOBJType_otCualquiera) || Objeto.ObjIndex == iORO) {
			WriteConsoleMsg(UserIndex, "Lo siento, no estoy interesado en este tipo de objetos.",
					FontTypeNames_FONTTYPE_INFO);
			EnviarNpcInv(UserIndex, UserList[UserIndex].flags.TargetNPC);
			WriteTradeOK(UserIndex);
			return;
		} else if (ObjData[Objeto.ObjIndex].Real == 1) {
			if (Npclist[NpcIndex].Name != "SR") {
				WriteConsoleMsg(UserIndex,
						"Las armaduras del ejército real sólo pueden ser vendidas a los sastres reales.",
						FontTypeNames_FONTTYPE_INFO);
				EnviarNpcInv(UserIndex, UserList[UserIndex].flags.TargetNPC);
				WriteTradeOK(UserIndex);
				return;
			}
		} else if (ObjData[Objeto.ObjIndex].Caos == 1) {
			if (Npclist[NpcIndex].Name != "SC") {
				WriteConsoleMsg(UserIndex,
						"Las armaduras de la legión oscura sólo pueden ser vendidas a los sastres del demonio.",
						FontTypeNames_FONTTYPE_INFO);
				EnviarNpcInv(UserIndex, UserList[UserIndex].flags.TargetNPC);
				WriteTradeOK(UserIndex);
				return;
			}
		} else if (UserList[UserIndex].Invent.Object[Slot].Amount < 0 || Cantidad == 0) {
			return;
		} else if (Slot<vb6::LBound(UserList[UserIndex].Invent.Object) || Slot>vb6::UBound(UserList[UserIndex].Invent.Object)) {
			EnviarNpcInv(UserIndex, UserList[UserIndex].flags.TargetNPC);
			return;
		} else if (UserTienePrivilegio(UserIndex, PlayerType_Consejero)) {
			WriteConsoleMsg(UserIndex, "No puedes vender ítems.", FontTypeNames_FONTTYPE_WARNING);
			EnviarNpcInv(UserIndex, UserList[UserIndex].flags.TargetNPC);
			WriteTradeOK(UserIndex);
			return;
		}

		QuitarUserInvItem(UserIndex, Slot, Cantidad);

		/* 'Precio = Round(ObjData(Objeto.ObjIndex).valor / REDUCTOR_PRECIOVENTA * Cantidad, 0) */
		Precio = vb6::Fix(SalePrice(Objeto.ObjIndex) * Cantidad);
		UserList[UserIndex].Stats.GLD = UserList[UserIndex].Stats.GLD + Precio;

		if (UserList[UserIndex].Stats.GLD > MAXORO) {
			UserList[UserIndex].Stats.GLD = MAXORO;
		}

		int NpcSlot;
		NpcSlot = SlotEnNPCInv(NpcIndex, Objeto.ObjIndex, Objeto.Amount);

		/* 'Slot valido */
		if (NpcSlot <= MAX_INVENTORY_SLOTS) {
			/* 'Mete el obj en el slot */
			Npclist[NpcIndex].Invent.Object[NpcSlot].ObjIndex = Objeto.ObjIndex;
			Npclist[NpcIndex].Invent.Object[NpcSlot].Amount = Npclist[NpcIndex].Invent.Object[NpcSlot].Amount
					+ Objeto.Amount;
			if (Npclist[NpcIndex].Invent.Object[NpcSlot].Amount > MAX_INVENTORY_OBJS) {
				Npclist[NpcIndex].Invent.Object[NpcSlot].Amount = MAX_INVENTORY_OBJS;
			}
		}

		/* 'Bien, ahora logueo de ser necesario. Pablo (ToxicWaste) 07/09/07 */
		/* 'Es un Objeto que tenemos que loguear? */
		if (ObjData[Objeto.ObjIndex].Log == 1) {
			LogDesarrollo(
					UserList[UserIndex].Name + " vendió al NPC " + std::to_string(Objeto.Amount) + " "
							+ ObjData[Objeto.ObjIndex].Name);
			/* 'Es mucha cantidad? */
		} else if (Objeto.Amount >= 1000) {
			/* 'Si no es de los prohibidos de loguear, lo logueamos. */
			if (ObjData[Objeto.ObjIndex].NoLog != 1) {
				LogDesarrollo(
						UserList[UserIndex].Name + " vendió al NPC " + std::to_string(Objeto.Amount) + " "
								+ ObjData[Objeto.ObjIndex].Name);
			}
		}

	}

	UpdateUserInv(true, UserIndex, 0);
	WriteUpdateUserStats(UserIndex);
	EnviarNpcInv(UserIndex, UserList[UserIndex].flags.TargetNPC);
	WriteTradeOK(UserIndex);

	SubirSkill(UserIndex, eSkill_Comerciar, true);
}