Updated Dave's chargen to use character.c as datasource, need to do a rewrite

master
silverwizard 5 years ago
parent 22da63b4bc
commit aef524d8ce
  1. 4
      Makefile
  2. 86
      character.c
  3. 4
      character.h
  4. 11
      chargen.c

@ -1,10 +1,8 @@
CC=cc
LIBS=-lm
generator:
${CC} -o charactergenerator ${LIBS} character.c
server:
${CC} -o chargen chargen.c
${CC} -o chargen ${LIBS} chargen.c
all: server generator

@ -317,9 +317,13 @@ void genBackground(){
}
}
int main(){
char * genChar(char* output){
profs = 0;
languages = 0;
for(int i = 0; i <= 100; i++){
otherprofs[i] = '\0';
}
int i;
strlcat(otherprofs, "", 1);
genRace();
genClass();
genBackground();
@ -327,111 +331,113 @@ int main(){
stats[i] = dieroll(3,6);
mods[i] = floor((stats[i]/2)-5);
}
printf("Race = %s\nBackground = %s\nClass = %s\nStr = %d %d\nDex = %d %d\nCon = %d %d\nInt = %d %d\nWis = %d %d\nCha = %d %d\n\nHP: %d\n", race, background, class, stats[STR], mods[STR], stats[DEX], mods[DEX], stats[CON], mods[CON], stats[INT], mods[INT], stats[WIS], mods[WIS], stats[CHA], mods[CHA], hp);
snprintf(output, 512, "Race = %s\r\nBackground = %s\r\nClass = %s\r\nStr = %d %d\r\nDex = %d %d\r\nCon = %d %d\r\nInt = %d %d\r\nWis = %d %d\r\nCha = %d %d\r\n\r\nHP: %d\r\n", race, background, class, stats[STR], mods[STR], stats[DEX], mods[DEX], stats[CON], mods[CON], stats[INT], mods[INT], stats[WIS], mods[WIS], stats[CHA], mods[CHA], hp);
printf("Proficiences:\n");
strlcat(output,"Proficiences:\r\n",512);
if((ATHLETICS & profs) != 0){
printf("Athletics\n");
strlcat(output,"Athletics\r\n",512);
}
if((ACROBATICS & profs) != 0){
printf("Acrobatics\n");
strlcat(output,"Acrobatics\r\n",512);
}
if((SLEIGHTOFHAND & profs) != 0){
printf("Sleight of Hand\n");
strlcat(output,"Sleight of Hand\r\n",512);
}
if((STEALTH & profs) != 0){
printf("Stealth\n");
strlcat(output,"Stealth\r\n",512);
}
if((ARCANA & profs) != 0){
printf("Arcana\n");
strlcat(output,"Arcana\r\n",512);
}
if((HISTORY & profs) != 0){
printf("History\n");
strlcat(output,"History\r\n",512);
}
if((INVESTIGATION & profs) != 0){
printf("Investigation\n");
strlcat(output,"Investigation\r\n",512);
}
if((NATURE & profs) != 0){
printf("Nature\n");
strlcat(output,"Nature\r\n",512);
}
if((RELIGION & profs) != 0){
printf("Regligion\n");
strlcat(output,"Regligion\r\n",512);
}
if((ANIMALHANDLING & profs) != 0){
printf("Animal Handling\n");
strlcat(output,"Animal Handling\r\n",512);
}
if((INSIGHT & profs) != 0){
printf("Insight\n");
strlcat(output,"Insight\r\n",512);
}
if((MEDICINE & profs) != 0){
printf("Medicine\n");
strlcat(output,"Medicine\r\n",512);
}
if((PERCEPTION & profs) != 0){
printf("Perception\n");
strlcat(output,"Perception\r\n",512);
}
if((SURVIVAL & profs) != 0){
printf("Survival\n");
strlcat(output,"Survival\r\n",512);
}
if((DECEPTION & profs) != 0){
printf("Deception\n");
strlcat(output,"Deception\r\n",512);
}
if((INTIMIDATION & profs) != 0){
printf("Intimidation\n");
strlcat(output,"Intimidation\r\n",512);
}
if((PERFORMANCE & profs) != 0){
printf("Performance\n");
strlcat(output,"Performance\r\n",512);
}
if((PERSUASION & profs) != 0){
printf("Persuaion\n");
strlcat(output,"Persuaion\r\n",512);
}
printf("\nLanguages:\nCommon\n");
strlcat(output,"\r\nLanguages:\r\nCommon\r\n",512);
if((ABYSSAL & languages) != 0){
printf("Abyssal\n");
strlcat(output,"Abyssal\r\n",512);
}
if((CELESTIAL & languages) != 0){
printf("Celestial\n");
strlcat(output,"Celestial\r\n",512);
}
if((DRACONIC & languages) != 0){
printf("Draconic\n");
strlcat(output,"Draconic\r\n",512);
}
if((DEEPSPEECH & languages) != 0){
printf("Deep Speech\n");
strlcat(output,"Deep Speech\r\n",512);
}
if((INFERNAL & languages) != 0){
printf("Infernal\n");
strlcat(output,"Infernal\r\n",512);
}
if((PRIMORDIAL & languages) != 0){
printf("Primordial\n");
strlcat(output,"Primordial\r\n",512);
}
if((SYLVAN & languages) != 0){
printf("Sylvan\n");
strlcat(output,"Sylvan\r\n",512);
}
if((UNDERCOMMON & languages) != 0){
printf("Undercommon\n");
strlcat(output,"Undercommon\r\n",512);
}
if((DWARVISH & languages) != 0){
printf("Dwarvish\n");
strlcat(output,"Dwarvish\r\n",512);
}
if((ELVISH & languages) != 0){
printf("Elvish\n");
strlcat(output,"Elvish\r\n",512);
}
if((GIANT & languages) != 0){
printf("Giant\n");
strlcat(output,"Giant\r\n",512);
}
if((GNOMISH & languages) != 0){
printf("Gnome\n");
strlcat(output,"Gnome\r\n",512);
}
if((GOBLIN & languages) != 0){
printf("Goblin\n");
strlcat(output,"Goblin\r\n",512);
}
if((HALFLISH & languages) != 0){
printf("Halfling\n");
strlcat(output,"Halfling\r\n",512);
}
if((ORC & languages) != 0){
printf("Orcish\n");
strlcat(output,"Orcish\r\n",512);
}
printf("\nOther Profs: %s\n", otherprofs);
return 1;
strlcat(output,"\r\nOther Profs: ",512);
strlcat(output,otherprofs,512);
strlcat(output,"\r\n",512);
return output;
}

@ -80,8 +80,6 @@
#define WIS 4
#define CHA 5
unsigned long profs;
unsigned long languages;
char otherprofs[100];
@ -95,3 +93,5 @@ char* backgrounds[] = { "Acolyte", "Charlatan", "Criminal", "Entertainer", "Folk
int stats[6];
int mods[6];
int hp;
char* genChar();

@ -11,6 +11,8 @@
#include <unistd.h>
#include <netdb.h>
#include "character.c"
void usage_and_die(const char *myname, const char *fmt, ...)
{
if (fmt)
@ -246,7 +248,10 @@ int main(int argc, char **argv)
else
printf("Responding to packet from %s:%s...\n", hbuf, sbuf);
rval = sendto(s, "chargen data\r\n", 14, 0, sa, len);
//rval = sendto(s, "chargen data\r\n", 14, 0, sa, len);
char character[512];
genChar(character);
rval = sendto(s, character, 512, 0, sa, len);
if (rval == -1)
warn("sendto");
}
@ -281,7 +286,9 @@ int main(int argc, char **argv)
printf("WTF? i=%u num_stream=%u stream_fds[i]=%d s=%d\n", i, num_stream, stream_fds[i], s);
continue;
}
if (write(s, "chargen data\r\n", 14) == -1)
char character[512];
genChar(character);
if (write(s, character, 512) == -1)
{
warn("write");
printf("Closing stream connection\n");

Loading…
Cancel
Save