コード例 #1
0
extra_reset() {
    if (!witness) {
	witness = clone_object("obj/monster");
	witness->set_name("witness");
	witness->set_alias("witness of jehova");
	witness->set_level(3);
	witness->set_al(100);
	witness->set_short("One of Jehova's Witnesses");
	witness->set_long("This is person is a Witness of Jehova.\n" +
			  "He is not actually ugly, and he shows no obvious signs of insanity,\n" +
			  "but he has that unmistakable look of a disciple of Jehova.\n" +
			  "If he came knocking on your door,\n" +
			  "you wouldn't let him in.\n");
	witness->set_aggressive(0);
	witness->set_male();

	witness->set_spell_mess1("Witness tries to exorcise a demon from his attacker.");
	witness->set_spell_mess2("Witness tries to exorcise a demon from you. Ouch! That hurt!");
	witness->set_chance(20);
	witness->set_spell_dam(10);

	if (!chat_str)
	    setup_arrays();
	witness->load_chat(50, chat_str);
	witness->load_a_chat(50, a_chat_str);
	move_object(witness, this_object());
    }
} /* extra_reset */
コード例 #2
0
ファイル: logmsg.cpp プロジェクト: acml/cvsnt
/*
 * callback proc to actually do the logfile write from Update_Logfile
 */
static int update_logfile_proc (void *params, const trigger_interface *cb)
{
	int ret = 0;
	loginfo_param_t *args = (loginfo_param_t*)params;

	if(cb->loginfo)
	{
		char *status=NULL;

		if (args->logfp)
		{
			off_t len;
			fseek(args->logfp,0,SEEK_END);
			len=ftell(args->logfp);
			status = (char*)xmalloc(len+1);
			rewind (args->logfp);
			len = fread(status,1,len,args->logfp);
			if(len<0)
				xfree(status);
			else
				status[len]='\0';
		}
		setup_arrays("",args->changes);
		ret = cb->loginfo(cb,args->message,status,args->directory,loginfo_count,loginfo_array);
		xfree(status);
		xfree(loginfo_array);
	}
	return ret;
}
コード例 #3
0
make_golem() {
    object temp;

    golem = clone_object("obj/monster");	/* NEW, IMPROVED monster class! */
    golem->set_name("golem-padrone");
    golem->set_alias("golem");
    golem->set_level(21);
    golem->set_ep(120000);
    golem->set_hp(1000);
    golem->set_ac(5);
    golem->set_ac(5);
    golem->set_al(0);
    golem->set_short("Padrone the Wizard of Law and Balance (grey lord)");
    golem->set_long("The famous wizard doesn't have time to sit here and wait all day.\n" +
		    "Therefore he made this golem, named it Golem-padrone, and put\n" +
		    "it here. It is a silicon golem, and it is equipped with a\n" +
		    "limited amount of intelligence.\n");
    
    golem->set_aggressive(0);

    /* The NEW, IMPROVED monster calls: */
    if (!chat_str)
	setup_arrays();
    golem->load_chat(10, chat_str);
    golem->load_a_chat(20, a_chat_str);
    golem->set_match(this_object(), function, type, match);

    move_object(call_other("players/padrone/outside/front_yard", "make_ticket"), golem);
    move_object(golem, this_object());

    temp = clone_object("players/padrone/obj/wizardshat");
    move_object(temp, golem);
    golem->init_command("wear hat");
    golem->init_command("say lux");

    temp = clone_object("obj/weapon");
    temp->set_name("debugging tool");
    temp->set_alt_name("tool");
    temp->set_alias("debugger");
    temp->set_class(10);
    temp->set_value(100);
    temp->set_weight(3);
    temp->set_short("A debugging tool");
    temp->set_long("This is a debugging tool.\n" +
		   "One of the wizards probably made it to take care of all\n" +
		   "the bugs that crawl into his correct and beautiful programs\n" +
		   "as soon as he's looking the other way.\n" +
		   "It looks like a big iron hammer with an extra wide head.\n");
    temp->set_hit_func(this_object());
    move_object(temp, golem);

    golem->set_ac(10);		/* After all wear commands! */
} /* make_robot_padrone */
コード例 #4
0
ファイル: path3.c プロジェクト: Shea690901/Castles_and_Quests
make_mathilda() {
    object dagger, bag, torch;
    
    mathilda = clone_object("obj/monster");		/* NEW, IMPROVED monster class! */
    mathilda->set_name("mathilda");
    mathilda->set_level(2);
    mathilda->set_ep(100);
    mathilda->set_hp(7);
    mathilda->set_al(150);
    mathilda->set_short("Mathilda the small thief (good)");
    mathilda->set_long("Mathilda is a dressed in black clothes, and she carries a dagger\n" +
		       "and a bag to carry things in. She is probably a thief.\n" +
		       "But something terrible has happened to Mathilda, and she\n" +
		       "is horribly hurt. She will probably die any minute now.\n");
    mathilda->set_aggressive(0);
    mathilda->set_spell_mess1("Mathilda bleeds a little.");
    mathilda->set_spell_mess2("Mathilda bleeds on you.");
    mathilda->set_chance(20);
    mathilda->set_spell_dam(0);
    
    move_object(mathilda, this_object());
    /* The NEW, IMPROVED monster calls: */
    if (!chat_str)
	setup_arrays();
    mathilda->load_chat(20, chat_str);
    
    dagger = clone_object("obj/weapon");
    dagger->set_name("dagger");
    dagger->set_class(7);
    dagger->set_value(10);
    dagger->set_weight(1);
    dagger->set_short("A dagger");
    dagger->set_long("This is an ordinary dagger, like the ones thieves often carry.\n");
    move_object(dagger, mathilda);
    mathilda->init_command("wield dagger");
    
    bag = clone_object("obj/bag");
    move_object(bag, mathilda);
    
    torch = clone_object("obj/torch");
    torch->set_name("torch");
    torch->set_fuel(2000);
    torch->set_weight(1);
    move_object(torch, bag);
} /* make_mathilda */
コード例 #5
0
ファイル: atlc.c プロジェクト: kgoulet/mdtlc
/*
atlc - arbitrary transmission line calculator, for the analysis of
transmission lines are directional couplers. 

Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either package_version 2
of the License, or (at your option) any later package_version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
USA.

Dr. David Kirkby, e-mail [email protected] 

*/
#include "config.h"


#ifdef HAVE_STRING_H
#include <string.h>
#endif

#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif

#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif  

#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif

#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif

#include "definitions.h"
#include "exit_codes.h"

#ifdef ENABLE_POSIX_THREADS
#include <pthread.h>
#endif

#ifdef ENABLE_MPI
#include <mpi.h>
#endif


#ifdef WINDOWS
#pragma hrdstop
#include <condefs.h>
#endif



struct pixels Er_on_command_line[MAX_DIFFERENT_PERMITTIVITIES];
struct pixels Er_in_bitmap[MAX_DIFFERENT_PERMITTIVITIES];

double **Vij;
double **Er;
unsigned char **oddity; 
unsigned char **cell_type; 
unsigned char *image_data;
unsigned char **cell_dielectric;  // mdtlc addition
int width=-1,  height=-1;
//extern int errno;    // mdtlc
//int errno;    // mdtlc
int number_of_workers=MAX_THREADS; 
int non_vacuum_found=FALSE;
int dielectrics_to_consider_just_now;
int coupler=FALSE;
double r=1.90;
 
char *inputfile_name;
double* pVodd;
double* pVeven;

//
// ADDITIONS FOR FLTK GUI
//
#include <windows.h>
#include <cstdlib>
#include <iostream>
#include <time.h>
//#include "browser_log.h"
//#include "trimp.h"


// moved the following from main2 to global because it has to be shared
// with gui
struct transmission_line_properties data;

//int main2(int argc, char **argv) /* Read parameters from command line */
int main2(char* p_file_name, unsigned char* bitmap_in , int w_pix , int h_pix,
    double* Vodd , double* Veven)
{
  FILE *where_to_print_fp=stdout, *image_data_fp;
  char *outputfile_name, *appendfile_name, *output_prefix;
  long i;
  size_t size;
  int offset;
  int q;
  char *end;
  
// added for mdtlc -- atlc has a habit of assuming a new run for each calculation
coupler=FALSE;
r=1.90;

  pVodd = Vodd;
  pVeven = Veven;
  
  printf("Deallocating\n");
// moved free up here to allow gui to access data
  
//if ( oddity != NULL )
//  free_ucmatrix(oddity,0,width-1,0,height-1);
//if ( cell_type != NULL )
//  free_ucmatrix(cell_type,0,width-1,0,height-1);
//if ( Vij != NULL )
//  free_dmatrix(Vij, 0,width-1,0,height-1);
//if ( Er != NULL )
//  free_dmatrix(Er,0,width-1,0,height-1);


  //errno=0;   // mdtlc
  set_data_to_sensible_starting_values(&data);
  inputfile_name=string(0,1024);
  outputfile_name=string(0,1024);
  appendfile_name=string(0,1024);
  output_prefix=string(0,1024);
  /* only use this if we have both a multi-threaded application and that 
  with have the function */
  (void) strcpy(output_prefix,"");
//  while((q=get_options(argc,argv,"Cr:vsSc:d:p:i:t:w:")) != -1)
//  switch (q) 
//  {
//    case 'C':
//      print_copyright( (char *) "1996-2002");
//      exit_with_msg_and_exit_code("",1);
//    break;
//    case 'b':
//      data.should_binary_data_be_written_tooQ=TRUE;
//    break;
//    case 'd':
//      /* Read a colour from the command line */
//      Er_on_command_line[data.dielectrics_on_command_line].other_colour=\
//      strtol(my_optarg, &end, 16);
//      /* Sepparte it into the Red, Green and Blue components */
//      Er_on_command_line[data.dielectrics_on_command_line].blue=\
//      Er_on_command_line[data.dielectrics_on_command_line].other_colour%256;
//      Er_on_command_line[data.dielectrics_on_command_line].green=\
//      Er_on_command_line[data.dielectrics_on_command_line].other_colour/(256);
//      Er_on_command_line[data.dielectrics_on_command_line].red=\
//      Er_on_command_line[data.dielectrics_on_command_line].other_colour/(256*256);
//      end++; /* Gets rid of '=' sign which we put on the command line */
//      Er_on_command_line[data.dielectrics_on_command_line].epsilon=atof(end);
//      if (data.verbose_level > 1)
//        printf("r=%x g=%x b=%x col=%x Er=%f\n",\
//      Er_on_command_line[data.dielectrics_on_command_line].red,\
//      Er_on_command_line[data.dielectrics_on_command_line].green, \
//      Er_on_command_line[data.dielectrics_on_command_line].blue, \
//      Er_on_command_line[data.dielectrics_on_command_line].other_colour, \
//      Er_on_command_line[data.dielectrics_on_command_line].epsilon);
//      data.dielectrics_on_command_line++;
//    break;
//    case 'c':
//      data.cutoff=atof(my_optarg);
//    break;
//    case 'p':
//      (void) strcpy(output_prefix,my_optarg);
//    break;
//    case 'r':
//      data.r=atof(my_optarg);
//      r=data.r;
//    break;
//    case 's':
//      data.write_bitmap_field_imagesQ=FALSE;
//    break;
//    case 'S':
//      data.write_binary_field_imagesQ=FALSE;
//    break;
//    case 't':
//      number_of_workers=atol(my_optarg);
//      if(number_of_workers > MAXIMUM_PROCESSING_DEVICES)
//      {
//         fprintf(stderr,"You are exceeded the %d limit set in the file definitions.h\n",MAXIMUM_PROCESSING_DEVICES);
//	 fprintf(stderr,"If you really do want this many, you will need to recompile\n");    
//         exit_with_msg_and_exit_code("",USER_REQUESTED_TOO_MANY_THREADS);
//      }
//#ifndef ENABLE_POSIX_THREADS
//      if(number_of_workers != 0)
//         exit_with_msg_and_exit_code("Error #1. The -t option can not be \
//used, (except to  set t=0, which is an \nexception made to allow a \
//benchmark to run), on a version of atlc that was \nnot configured with the \
//--with-threads option, and hence built without the \nthreads library.\n",1);
//#endif
//    break;
//    case 'w':
//#ifndef ENABLE_MPI
//      exit_with_msg_and_exit_code("Error #1a. The -w option can not be used on \
//a version of atlc that was not\nconfigured with the --with-mpi option, \
//hence built without the mpi\nlibrary.\n",1);
//#endif
//          break;
//    case 'i': /* Lighten or darken images of E-field */
//	  data.image_fiddle_factor=atof(my_optarg);
//	  break;
//    case 'v':
//      data.verbose_level++;
//    break;
//    case '?':
//      usage_atlc();
//  } /* End of the switch statement */

  /* There should only be one argument to atlc, the bitmapfile name.
  There can be a few options though. We now check that there is only
  one argument */

//  if(argc-my_optind == 1)  /* This should be so hopefully !! */
//  {
//#ifdef DEBUG
//  if (errno != 0)
//    fprintf(stderr,"errno=%d in atlc.c #2\n",errno);
//#endif
    (void) strcpy(inputfile_name, p_file_name);
    (void) strcpy(outputfile_name, output_prefix);
    (void) strcat(output_prefix,inputfile_name);
    (void) strcpy(outputfile_name,output_prefix);
    free_string(output_prefix,0,1024);

//    read_bitmap_file_headers(inputfile_name, &offset, &size, &width, &height);

    /* Allocate all ram now, so atlc is sure to have it. There is no point
    in getting some now, starting work then finding atlc can't get the 
    rest of what is needed. */
    offset=0;
    width = w_pix;
    height = h_pix;
    size = w_pix*h_pix*3;
//    image_data=ustring(0L,(long)size); // KG just use source bitmap from gui
    image_data = bitmap_in;
    oddity=ucmatrix(0,width-1,0,height-1);
    cell_type=ucmatrix(0,width-1,0,height-1);
    cell_dielectric=ucmatrix(0,width-1,0,height-1);  // mdtlc addition
    Vij=dmatrix(0,width-1,0,height-1);
    Er=dmatrix(0,width-1,0,height-1);
    /* On Solaris systems, if the following is not executed, only one 
    thread will run at any one time, which rather defeats the object of 
    running multi-threaded. */

#ifdef ENABLE_POSIX_THREADS
#ifdef HAVE_PTHREAD_SETCONCURRENCY     
    pthread_setconcurrency(number_of_workers);
#endif 
#endif 

    /* Each thread solves the equations for a part of the voltage
    matrix. If there were more threads than columms we would have a
    problem. I'm not sure exactly how many can be got away with, but
    one is unlikly to have more cpus that matrix columns */

    /* In theory, it would be sensible to get atlc to be able to read
    from stdin. This is a test, that checks if the filename is '-', and
    if so assumes its reading from stdin. So far, the program is
    unable to read from stdin, so this code is not really doing
    anything useful, but might be expanded at a later date. */
//#ifdef DEBUG
//  if (errno != 0)
//    fprintf(stderr,"errno=%d in atlc.c #3\n",errno);
//#endif
//    if( strcmp(argv[my_optind],"-") != 0)
//    {
//      if( (image_data_fp=fopen(inputfile_name, "rb")) == NULL)
//      {
//        fprintf(stderr,"Error #3. Can't open %s!!!!!\n", argv[my_optind]);
//        exit_with_msg_and_exit_code("",3);
//      }
//      if(fseek(image_data_fp, offset, SEEK_SET)!=0)
//      {   
//        fprintf(stderr,"Error #4. Sorry, unable to seek to the correct part \
//	(offset=%d) of the bmp image\n", offset);
//	exit_with_msg_and_exit_code("",4);
//      }
//    } /* end of if( strcmp(argv[my_optind],"-") != 0) */
//    else
//      image_data_fp=stdin;
//    /* For some unknown reason Microsoft's Visual C++ was unhappy to read
//    the bitmap image using an fread() call. Instead, the following two 
//    stupid lines fixed that issue. This will only get compiled under 
//    Windoze, the more sensible fread call being used on other operating 
//    systems. */
//
//#ifdef WINDOWS
//    for(i=0; (i < (long)size ) && (feof(image_data_fp)==0); i++)
//      image_data[i]=(unsigned char)fgetc(image_data_fp);
//#else
//	i = fread(image_data,  size, 1, image_data_fp);
//#endif
//    if((ferror(image_data_fp) || (i != 1 )))
//    {
//      fprintf(stderr,"Error #5. Unable to read all of the image data properly\n");
//      exit_with_msg_and_exit_code("",5);
//    }
    /* declare matrix's to indicate what pixels are fixed and variable */
    /* We now fill the following 3 arrays with the correct data, based on the 
    contents of the bitmap image */
 
    setup_arrays(&data);

    set_oddity_value();
   // system("PAUSE");  
    /* If there are multiple dielectrics, the impedance calculations
    needs to be done twice. We start by doing them once, for an vacuum
    dielectric. If necessary, they will be done again */
    do_fd_calculation(&data, size, where_to_print_fp,outputfile_name);
//  }
//  else
//  {
//    usage_atlc();
//    return(PROGRAM_CALLED_WITH_WRONG_NUMBER_OF_ARGUMENTS); 
//  }
  free_string(inputfile_name,0,1024);
  free_string(outputfile_name,0,1024);
  free_string(appendfile_name,0,1024);
//  free_ustring(image_data,0L,(long) size);

  free_ucmatrix(oddity,0,width-1,0,height-1);
  free_ucmatrix(cell_type,0,width-1,0,height-1);
  free_ucmatrix(cell_dielectric,0,width-1,0,height-1);  // mdtlc addition
  free_dmatrix(Vij, 0,width-1,0,height-1);
  free_dmatrix(Er,0,width-1,0,height-1);


  
    // system("PAUSE");
  
  return(OKAY); 
}
コード例 #6
0
make_obliterator() {
    object special_sword, talker, thing;
      
    follow = 0;
    follow_name = 0;
    last_talker = 0;
    found_him = 0;
    vasques = 0;
      
    obliterator = clone_object("obj/monster");	/* NEW, IMPROVED monster class! */
    obliterator->set_name("obliterator");
    obliterator->set_alias("sir obliterator");
    obliterator->set_level(19);
    obliterator->set_hp(250);
    obliterator->set_al(-1000);
    obliterator->set_short("Sir Obliterator, the anti-paladin");
    obliterator->set_long("Sir Obliterator is an evil anti-paladin.\n" +
			  "He is dressed in black, has a grim look on his face, and is quite\n" +
			  "obviously very, very dangerous. You are lucky today, however,\n" +
			  "because he doesn't seem to be the least interested in you.\n" +
			  "Sir Obliterator is on an important mission -- a matter of life\n" +
			  "and death! Well, mostly death, really...\n");
    obliterator->set_aggressive(0);
    obliterator->set_spell_mess1("Sir Obliterator kicks his opponent hard with his combat boots.");
    obliterator->set_spell_mess2("Sir Obliterator kicks you hard with his combat boots.");
    obliterator->set_chance(20);
    obliterator->set_spell_dam(20);
    obliterator->set_dead_ob(this_object());
    move_object(obliterator, this_object());
    
    /* The NEW, IMPROVED monster calls: */
    if (!chat_str)
	setup_arrays();
    obliterator->load_chat(10, chat_str);
    obliterator->load_a_chat(20, a_chat_str);
    obliterator->set_match(this_object(), function, type, match);
    
    thing = clone_object("obj/treasure");
    thing->set_id("amulet");
    thing->set_alias("big black iron amulet");
    thing->set_short("A big black iron amulet");
    thing->set_long("This is Sir Obliterator's teleport device, a big and heavy black amulet\n" +
		    "made of iron, engraved with some evil-looking runes. You cannot use\n" +
		    "it to teleport, since it was made specifically for Sir Obliterator.\n");
    thing->set_weight(4);
    thing->set_value(20);
    move_object(thing, obliterator);
    
    thing = clone_object("obj/armour");
    thing->set_name("chainmail");
    thing->set_alias("armour");
    thing->set_type("armour");
    thing->set_ac(3);
    thing->set_value(500);
    thing->set_weight(5);
    thing->set_short("A suit of chainmail");
    move_object(thing, obliterator);
    obliterator->add_weight(5);
    obliterator->init_command("wear chainmail");
    
    thing = clone_object("obj/armour");
    thing->set_name("shield");
    thing->set_alias("big black shield");
    thing->set_type("shield");
    thing->set_ac(1);
    thing->set_value(100);
    thing->set_weight(5);
    thing->set_short("A big black shield with a picture painted on it");
    thing->set_long("The shield is big, black but not very beautiful.\n" +
		    "There is a picture painted on it, a picture of a dead\n" +
		    "person, called Vasques, being eaten by a black dragon.\n");
    move_object(thing, obliterator);
    obliterator->add_weight(6);
    obliterator->init_command("wear shield");
    
    thing = clone_object("obj/armour");
    thing->set_name("metal helmet");
    thing->set_ac(1);
    thing->set_weight(2);
    thing->set_value(75);
    thing->set_alias("helmet");
    thing->set_type("helmet");
    thing->set_short("A metal helmet");
    thing->set_long("A metal helmet.\n");
    move_object(thing, obliterator);
    obliterator->add_weight(2);
    obliterator->init_command("wear helmet");
    
    thing = clone_object("obj/armour");
    thing->set_name("combat boots");
    thing->set_ac(1);
    thing->set_weight(1);
    thing->set_value(75);
    thing->set_alias("boots");
    thing->set_type("boot");
    thing->set_short("A pair of combat boots");
    move_object(thing, obliterator);
    obliterator->add_weight(1);
    obliterator->init_command("wear boots");
    
    sword = clone_object("obj/weapon");
    sword->set_name("black longsword");
    sword->set_alt_name("longsword");
    sword->set_alias("sword");
    sword->set_class(16);
    sword->set_value(200);
    sword->set_weight(3);
    sword->set_short("A black longsword");
    sword->set_long("This is the black longsword of Sir Obliterator, the anti-paladin.\n" +
		    "As a weapon it's not really that impressing, but Sir Obliterator\n" +
		    "obviously thinks it is quite sufficient for the random encounters\n" +
		    "he will have while he is on his quest - those nerds who actually\n" +
		    "are stupid enough to attack him. Him!\n" +
		    "For his real mission, though, he has another weapon...\n");
    sword->set_hit_func(this_object());
    move_object(sword, obliterator);
    obliterator->add_weight(3);
    obliterator->init_command("wield sword");
    
    special_sword = clone_object("obj/weapon");
    special_sword->set_name("unholy avenger");
    special_sword->set_alt_name("avenger");
    special_sword->set_alias("sword");
    special_sword->set_class(WEAPON_CLASS);
    special_sword->set_value(8000);
    special_sword->set_weight(6);
    special_sword->set_short("An Unholy Avenger of Specified Annihilation");
    special_sword->set_long("What a horrible weapon! It is black as night, cold as ice and heavy\n" +
			    "as a gravestone soaked in blood. You shiver with fear just from\n" +
			    "looking at this evil, evil, evil thing.\n" +
			    "But you understand that this is a very special weapon, existing\n" +
			    "only for a single purpose. Somewhere, someone has made this sword,\n" +
			    "infested it with pure evil, and filled it with a hate that burns\n" +
			    "for a single being in the world...\n");
    move_object(special_sword, "players/padrone/outside/obli_hit_func");
    special_sword->set_hit_func(environment(special_sword));
    special_sword->set_wield_func(this_object());
    move_object(special_sword, obliterator);
      
    /* Adjusted for his extra strength and agility, to match Vasques: */
    obliterator->set_ac(9);
    obliterator->set_wc(30);
} /* make_obliterator */