示例#1
0
文件: errhnd.cpp 项目: 089git/calibre
void ErrorHandler::WriteError(const char *ArcName,const wchar *ArcNameW,const char *FileName,const wchar *FileNameW)
{
#ifndef SILENT
  WriteErrorMsg(ArcName,ArcNameW,FileName,FileNameW);
#endif
#if !defined(SILENT) || defined(RARDLL)
  Throw(RARX_WRITE);
#endif
}
示例#2
0
文件: errhnd.cpp 项目: alown/iViewer
void ErrorHandler::WriteError(const char *ArcName,const char *FileName)
{
#ifndef SILENT
  WriteErrorMsg(ArcName,FileName);
#endif
#if !defined(SILENT) || defined(RARDLL)
  Throw(WRITE_ERROR);
#endif
}
/*BOOL WriteToPort(char* lpBuf)
*Purpose: Writes characters typed to the port.
*Arg 1 - Buffer for characters receivedfrom the port.
*/
BOOL WriteToPort(char* lpBuf) {
   OVERLAPPED osWrite = {0};
   DWORD dwWritten;

   //Create this write operation's OVERLAPPED structure's hEvent.
   osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
   if(osWrite.hEvent == NULL)
      // error creating overlapped event handle
      return FALSE;

   if(!WriteFile(hComm, lpBuf, 1, &dwWritten, &osWrite)) {
      if(GetLastError() != ERROR_IO_PENDING) {
		  WriteErrorMsg();
		  return FALSE;
      }
   }
   CloseHandle(osWrite.hEvent);
   return TRUE;
}
示例#4
0
void DbgOut(char* msg){
	WriteErrorMsg("c:\\users\\nathan\\Desktop\\com_objectivemedia_dbg.txt", msg);
        //printf(msg);
}
示例#5
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);
}
示例#6
0
文件: fileio.c 项目: ekstroem/pedipet
void importlinkagepedigree (void)
{
  char minibuf[NAMESIZE];
  individual *ind, *ind2;
  

  //  IDlist *idlist;
  markerlist *marker;
  namelist *nl;
  quanttrait *qt;
  int i, families, persons, nmarkers, ntraits, code;

  printf("Number of markers in file: ");
  InputLine(buf, BUFFERSIZE);
  nmarkers = atoip(buf);

  printf("Number of traits in file : ");
  InputLine(buf, BUFFERSIZE);
  ntraits = atoip(buf);

  printf ("Name of linkage pedigree file to input: ");
  InputLine(buf, BUFFERSIZE);
  cfopen (buf,"r");

  getbuf ();

  persons = 0;
  families = 0;

  if (options->Index[O_CONVERTLINKAGEID])
    printf("WARNING: ID's are converted from number to fam-number\n");

  while (buf[0] != EOF)
  {

    // If empty line then read next line
    if (!buf[0] || !strpbrk(buf, "0123456789"))
    {
      getbuf ();
      continue;
    }

    ind = newperson ();
    persons++;
    ind->globalid = persons;
    ind->localid = persons;

    strcpy(ind->pedigree, igetstr (buf));
    strcpy(ind->id, getstr ());

    strcpy(ind->tmpstr1, getstr ()); // Father ID
    strcpy(ind->tmpstr2, getstr ()); // Mother ID

    // If conversion of IDs
    if (options->Index[O_CONVERTLINKAGEID]) {
      sprintf(minibuf,"%s-%s", ind->pedigree,ind->id);
      strcpy(ind->id,minibuf);
      sprintf(minibuf, "%s-%s", ind->pedigree,ind->tmpstr1);
      strcpy(ind->tmpstr1,minibuf);
      sprintf(minibuf, "%s-%s", ind->pedigree,ind->tmpstr2);
      strcpy(ind->tmpstr2,minibuf);
    }
    switch (geti ())
    {
      case  1 : ind->sex = S_MALE; break;
      case  2 : ind->sex = S_FEMALE; break;
      default : ind->sex = S_UNKNOWN;
    }
//    atof(getstr());

    for (i = 0 ; i<nmarkers; i++)
    {
      marker = cmalloc (sizeof (markerlist));
      memset (marker,0,sizeof (markerlist));
      marker->allele1 = geti();
      marker->allele2 = geti ();

      addlist(&ind->marker, marker);
    }

    // Reading traits
    for (i = 0 ; i<ntraits; i++)
    {
      qt = cmalloc (sizeof (quanttrait));
      memset (qt,0,sizeof (quanttrait));
      ReadATrait(qt);

      addlist(&ind->qttrait,qt);
    }

//    printf("\n");
    getbuf ();
  }

  fclose (F);
  printf ("%d persons from %d pedigree(s) read\n", 
          persons, numberofpedigrees());

  code = 0;
  // Should now fix fathers and mothers
  forind
  {
    ind->father = findperson(ind->tmpstr1);
    ind->mother = findperson(ind->tmpstr2);

    // if a person has a father and a mother, then add the
    //  person to the parents lists
    if (ind->father && ind->mother)
    {
      adduniqueidlist (&ind->father->offspring, ind);
      adduniqueidlist (&ind->father->mate, ind->mother);
      adduniqueidlist (&ind->mother->offspring, ind);
      adduniqueidlist (&ind->mother->mate,ind->father);
    }
    else if (ind->father || ind->mother) // The person has only one parent
      {
        code = 1;
        sprintf(buf2, "%s has only one parent in pedigree file\n", ind->id);
        WriteErrorMsg(buf2);
      }
     
  }

  if (code)
    printf("ERROR: A least one parent not found in pedigree file\n");

  // Fixing sibs
  forind
  {
    for (ind2 = ind->next; ind2; ind2 = ind2->next)
    {
      // If same father or mother then add to list of both
      if (((ind->father == ind2->father) && (ind->father)) || 
          ((ind->mother == ind2->mother) && (ind->mother)))
      {
        adduniqueidlist(&ind->sib, ind2);
        adduniqueidlist(&ind2->sib, ind);
      }
    }
  }

  // Have now read the file and made the dataset
  // Should fix the missing parts
  // This part definately needs some error checking

  // First set the marker names:
  for (i=1; i<=nmarkers; i++)
  {
    nl = cmalloc (sizeof (namelist));
    memset (nl,0,sizeof (namelist));

    sprintf(nl->name, "Marker %d",i);
    addlist(&markernames, nl);
  }

  // Then add trait names
  for (i=1; i<=ntraits; i++)
  {
    nl = cmalloc (sizeof (namelist));
    memset (nl,0,sizeof (namelist));

    sprintf(nl->name, "Trait %d",i);
    addlist(&traitnames, nl);
  }

  InitializeFrequencies(nmarkers);

  // Initialize order and distances
  order = ivector(1,nmarkers);
  invorder = ivector(1,nmarkers);
  distance = vector(1, nmarkers-1);
  for (i=1; i<=nmarkers; i++)
  {
    order[i] = i;
    invorder[i] = i;
  }

  for (i=1; i<nmarkers; i++)
    distance[i] = InverseMapFunction(0.1);
  
}