Menu

Example Programs

Karl H. Beckers

While the GriFFin project, as of now, is about the library, first and foremost, there are some sample applications that showcase API use and may be of some limited use on their own.

GriFFin CLI (command-line interface)

This is intended to evolve into collection of command-line utilities. Right now, the only feature supported is unpacking ERF or BIF files.
If you run it without specifying a command, you get a list of valid commands, like this:

C:\griffin-cli\target>java -jar griffin-cli-1.0-SNAPSHOT-jar-with-dependencies.jar
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
Please specify a command as the first argument.
Valid commands are: unpack

Ignore the lines starting with SLF4J, or add a SLF4J logger implementation of your choice, if you want to actually configure some logging, e. g. for debugging purposes.

The unpack command has a help page that tells you how to use it. If you're trying to extract resources from BIF, make sure you understand how BIF and KEY files work together. To extract from BIF, this tool requires you to have a KEY file. The KEY file, however, could also reference other BIF files for some resources. Those will not get extracted. If you have a KEY file that has the keys for six BIF files, to extract them all you would have to run the comman six times, specifying a different BIF file along with the same KEY file, each time.

C:\griffin-cli\target>java -jar griffin-cli-1.0-SNAPSHOT-jar-with-dependencies.jar unpack
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.

This command extracts ERF and BIF files. By default it
expects an ERF file. To extract a BIF file, you specify
the corresponding KEY file with the key parameter. In
BIF extraction mode, this command only extracts resources
mentioned in the KEY file from the BIF files mentioned on
the command line. It does not try to _find_ BIF files
based on the information from the KEY file.
All files are extracted to the current directory.


Non-option arguments:
[File] -- Files to extract.

Option                       Description
------                       -----------
-?, --help                   Display help/usage information.
-K, -k, --Key, --key <File>  Use the specified KEY file. This also changes
                               behaviour to BIF extraction
-v, --verbose                Print verbose output.

Build from source or download here

GriFFin Web-App

This is a quickly hacked together and totally ugly demo web application to spark off some imagination. You can download it from the "griffin-web-app" folder in the files section.

Use it like this with a NWN:EE installation that has subdirectories in the server vault by player public key:

  1. Install tomcat 7.x somewhere
  2. Edit the file conf/tomcat-users.xml below where you extracted the tomcat archive. Add lines like the following: <role rolename="player"/> <user password="ready" roles="player" username="player1"/>
  3. Deploy the griffin-web-app, ideally by creating a directory webapps/griffin in the tomcat installation and extracting the war file there: jar xvf griffin-web-app-<version>.war
  4. Change the path in webapps/griffin/WEB-INF/classes/nwn.properties to point to your server vault directory
  5. start tomcat
  6. browse to http://localhost:8080/griffin/home.jsf
  7. log in with user name "player1" and password "ready"
  8. DON'T RESTART TOMCAT WHILE YOU PLAY AROUND WITH THIS (because everything gets stored in an automatically created in-memory database that will get wiped with a restart.)

The use case that is implemented here is where you want to allow people to manage their own player characters, but need to be sure they actually own the account. You likely don't want to manually process people's claims that account XYZ is theirs. A challenge-response mechanism springs to mind, like this:

  1. You have this web application that you log in to somehow (we are using the most simple way provided by tomcat, here, but login mechanisms could easily be switched out.)
  2. The application now knows you are some person, but needs to verify you acutally own a certain account / public key before it can let you do stuff with it, so it allows you to claim a public key and will then ask you to log in to your account and create a character with a random first and last name
  3. After you do that, you can to back to the web application where you will see a list of accounts you have claimed and where you can either request a new challenge or tell the system you're done and that it should check.
  4. The web application then goes and checks if a character with the requested names is present and marks the account as confirmed for your user.
  5. After that, the web application could allow you to do whatever with the characters in your account, e. g. delete them, change description, etc. etc. (Though not everything that's technically possible might be a good idea, too.)

This is all a long way from complete. It doesn't even do conflict resolution for when multiple people claim an account. But feedback is very welcome.
And if you're a UI hacker and want to turn this into a cool HTML5 AJAX thing that pulls everything from the game resources to eventually become a full-blown graphical character editor, go for it :P


Related

Wiki: Home

MongoDB Logo MongoDB